Advertisement
Krzyspx

brama4piec

Dec 5th, 2016
3,907
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.13 KB | None | 0 0
  1. #define piechistereza 2
  2. int temppiec = 210; //początkowa temparatura zadana
  3.  
  4. void Program_vPin18(String strvPin);
  5. void Program_vPin19(String strvPin);
  6. void wyslij_V11();
  7.  
  8. bool piecgrzanie = 0; //flaga grzania on/off
  9. bool oldpiecgrzanie = 0;
  10. void pieconoff()
  11. {
  12.   if (oldtemp < (temppiec - piechistereza))
  13.   {
  14.     piecgrzanie = 1;//włącz grzanie
  15.     if (oldpiecgrzanie != piecgrzanie)
  16.     {
  17.       oldpiecgrzanie = piecgrzanie;
  18.       sendkodpilot(piecon, impuls_piec);
  19.       // BlynkvirtualWrite_col(17, _BLUE);
  20.       Serial.println("piec on");
  21.     }
  22.   }
  23.   if (oldtemp > (temppiec + piechistereza))
  24.   {
  25.     piecgrzanie = 0;//wyłącz grzanie
  26.     if (oldpiecgrzanie != piecgrzanie)
  27.     {
  28.       oldpiecgrzanie = piecgrzanie;
  29.       sendkodpilot(piecoff, impuls_piec);
  30.       BlynkvirtualWrite_col(17, _RED);
  31.       Serial.println("piec off");
  32.     }
  33.   }
  34. }
  35. bool flagagrzanie = 0;
  36. void miganiegrzanie()
  37. {
  38.   flagagrzanie = !flagagrzanie;
  39.   if (piecgrzanie)
  40.   {
  41.     if (flagagrzanie)
  42.     {
  43.       BlynkvirtualWrite_col(17, _RED);
  44.     } else
  45.     {
  46.       BlynkvirtualWrite_col(17, _BLUE);
  47.     }
  48.   }
  49. }
  50.  
  51. void Program_vPin19(String strvPin) //zwiekszanie setup temperatury co 0,5 oC
  52. {
  53.   int  klaw = intfromstr(strvPin);
  54.   if (klaw)  //sprawdzanie zmiany stanu przycisku  vPIN V10 załączenie pompy
  55.   {
  56.     temppiec = temppiec + 5;
  57.     if (temppiec > 260)
  58.     {
  59.       temppiec = 260;
  60.     }
  61.     wyslij_V11();
  62.   }
  63. }
  64.  
  65. void Program_vPin18(String strvPin) //zmniejszanie setup temperatury co 0,5 oC
  66. {
  67.   int  klaw = intfromstr(strvPin);
  68.   if (klaw) //sprawdzanie zmiany stanu przycisku  vPIN V10 załączenie pompy
  69.   {
  70.     temppiec = temppiec - 5;
  71.     if (temppiec < 130)
  72.     {
  73.       temppiec = 130;
  74.     }
  75.     wyslij_V11();
  76.   }
  77. }
  78.  
  79. int oldtemppiec = 0;
  80. void wyslij_V11() { //wysylanie ttemp do APP
  81.  
  82.   int temperature = (temppiec / 10);
  83.   int dziesietne = (temppiec % 10);
  84.   String str = String(temperature) + "." + String(dziesietne) + " ℃"; // oszczedzam 3 kB pamieci
  85.   Serial.println("set piec" + str);
  86.   if (oldtemppiec != temppiec) {
  87.     oldtemppiec = temppiec;
  88.     BlynkvirtualWrite_str(17, str);
  89.   }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement