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

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


15372
15373
# File 'Monkeybrains.rb', line 15372

def initialize(listener)
end

Instance Method Details

getBikeLightsToybox::Lang::Array

Get a list of lights in the network.

Returns:

Since:

  • 2.2.0


15311
15312
# File 'Monkeybrains.rb', line 15311

def getBikeLights()
end

getNetworkModeToybox::Lang::Number

Get the light network mode.

Returns:

Since:

  • 2.2.0


15296
15297
# File 'Monkeybrains.rb', line 15296

def getNetworkMode()
end

getNetworkStateToybox::Lang::Number

Get the light network state.

Returns:

Since:

  • 2.2.0


15303
15304
# File 'Monkeybrains.rb', line 15303

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


15317
15318
# File 'Monkeybrains.rb', line 15317

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


15323
15324
# File 'Monkeybrains.rb', line 15323

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


15337
15338
# File 'Monkeybrains.rb', line 15337

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


15351
15352
# File 'Monkeybrains.rb', line 15351

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


15363
15364
# File 'Monkeybrains.rb', line 15363

def toggleSignalLight(left)
end