#include "AccessoryLightMulti.hpp"
Public Member Functions | |
AccessoryLightMulti () | |
void | begin (unsigned long inId, uint8_t inSize, unsigned long inBlinkDuration) |
void | beginLight (uint8_t inIndex, Port *inpPort, int inIntensity = 255) |
bool | IsOn (uint8_t inIndex) const |
bool | IsBlinking (uint8_t inIndex) const |
bool | IsFading (uint8_t inIndex) const |
uint8_t | GetSize () const |
unsigned char | AddMovingPosition (unsigned long inId, int inOnMask, int inBlinkMask = 0) |
void | AdjustMovingPositionBlinksSize (uint8_t inNewSize) |
int | GetMovingPositionBlinksByIndex (int inIndex) const |
void | SetBlinking (uint8_t inIndex, unsigned long inBlinkingDelay) |
void | SetFading (uint8_t inIndex, uint8_t inStep, uint8_t inDelay) |
void | Event (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0) |
void | LightOn (uint8_t inIndex) |
void | LightOff (uint8_t inIndex) |
void | Blink (uint8_t inIndex) |
void | LightOn () |
void | LightOff () |
void | Blink () |
![]() | |
Accessory () | |
void | begin (ACC_STATE inStartingState = STATE_NONE) |
Port * | GetPort () const |
ACC_STATE | GetState () const |
ACC_STATE | GetPreviousState () const |
bool | IsNone () const |
bool | IsFirst () const |
bool | IsSecond () const |
uint8_t | AddMovingPosition (unsigned long inId, int inPosition) |
unsigned int | GetDebounceDelay () const |
unsigned long | GetLastMoveTime () const |
unsigned long | GetDuration () const |
bool | loop () |
void | AdjustMovingPositionsSize (uint8_t inNewSize) |
bool | IsEmpty () const |
uint8_t | IndexOfMovingPosition (unsigned long inId) const |
int | GetMovingPosition (unsigned long inId) const |
int | GetMovingPositionByIndex (int inIndex) const |
unsigned long | GetMovingPositionIdByIndex (int inIndex) const |
const uint8_t | GetLastMovingPosition () const |
const uint8_t | GetMovingPositionSize () const |
void | SetLastMovingPosition (uint8_t inLastPositionIndex) |
void | SetDebounceDelay (unsigned int inDebounceDelay) |
void | SetLastMoveTime () |
void | SetDuration (unsigned long inDuration) |
void | SetNextAccessory (Accessory *inAccessory) |
Accessory * | GetNextAccessory () const |
unsigned long | GetActionStartingMillis () const |
virtual void | StartAction () |
virtual void | StartAction (ACC_STATE inState) |
virtual void | ResetAction () |
bool | IsActionDelayPending () const |
virtual bool | IsGroupActionPending () const |
virtual bool | CanBePositional () const |
virtual void | MovePosition (int inPosition) |
virtual void | SetState (ACC_STATE inNewState) |
void | SetStateRaw (ACC_STATE inNewState) |
void | SetStartingMillis () |
void | ResetStartingMillis () |
Additional Inherited Members | |
![]() | |
static void | ExecuteEvent (unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0) |
static uint8_t | GetCount () |
static bool | IsActionPending () |
static Accessory * | GetFirstAccessory () |
![]() | |
Port * | pPort |
ACC_STATE | prevState |
This class describes a group of lights. This is typically used for railroad or traffic signals. This group of lights can define a 'MovingPosition' which represents a combination of lights on, off and/or blinking. Each moving position defines an identifier and two masks on an integer, one for on/off status, another optional one for blinking lights. An integer is 16 bits long, so this is the maximum number of lights a MovingPosition can handle.
For a group of five lights, three moving positions defined with id from 125 to 127 (why not ?) :
moving position id | mask | blink mask | light 0 | 1 | 2 | 3 | 4 |
---|---|---|---|---|---|---|---|
125 | B10000 | B00000 | on | off | off | off | off |
126 | B10100 | B00000 | on | off | on | off | off |
127 | B11000 | B00001 | on | on | off | off | blink |
The moving positions are stored like any other Accessory in the MovingPosition list in the base class Accessory itself. The blinking masks cannot be stored in the same structure, so a new list of blinking masks is created inside this class, and the indexes are synchronized between the two lists.
Definition at line 35 of file AccessoryLightMulti.hpp.
AccessoryLightMulti::AccessoryLightMulti | ( | ) |
Default constructor.
Definition at line 12 of file AccessoryLightMulti.cpp.
unsigned char AccessoryLightMulti::AddMovingPosition | ( | unsigned long | inId, |
int | inOnMask, | ||
int | inBlinkMask = 0 |
||
) |
Add a new moving position.
inId | Id of this moving position. |
inOnMask | Each bit at 1 of this mask will turn on this light on. |
inBlinkMask | Each bit at 1 of this mask will flash this light. Default is 0. |
Definition at line 66 of file AccessoryLightMulti.cpp.
void AccessoryLightMulti::AdjustMovingPositionBlinksSize | ( | uint8_t | inNewSize | ) |
Sets the number of moving positions. If some MovingPosition was previously existing, they will be preserved.
inNewSize | new size. |
Definition at line 50 of file AccessoryLightMulti.cpp.
void AccessoryLightMulti::begin | ( | unsigned long | inId, |
uint8_t | inSize, | ||
unsigned long | inBlinkDuration | ||
) |
Initialize the instance.
inId | Id of this accessory. |
inSize | Total number of lights in the group. |
inBlinkDuration | Blink duration, 0 for fix light. Default is 0. |
Definition at line 32 of file AccessoryLightMulti.cpp.
void AccessoryLightMulti::beginLight | ( | uint8_t | inIndex, |
Port * | inpPort, | ||
int | inIntensity = 255 |
||
) |
Initialize one light in the group.
inIndex | index of the light in the group. |
inpPort | Port driven this light. |
inIntensity | Intensity of this light. Default is maximum, 255. |
Definition at line 75 of file AccessoryLightMulti.cpp.
|
inline |
Turn the given light on and blink.
inIndex | Index of the light to scan. |
Definition at line 126 of file AccessoryLightMulti.hpp.
void AccessoryLightMulti::Blink | ( | ) |
Turn all the lights on and blink.
Definition at line 93 of file AccessoryLightMulti.cpp.
|
virtual |
Execute a new event.
inId | Id of an accessory or an accessory item. |
inEvent | Type of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID. |
inData | Associated data to the event type. Default is 0. |
Reimplemented from Accessory.
Definition at line 172 of file AccessoryLightMulti.cpp.
|
inline |
Gets the blinking mask for the given index.
inIndex | Index of the light to scan. |
Definition at line 96 of file AccessoryLightMulti.hpp.
|
inline |
Gets the number of lights.
Definition at line 79 of file AccessoryLightMulti.hpp.
|
inline |
Checks if the light is blinking.
inIndex | index of the light to check. |
Definition at line 69 of file AccessoryLightMulti.hpp.
|
inline |
Checks if the light is fading.
inIndex | index of the light to check. |
Definition at line 75 of file AccessoryLightMulti.hpp.
|
inline |
Checks if the light is blinking.
inIndex | index of the light to check. |
Definition at line 64 of file AccessoryLightMulti.hpp.
|
inline |
Turn the given light off.
inIndex | Index of the light to scan. |
Definition at line 122 of file AccessoryLightMulti.hpp.
void AccessoryLightMulti::LightOff | ( | ) |
Turn all the lights off.
Definition at line 87 of file AccessoryLightMulti.cpp.
|
inline |
Turn the given light on.
inIndex | Index of the light to scan. |
Definition at line 118 of file AccessoryLightMulti.hpp.
void AccessoryLightMulti::LightOn | ( | ) |
Turn all the lights on.
Definition at line 81 of file AccessoryLightMulti.cpp.
|
inline |
Sets the blinking delay for the given index.
inIndex | Index of the light to scan. |
inBlinkingDelay | Blinking delay in milliseconds for the light number 'inIndex'. |
Definition at line 101 of file AccessoryLightMulti.hpp.
|
inline |
Sets the fading steps for the given index.
inIndex | Index of the light to scan. |
inStep | Number of steps between light on and light off. |
inDelay | Duration of each step. |
Definition at line 107 of file AccessoryLightMulti.hpp.