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


17154
17155
# File 'Monkeybrains.rb', line 17154

def initialize(listener)
end

Instance Method Details

getBikeLightsToybox::Lang::Array

Get a list of lights in the network.

Returns:

Since:

  • 2.2.0


17093
17094
# File 'Monkeybrains.rb', line 17093

def getBikeLights()
end

getNetworkModeToybox::Lang::Number

Get the light network mode.

Returns:

Since:

  • 2.2.0


17078
17079
# File 'Monkeybrains.rb', line 17078

def getNetworkMode()
end

getNetworkStateToybox::Lang::Number

Get the light network state.

Returns:

Since:

  • 2.2.0


17085
17086
# File 'Monkeybrains.rb', line 17085

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


17099
17100
# File 'Monkeybrains.rb', line 17099

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


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

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


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

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


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

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


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

def toggleSignalLight(left)
end