Accessories
Arduino for motors and lights library.
AccessoryLightMulti Class Reference

#include "AccessoryLightMulti.hpp"

Inheritance diagram for AccessoryLightMulti:
Accessory

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 ()
 
- Public Member Functions inherited from Accessory
 Accessory ()
 
void begin (ACC_STATE inStartingState = STATE_NONE)
 
PortGetPort () 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 Public Member Functions inherited from Accessory
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 ()
 
- Protected Attributes inherited from Accessory
PortpPort
 
ACC_STATE prevState
 

Detailed Description

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 offoffoffoff
126 B10100 B00000 on offon offoff
127 B11000 B00001 on on offoffblink

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.

Constructor & Destructor Documentation

AccessoryLightMulti::AccessoryLightMulti ( )

Default constructor.

Definition at line 12 of file AccessoryLightMulti.cpp.

Member Function Documentation

unsigned char AccessoryLightMulti::AddMovingPosition ( unsigned long  inId,
int  inOnMask,
int  inBlinkMask = 0 
)

Add a new moving position.

Parameters
inIdId of this moving position.
inOnMaskEach bit at 1 of this mask will turn on this light on.
inBlinkMaskEach bit at 1 of this mask will flash this light. Default is 0.
Returns
index of the moving position in the internal list.

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.

Parameters
inNewSizenew size.

Definition at line 50 of file AccessoryLightMulti.cpp.

void AccessoryLightMulti::begin ( unsigned long  inId,
uint8_t  inSize,
unsigned long  inBlinkDuration 
)

Initialize the instance.

Parameters
inIdId of this accessory.
inSizeTotal number of lights in the group.
inBlinkDurationBlink 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.

Parameters
inIndexindex of the light in the group.
inpPortPort driven this light.
inIntensityIntensity of this light. Default is maximum, 255.

Definition at line 75 of file AccessoryLightMulti.cpp.

void AccessoryLightMulti::Blink ( uint8_t  inIndex)
inline

Turn the given light on and blink.

Parameters
inIndexIndex 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.

void AccessoryLightMulti::Event ( unsigned long  inId,
ACCESSORIES_EVENT_TYPE  inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID,
int  inData = 0 
)
virtual

Execute a new event.

Parameters
inIdId of an accessory or an accessory item.
inEventType of the new event. Default is ACCESSORIES_EVENT_MOVEPOSITIONID.
inDataAssociated data to the event type. Default is 0.

Reimplemented from Accessory.

Definition at line 172 of file AccessoryLightMulti.cpp.

int AccessoryLightMulti::GetMovingPositionBlinksByIndex ( int  inIndex) const
inline

Gets the blinking mask for the given index.

Parameters
inIndexIndex of the light to scan.
Returns
Blinking mask for the light number 'inIndex'.

Definition at line 96 of file AccessoryLightMulti.hpp.

uint8_t AccessoryLightMulti::GetSize ( ) const
inline

Gets the number of lights.

Returns
number of lights.

Definition at line 79 of file AccessoryLightMulti.hpp.

bool AccessoryLightMulti::IsBlinking ( uint8_t  inIndex) const
inline

Checks if the light is blinking.

Parameters
inIndexindex of the light to check.
Returns
true if the light is blinking.

Definition at line 69 of file AccessoryLightMulti.hpp.

bool AccessoryLightMulti::IsFading ( uint8_t  inIndex) const
inline

Checks if the light is fading.

Parameters
inIndexindex of the light to check.
Returns
true if the light is fading.
Remarks
A light can dim only with an analog pin.

Definition at line 75 of file AccessoryLightMulti.hpp.

bool AccessoryLightMulti::IsOn ( uint8_t  inIndex) const
inline

Checks if the light is blinking.

Parameters
inIndexindex of the light to check.
Returns
true if the light is blinking.

Definition at line 64 of file AccessoryLightMulti.hpp.

void AccessoryLightMulti::LightOff ( uint8_t  inIndex)
inline

Turn the given light off.

Parameters
inIndexIndex 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.

void AccessoryLightMulti::LightOn ( uint8_t  inIndex)
inline

Turn the given light on.

Parameters
inIndexIndex 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.

void AccessoryLightMulti::SetBlinking ( uint8_t  inIndex,
unsigned long  inBlinkingDelay 
)
inline

Sets the blinking delay for the given index.

Parameters
inIndexIndex of the light to scan.
inBlinkingDelayBlinking delay in milliseconds for the light number 'inIndex'.

Definition at line 101 of file AccessoryLightMulti.hpp.

void AccessoryLightMulti::SetFading ( uint8_t  inIndex,
uint8_t  inStep,
uint8_t  inDelay 
)
inline

Sets the fading steps for the given index.

Parameters
inIndexIndex of the light to scan.
inStepNumber of steps between light on and light off.
inDelayDuration of each step.

Definition at line 107 of file AccessoryLightMulti.hpp.


The documentation for this class was generated from the following files: