Accessories
Arduino for motors and lights library.
AccessoryLightMulti.hpp
1 //-------------------------------------------------------------------
2 #ifndef __accessoryLightMulti_H__
3 #define __accessoryLightMulti_H__
4 //-------------------------------------------------------------------
5 
6 #include "Accessory.hpp"
7 
8 //-------------------------------------------------------------------
9 
10 #ifndef NO_LIGHT
11 
12 #define LIGHTMULTI(list, nb) ((AccessoryLightMulti *) (list)[nb])
13 
36 {
37  private:
38  // Dont use a chained list here, because the user only gives a number. He does not add lights one by one...
39  AccessoryBaseLight *pLights;
40  int *pMovingPositionBlinks;
41  uint8_t lightsSize;
42 
43  public:
46 
52  void begin(unsigned long inId, uint8_t inSize, unsigned long inBlinkDuration);
58  void beginLight(uint8_t inIndex, Port *inpPort, int inIntensity = 255);
59 
64  inline bool IsOn(uint8_t inIndex) const { return this->pLights[inIndex].IsOn(); }
69  inline bool IsBlinking(uint8_t inIndex) const { return this->pLights[inIndex].IsBlinking(); }
75  inline bool IsFading(uint8_t inIndex) const { return this->pLights[inIndex].IsFading(); }
79  inline uint8_t GetSize() const { return this->lightsSize; }
80 
87  unsigned char AddMovingPosition(unsigned long inId, int inOnMask, int inBlinkMask = 0);
91  void AdjustMovingPositionBlinksSize(uint8_t inNewSize);
96  inline int GetMovingPositionBlinksByIndex(int inIndex) const { return this->pMovingPositionBlinks[inIndex]; }
101  inline void SetBlinking(uint8_t inIndex, unsigned long inBlinkingDelay) { this->pLights[inIndex].SetBlinking(inBlinkingDelay); }
107  inline void SetFading(uint8_t inIndex, uint8_t inStep, uint8_t inDelay) { this->pLights[inIndex].SetFading(inStep, inDelay); }
113  void Event(unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0);
114 
118  inline void LightOn(uint8_t inIndex) { this->pLights[inIndex].LightOn(); }
122  inline void LightOff(uint8_t inIndex) { this->pLights[inIndex].LightOff(); }
126  inline void Blink(uint8_t inIndex) { this->pLights[inIndex].Blink(); }
127 
129  void LightOn();
131  void LightOff();
133  void Blink();
134 
135  private:
136  inline void SetState(uint8_t inIndex, ACC_STATE inState) { this->pLights[inIndex].SetState(inState); }
137  inline ACC_STATE Toggle(uint8_t inIndex) { return this->pLights[inIndex].Toggle(); }
138 
139  inline bool IsGroupActionPending(uint8_t inIndex) { return this->pLights[inIndex].IsGroupActionPending(); }
140  inline void StartAction(uint8_t inIndex) { this->pLights[inIndex].StartAction(); }
141  inline bool ActionEnded(uint8_t inIndex) { return this->pLights[inIndex].ActionEnded(); }
142 
143  bool ActionEnded();
144 
145  ACC_STATE Toggle();
146  void Move(unsigned long inId);
147  void Move(int position);
148  void MoveBlink(int inOnMask, int inBlinkMask);
149 #ifndef NO_EEPROM
150  int EEPROMSave(int inPos, bool inSimulate = false);
151  int EEPROMLoad(int inPos);
152 #endif
153 #ifdef ACCESSORIES_DEBUG_MODE
154  void CheckPort() const;
155  void CheckIndex(int inIndex, const __FlashStringHelper *infunc);
156 #endif
157 
158 #ifdef ACCESSORIES_PRINT_ACCESSORIES
159  public:
163  void printAccessory();
167  void printMovingPositions();
168 #endif
169 };
170 #endif
171 
172 
173 //-------------------------------------------------------------------
174 #endif
175 //-------------------------------------------------------------------
virtual void StartAction()
Definition: Accessory.cpp:77
virtual bool IsGroupActionPending() const
Definition: Accessory.hpp:404
void LightOn(uint8_t inIndex)
void SetFading(uint8_t inStep, uint8_t inDelay)
void SetFading(uint8_t inIndex, uint8_t inStep, uint8_t inDelay)
void SetBlinking(unsigned long inBlinkingDelay)
void SetBlinking(uint8_t inIndex, unsigned long inBlinkingDelay)
void LightOff(uint8_t inIndex)
int GetMovingPositionBlinksByIndex(int inIndex) const
void AdjustMovingPositionBlinksSize(uint8_t inNewSize)
unsigned char AddMovingPosition(unsigned long inId, int inOnMask, int inBlinkMask = 0)
uint8_t GetSize() const
bool IsFading(uint8_t inIndex) const
bool IsBlinking(uint8_t inIndex) const
void Blink(uint8_t inIndex)
bool IsOn(uint8_t inIndex) const
Definition: Port.hpp:61
void Event(unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0)
void beginLight(uint8_t inIndex, Port *inpPort, int inIntensity = 255)
void begin(unsigned long inId, uint8_t inSize, unsigned long inBlinkDuration)