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, onMessage, onProductInfoUpdate, onSentMessage

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initializeBikePowerListener

Constructor.

Since:

  • 2.2.0


17572
17573
# File 'Monkeybrains.rb', line 17572

def initialize()
end

Instance Method Details

onCalculatedCadenceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17579
17580
# File 'Monkeybrains.rb', line 17579

def onCalculatedCadenceUpdate(data)
end

onCalculatedPowerUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17586
17587
# File 'Monkeybrains.rb', line 17586

def onCalculatedPowerUpdate(data)
end

onCalculatedWheelDistanceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17593
17594
# File 'Monkeybrains.rb', line 17593

def onCalculatedWheelDistanceUpdate(data)
end

onCalculatedWheelSpeedUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17600
17601
# File 'Monkeybrains.rb', line 17600

def onCalculatedWheelSpeedUpdate(data)
end

onPedalPowerBalanceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17607
17608
# File 'Monkeybrains.rb', line 17607

def onPedalPowerBalanceUpdate(data)
end

onTorqueEffectivenessPedalSmoothnessUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17615
17616
# File 'Monkeybrains.rb', line 17615

def onTorqueEffectivenessPedalSmoothnessUpdate(data)
end