Display_thermostat.ino 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. #ifdef FIRMWARE_VARIANT_THERMOSTAT
  2. void display_update()
  3. {
  4. if (display_showFullscreenMsg)
  5. {
  6. if(display_nextMsgToShow > 0) {
  7. display_showNextMessageAfterTimeout();
  8. }
  9. else {
  10. display_showFullscreenMsg = false;
  11. display_overrideInterval = 0;
  12. display_updateImmediately = true;
  13. }
  14. }
  15. else
  16. {
  17. bool _showTemp = false;
  18. char _ch_temp[6];
  19. unsigned long _now = millis();
  20. if (confTherm.togglingTempHumAIDisplay)
  21. {
  22. char _ch_hum[4];
  23. char _tempLabel[2];
  24. if (((_now - outTempHumLastUpdate) < sensors_maxMeasurementAge_outside) && outTempHumLastUpdate != 0 && display_whichTempToDisplay == 1 &&
  25. ((_now - display_lastDisplayToggle) > (confDisplay.displayInterval * 1000)))
  26. {
  27. // outside temp has been updated < 5 min ago, last displayed temp was INSIDE and display interval is overdue
  28. display_whichTempToDisplay = 2; // 1= I, 2= O
  29. display_lastDisplayToggle = _now;
  30. }
  31. else if (display_whichTempToDisplay != 1 && ((_now - display_lastDisplayToggle) > (confDisplay.displayInterval * 1000)))
  32. {
  33. display_whichTempToDisplay = 1; // 1= I, 2= O
  34. display_lastDisplayToggle = _now;
  35. }
  36. display_lastDisplayUpdate = _now;
  37. if (display_whichTempToDisplay == 2)
  38. { // 2 = outside temp/hum received via MQTT
  39. if (outTempHumLastUpdate != 0 && (_now - outTempHumLastUpdate) < sensors_maxMeasurementAge_outside)
  40. {
  41. _showTemp = true;
  42. dtostrf(outTemp, 5, 1, _ch_temp);
  43. sprintf(_ch_hum, "%2i", outHum);
  44. strcpy(_tempLabel, confTherm.oTempLabel);
  45. }
  46. }
  47. else
  48. {
  49. if (sensor_DHT_lastUpdate != 0 && (_now - sensor_DHT_lastUpdate) < sensors_maxMeasurementAge)
  50. {
  51. _showTemp = true;
  52. dtostrf(sensor_DHT_currTemp, 5, 1, _ch_temp);
  53. sprintf(_ch_hum, "%2i", sensor_DHT_currHum);
  54. strcpy(_tempLabel, confTherm.iTempLabel);
  55. }
  56. }
  57. // 12345667890123456
  58. // =20.0° 35% >22.5°
  59. // A -10.2° 95% N
  60. // A 22.2° 95% N
  61. // A 5.2° 95% N
  62. // LCD line 1
  63. // print temperature incl = and ° symbol + humidity to lcd, line 1, first 11 chars
  64. lcd.setCursor(0, 0);
  65. if (_showTemp)
  66. {
  67. // lcd.write(0x3D); // = Zeichen
  68. lcd.print(_tempLabel);
  69. lcd.print(_ch_temp);
  70. // lcd.write(0xDF); // degree symbol
  71. lcd.write((uint8_t)3); // °C symbol
  72. lcd.print(" ");
  73. if (sensor_DHT_currHum == 0)
  74. lcd.print("--");
  75. else if (sensor_DHT_currHum < 10)
  76. {
  77. lcd.print(" ");
  78. lcd.print(_ch_hum);
  79. }
  80. else
  81. {
  82. lcd.print(_ch_hum);
  83. }
  84. lcd.print("%");
  85. lcd.print(" ");
  86. }
  87. else
  88. {
  89. lcd.print(" ");
  90. }
  91. }
  92. else
  93. { // non toggling temperature I + A display without humidity in line 1
  94. lcd.setCursor(0, 0);
  95. lcd.print(confTherm.iTempLabel);
  96. if (sensor_DHT_lastUpdate != 0 && (_now - sensor_DHT_lastUpdate) < sensors_maxMeasurementAge)
  97. {
  98. dtostrf(sensor_DHT_currTemp, 5, 1, _ch_temp);
  99. lcd.print(_ch_temp);
  100. }
  101. else
  102. {
  103. lcd.print(" --.-");
  104. }
  105. lcd.write((uint8_t)3); // °C symbol
  106. lcd.print(" ");
  107. if (outTempHumLastUpdate != 0 && (_now - outTempHumLastUpdate) < sensors_maxMeasurementAge_outside)
  108. {
  109. lcd.print(" ");
  110. lcd.print(confTherm.oTempLabel);
  111. dtostrf(outTemp, 5, 1, _ch_temp);
  112. lcd.print(_ch_temp);
  113. lcd.write((uint8_t)3); // °C symbol
  114. }
  115. else
  116. {
  117. lcd.print(" ");
  118. }
  119. }
  120. thermostat_updateCurrSetTemp();
  121. char _ch_currSetTemp[6];
  122. dtostrf(thermostat_currSetTemp, 5, 1, _ch_currSetTemp);
  123. // LCD line 2
  124. // display target temperature to line 2, 8 chars length incl space at the end
  125. lcd.setCursor(0, 1);
  126. if (system_doRestart) { lcd.print("Restarting... "); }
  127. else if (system_pendingRestart)
  128. {
  129. lcd.print("Restart? ");
  130. }
  131. else if (thermostat_heatingMode == 0)
  132. { // when the heating mode is OFF, do not display target temp - instead show "Heating off" info in line 2
  133. // 1234567890123456
  134. lcd.print(" ");
  135. lcd.setCursor(0, 1);
  136. lcd.print(confTherm.offMessage);
  137. // for(int i=strlen(offMessage); i < 14; i++) {
  138. // lcd.print(" ");
  139. //}
  140. display_addConnectionIcon();
  141. }
  142. //else if (heatingPause > 0)
  143. //{ // when heating pause mode is active, do not display target temp - instead show "PAUSE" info in line 2
  144. // // 1234567890123456
  145. // lcd.print(" ");
  146. // lcd.setCursor(0, 1);
  147. // //lcd.print(confThermAdv.pauseMessage);
  148. // lcd.print("PAUSE 0:");
  149. //
  150. // unsigned int _pauseMin = heatingPause / 60;
  151. // if(_pauseMin < 10) lcd.print("0");
  152. // lcd.print(_pauseMin);
  153. //
  154. // display_addConnectionIcon();
  155. //}
  156. // Status Message in Display Row 2
  157. else if (display_showRow2OverlayMsg)
  158. {
  159. display_showRow2OverlayMsg = false;
  160. //displayInterval = confDisplay.displayInterval;
  161. display_updateImmediately = true;
  162. if (thermostat_pendingPresetToggle)
  163. {
  164. thermostat_preset = thermostat_pendingPreset;
  165. thermostat_updateCurrentPresetName();
  166. thermostat_pendingPresetToggle = false;
  167. }
  168. }
  169. else
  170. {
  171. lcd.write((uint8_t)2); // arrow right symbol
  172. //lcd.print(">");
  173. // lcd.print(" ");
  174. lcd.print(_ch_currSetTemp);
  175. // lcd.write(0xDF); // degree symbol
  176. lcd.write((uint8_t)3); // °C symbol
  177. lcd.print(" ");
  178. lcd.setCursor(8, 1);
  179. lcd.print(" ");
  180. // display status info to line 2 from char 9 -> 8 chars length
  181. lcd.setCursor(9, 1);
  182. if (thermostat_preset == 0)
  183. { // day/normal mode
  184. lcd.write((uint8_t)1); // sun symbol if mode is day/normal
  185. }
  186. else if (thermostat_preset == 1)
  187. { // night/reduction mode
  188. lcd.write((uint8_t)0); // moon symbol if mode is night/reduction
  189. }
  190. else if (thermostat_preset == 2)
  191. { // night/reduction mode
  192. lcd.write((uint8_t)6); // reduction 2 (2 arrows down) symbol if mode is reduction 2
  193. }
  194. if (thermostat_heatingPause > 0)
  195. {
  196. lcd.createChar(7, display_customCharPause);
  197. lcd.setCursor(12, 1);
  198. lcd.write((uint8_t)7); // pause symbol if heating is paused
  199. }
  200. else if (thermostat_heatingLockTime > 0)
  201. {
  202. lcd.createChar(7, display_customCharLock);
  203. lcd.setCursor(12, 1);
  204. lcd.write((uint8_t)7); // lock symbol if heating should run BUT lockout time is active
  205. }
  206. else if (thermostat_turnHeatingOn)
  207. {
  208. lcd.createChar(7, display_customCharFlame);
  209. lcd.setCursor(12, 1);
  210. lcd.write((uint8_t)7); // flame symbol if heating is active
  211. }
  212. else
  213. {
  214. lcd.setCursor(12, 1);
  215. lcd.print(" ");
  216. }
  217. display_addConnectionIcon();
  218. }
  219. }
  220. }
  221. #endif // FIRMWARE_VARIANT_THERMOSTAT