Advertisement
DrRandom

pointer to an array of structs

Aug 28th, 2020 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define MAX_THERMOS 20
  2. boolean Therm_has_Done = false;
  3.  
  4. typedef struct {
  5.   uint16_t Set_Temp;
  6.   uint16_t Min;
  7.   uint16_t Hour;
  8.   uint16_t Week;
  9.   uint16_t Room_Temp;
  10.   boolean Szelep_is_ON = false;
  11.   long StartedTime = 0;
  12. } THERM_Struct;
  13. THERM_Struct * Smart_THERM[MAX_THERMOS] = {0};
  14.  
  15. int Szelep_Timer_Counter = 0;
  16. static const inline void Thermos_Szelep_Timer_Checker(){
  17.     if(Therm_has_Done){
  18.         if(Smart_THERM[Szelep_Timer_Counter] != 0){
  19.             if(Smart_THERM[Szelep_Timer_Counter]->Szelep_is_ON){
  20.                 if(millis() - Smart_THERM[Szelep_Timer_Counter]->StartedTime >= 20000){
  21.                     Smart_THERM[Szelep_Timer_Counter]->Timer_Is_On = true;
  22.                     Serial.println("Valahogy bejöttünk ide úgy hogy elméletileg a tömb minden eleme 0");
  23.                 }
  24.             }
  25.         }
  26.         Szelep_Timer_Counter++;if(Szelep_Timer_Counter > MAX_THERMOS){Szelep_Timer_Counter = 0;}
  27.     }
  28. }
  29.  
  30.  
  31. static const inline void Init_Structs(){
  32.   for(int i = 0; i < MAX_THERMOS; i++){
  33.     Smart_THERM[i] = new THERM_Struct;
  34.     Smart_THERM[i] = 0;
  35.   }
  36. }
  37. void setup(){
  38.   Serial.begin(115200);
  39.   Init_Structs();
  40. }
  41.  
  42. void loop(){
  43.  Thermos_Szelep_Timer_Checker();
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement