Class: Toybox::AntPlus::LightNetwork

Inherits:
Device show all

Overview

A class representing a network of bike lights

Examples:

A basic example of LightNetwork and LightNetworkListener setup

using Toybox.AntPlus;
class MyLightNetworkListener extends AntPlus.LightNetworkListener {
    var mNetworkState = 0;

    function onLightNetworkStateUpdate(data) {
        mNetworkState = data;
    }
}

// In app class…
    function initialize() {
        mLightNetworkListener = new MyLightNetworkListener();
        mLightNetwork = new AntPlus.LightNetwork(mLightNetworkListener);
    }

    function onUpdate(dc) {
        // Call parent's onUpdate(dc) to redraw the layout
        View.onUpdate(dc);

        if (null != mLightNetworkListener.mNetworkState) {
            dc.drawText(
                10,
                10,
                Gfx.FONT_TINY,
                mLightNetworkListener.mNetworkState.toString(),
                Gfx.TEXT_JUSTIFY_LEFT);
        }

        if (mode < 15) {
            mode++;
        }
        else {
            mode = 0;
        }
        mLightNetwork.setHeadlightsMode(mode);
    }

Since:

  • 2.2.0

Light Type collapse

Methods inherited from Device

getBatteryStatus, getComponentIdentifiers, getDeviceState, getManufacturerInfo, getProductInfo, sendManufacturerMessage, sendPageRequest

Methods inherited from Lang::Object

equals, hashCode, method, toString, weak

Constructor Details

initialize(listener) ⇒ LightNetwork

Constructor for the LightNetwork object. takes an extension of the LightNetworkListener class as a parameter. null can be passed in instead if the user plans to only poll for data using the get* methods.

Parameters:

Since:

  • 2.2.0


17181
17182
# File 'Monkeybrains.rb', line 17181

def initialize(listener)
end

Instance Method Details

getBikeLightsToybox::Lang::Array

Get a list of lights in the network.

Returns:

Since:

  • 2.2.0


17120
17121
# File 'Monkeybrains.rb', line 17120

def getBikeLights()
end

getNetworkModeToybox::Lang::Number

Get the light network mode.

Returns:

Since:

  • 2.2.0


17105
17106
# File 'Monkeybrains.rb', line 17105

def getNetworkMode()
end

getNetworkStateToybox::Lang::Number

Get the light network state.

Returns:

Since:

  • 2.2.0


17112
17113
# File 'Monkeybrains.rb', line 17112

def getNetworkState()
end

restoreHeadlightsNetworkModeControlObject

Bring all headlights under the control of whichever light network mode has been chosen by the user.

Since:

  • 2.2.0


17126
17127
# File 'Monkeybrains.rb', line 17126

def restoreHeadlightsNetworkModeControl()
end

restoreTaillightsNetworkModeControlObject

Bring all taillights under the control of whichever light network mode has been chosen by the user.

Since:

  • 2.2.0


17132
17133
# File 'Monkeybrains.rb', line 17132

def restoreTaillightsNetworkModeControl()
end

setHeadlightsMode(mode) ⇒ Object

Tell all headlights to enter the same mode.

You should check the capable modes of each headlight in the network before sending light modes, as lights will ignore commands to go into modes that they do not support. Lights whose modes are set here will not be controlled by the Light Network Mode until they are restored OR until the user changes the Light Network Mode outside of ConnectIQ.

Parameters:

Since:

  • 2.2.0


17146
17147
# File 'Monkeybrains.rb', line 17146

def setHeadlightsMode(mode)
end

setTaillightsMode(mode) ⇒ Object

Tell all taillights to enter the same mode.

You should check the capable modes of each taillight in the network before sending light modes, as lights will ignore commands to go into modes that they do not support. Lights whose modes are set here will not be controlled by the Light Network Mode until they are restored OR until the user changes the Light Network Mode outside of ConnectIQ.

Parameters:

Since:

  • 2.2.0


17160
17161
# File 'Monkeybrains.rb', line 17160

def setTaillightsMode(mode)
end

toggleSignalLight(left) ⇒ Object

A signal switch for right and left singals.

  • If signal light is engaged, disengage it.

  • If signal lgiht is disengaged, engage it.

*This will automatically disengage the opposite signal if it is currently engaged.

Parameters:

Since:

  • 2.2.0


17172
17173
# File 'Monkeybrains.rb', line 17172

def toggleSignalLight(left)
end