Advertisement
DrRandom

Struct arrays

Jun 21st, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.94 KB | None | 0 0
  1. /** TIMER ARRAYS **/
  2. #define MAX_TIMERS 255
  3.  
  4. int Timer_Counter = 0;
  5. uint16_t BUFFER_PIN[1] = {0x00};
  6. typedef struct{
  7.     long Duration;
  8.     long Start;
  9.     int PIN;
  10.     boolean State;
  11.     String ID;
  12.     uint16_t Address;
  13.     boolean Is_On = false;
  14. }Timer_Struct;
  15.  
  16. Timer_Struct Timers[MAX_TIMERS];
  17.  
  18. /** TIMER ARRAYS **/
  19.  
  20. static const inline void Timer_Stop(int Nth){
  21.     Timers[Nth].Is_On = false;
  22. }
  23.  
  24. static const inline void Timer_Checker_Loop(){
  25.     if(Timers[Timer_Counter].Is_On == true){
  26.         if(millis() - Timers[Timer_Counter].Start >= Timers[Timer_Counter].Duration){
  27.             // Fired!
  28.         }
  29.     }
  30.     Timer_Counter++;
  31. }
  32.  
  33. static const inline void Timer_Start(int Nth,long Duration,int PIN,String ID,uint16_t Address){
  34.     Timers[Nth].Duration    = Duration;
  35.     Timers[Nth].PIN         = PIN;
  36.     Timers[Nth].ID          = ID;
  37.     Timers[Nth].Address     = Address;
  38.     Timers[Nth].Is_On       = true;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement