Class: Toybox.AntPlus.BikePowerListener

Overview

Listener class for Bike Power.

Example:

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.distance);
    }

    //! 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:

API Level 2.2.0

Supported Devices:

Instance Method Summary collapse

Instance Method Details

initialize()

Constructor

Since:

API Level 2.2.0

onCalculatedCadenceUpdate(data as AntPlus.CalculatedCadence) as Void

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

Parameters:

Since:

API Level 2.2.0

onCalculatedPowerUpdate(data as AntPlus.CalculatedPower) as Void

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

Parameters:

Since:

API Level 2.2.0

onCalculatedWheelDistanceUpdate(data as AntPlus.CalculatedWheelDistance) as Void

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

Parameters:

Since:

API Level 2.2.0

onCalculatedWheelSpeedUpdate(data as AntPlus.CalculatedWheelSpeed) as Void

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

Parameters:

Since:

API Level 2.2.0

onPedalPowerBalanceUpdate(data as AntPlus.PedalPowerBalance) as Void

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

Parameters:

Since:

API Level 2.2.0

onTorqueEffectivenessPedalSmoothnessUpdate(data as AntPlus.TorqueEffectivenessPedalSmoothness) as Void

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

Parameters:

Since:

API Level 2.2.0


Generated Sep 23, 2024, 3:32:48 PM