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


17545
17546
# File 'Monkeybrains.rb', line 17545

def initialize()
end

Instance Method Details

onCalculatedCadenceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17552
17553
# File 'Monkeybrains.rb', line 17552

def onCalculatedCadenceUpdate(data)
end

onCalculatedPowerUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17559
17560
# File 'Monkeybrains.rb', line 17559

def onCalculatedPowerUpdate(data)
end

onCalculatedWheelDistanceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17566
17567
# File 'Monkeybrains.rb', line 17566

def onCalculatedWheelDistanceUpdate(data)
end

onCalculatedWheelSpeedUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


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

def onCalculatedWheelSpeedUpdate(data)
end

onPedalPowerBalanceUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


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

def onPedalPowerBalanceUpdate(data)
end

onTorqueEffectivenessPedalSmoothnessUpdate(data) ⇒ Object

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

Parameters:

Since:

  • 2.2.0


17588
17589
# File 'Monkeybrains.rb', line 17588

def onTorqueEffectivenessPedalSmoothnessUpdate(data)
end