Class: Toybox::AntPlus::BikePowerListener

Inherits:
DeviceListener show all

Overview

Listener class for Bike Power.

Examples:

An implementation of BikePowerListener

using Toybox.AntPlus;
class MyBikePowerListener extends AntPlus.BikePowerListener {

    hidden enum {
        ITEM_POWER,
        ITEM_DISTANCE,
        ITEM_SPEED
    }

    hidden const INDICATOR_HEIGHT_DISTANCE = 130;
    hidden const INDICATOR_HEIGHT_POWER = 100;
    hidden const INDICATOR_HEIGHT_SPEED = 160;

    var items;

    # Initializes class variables
    function initialize() {
        BikePowerListener.initialize();
        items = [
            new ListItem("power", INDICATOR_HEIGHT_POWER, Gfx.COLOR_PINK),
            new ListItem("distance", INDICATOR_HEIGHT_DISTANCE, Gfx.COLOR_BLUE),
            new ListItem("speed", INDICATOR_HEIGHT_SPEED, Gfx.COLOR_GREEN)
        ];
    }

    # Sets the isPowerUpdated boolean to true
    # Allows view to know an update has been received
    # Takes a data parameter which is the CalculatedPower object that has been
    # modified
    function onCalculatedPowerUpdate(data) {
        items[ITEM_POWER].setValue(data.power);
    }

    # Sets the isDistanceUpdated boolean to true
    # Allows view to know an update has been received
    # Takes a data parameter which is the CalculatedWheelDistance object that
    # has been modified
    function onCalculatedWheelDistanceUpdate(data) {
        items[ITEM_DISTANCE].setValue(data.wheelDistance);
    }

    # Sets the isSpeedUpdated boolean to true
    # Allows view to know an update has been received
    # Takes a data parameter which is the CalculatedWheelSpeed object that has
    # been modified
    function onCalculatedSpeedUpdate(data) {
        items[ITEM_SPEED].setValue(data.wheelSpeed);
    }
}

Since:

  • 2.2.0

Bike Power Sensor Type collapse

Methods inherited from DeviceListener

onBatteryStatusUpdate, onDeviceStateUpdate, onManufacturerInfoUpdate, onProductInfoUpdate

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initializeBikePowerListener

Constructor.

Since:

  • 2.2.0


15779
15780
# File 'Monkeybrains.rb', line 15779

def initialize()
end

Instance Method Details

onCalculatedCadenceUpdate(data) ⇒ Object

Callback when calculated cadence is updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15786
15787
# File 'Monkeybrains.rb', line 15786

def onCalculatedCadenceUpdate(data)
end

onCalculatedPowerUpdate(data) ⇒ Object

Callback when calculated power is updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15793
15794
# File 'Monkeybrains.rb', line 15793

def onCalculatedPowerUpdate(data)
end

onCalculatedWheelDistanceUpdate(data) ⇒ Object

Callback when calculated wheel distance is updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15800
15801
# File 'Monkeybrains.rb', line 15800

def onCalculatedWheelDistanceUpdate(data)
end

onCalculatedWheelSpeedUpdate(data) ⇒ Object

Callback when calculated wheel speed is updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15807
15808
# File 'Monkeybrains.rb', line 15807

def onCalculatedWheelSpeedUpdate(data)
end

onPedalPowerBalanceUpdate(data) ⇒ Object

Callback when power balance is updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15814
15815
# File 'Monkeybrains.rb', line 15814

def onPedalPowerBalanceUpdate(data)
end

onTorqueEffectivenessPedalSmoothnessUpdate(data) ⇒ Object

Callback when torque effectiveness & pedal smoothness are updated (max freq 1Hz)

Parameters:

Since:

  • 2.2.0


15822
15823
# File 'Monkeybrains.rb', line 15822

def onTorqueEffectivenessPedalSmoothnessUpdate(data)
end