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 
58 {
59  private:
60  // Do not use a chained list here, because the user only gives a number. He does not add lights one by one...
61  AccessoryBaseLight *pLights;
62  int *pMovingPositionBlinks;
63  uint8_t lightsSize;
64 
65  public:
68 
74  void begin(unsigned long inId, uint8_t inSize, unsigned long inBlinkDuration);
80  void beginLight(uint8_t inIndex, Port *inpPort, int inIntensity = 255);
81 
86  inline bool IsOn(uint8_t inIndex) const { return this->pLights[inIndex].IsOn(); }
91  inline bool IsBlinking(uint8_t inIndex) const { return this->pLights[inIndex].IsBlinking(); }
97  inline bool IsFading(uint8_t inIndex) const { return this->pLights[inIndex].IsFading(); }
101  inline uint8_t GetSize() const { return this->lightsSize; }
102 
109  unsigned char AddMovingPosition(unsigned long inId, int inOnMask, int inBlinkMask = 0);
113  void AdjustMovingPositionBlinksSize(uint8_t inNewSize);
118  inline int GetMovingPositionBlinksByIndex(int inIndex) const { return this->pMovingPositionBlinks[inIndex]; }
123  inline void SetBlinking(uint8_t inIndex, unsigned long inBlinkingDelay) { this->pLights[inIndex].SetBlinking(inBlinkingDelay); }
129  inline void SetFading(uint8_t inIndex, uint8_t inStep, uint8_t inDelay) { this->pLights[inIndex].SetFading(inStep, inDelay); }
135  void Event(unsigned long inId, ACCESSORIES_EVENT_TYPE inEvent = ACCESSORIES_EVENT_MOVEPOSITIONID, int inData = 0);
136 
140  inline void LightOn(uint8_t inIndex) { this->pLights[inIndex].LightOn(); }
144  inline void LightOff(uint8_t inIndex) { this->pLights[inIndex].LightOff(); }
148  inline void Blink(uint8_t inIndex) { this->pLights[inIndex].Blink(); }
149 
151  void LightOn();
153  void LightOff();
155  void Blink();
156 
157  private:
158  inline void SetState(uint8_t inIndex, ACC_STATE inState) { this->pLights[inIndex].SetState(inState); }
159  inline ACC_STATE Toggle(uint8_t inIndex) { return this->pLights[inIndex].Toggle(); }
160 
161  inline bool IsGroupActionPending(uint8_t inIndex) { return this->pLights[inIndex].IsGroupActionPending(); }
162  inline void StartAction(uint8_t inIndex) { this->pLights[inIndex].StartAction(); }
163  inline bool ActionEnded(uint8_t inIndex) { return this->pLights[inIndex].ActionEnded(); }
164 
165  bool ActionEnded();
166 
167  ACC_STATE Toggle();
168  void Move(unsigned long inId);
169  void Move(int position);
170  void MoveBlink(int inOnMask, int inBlinkMask);
171 #ifndef NO_EEPROM
172  int EEPROMSave(int inPos, bool inSimulate = false);
173  int EEPROMLoad(int inPos);
174 #endif
175 #ifdef ACCESSORIES_DEBUG_MODE
176  void CheckPort() const;
177  void CheckIndex(int inIndex, const __FlashStringHelper *infunc);
178 #endif
179 
180 #ifdef ACCESSORIES_PRINT_ACCESSORIES
181  public:
185  void printAccessory();
189  void printMovingPositions();
190 #endif
191 };
192 #endif
193 
194 
195 //-------------------------------------------------------------------
196 #endif
197 //-------------------------------------------------------------------
virtual bool IsGroupActionPending() const
Definition: Accessory.hpp:430
void LightOn(uint8_t inIndex)
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)
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)
virtual void StartAction()
Definition: Accessory.cpp:135
void begin(unsigned long inId, uint8_t inSize, unsigned long inBlinkDuration)
void SetFading(uint8_t inStep, uint8_t inDelay)