scheduler.ino 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. void checkMillis() {
  2. if ( (millis() - lastRun) > 100 ) {
  3. lastRun = millis();
  4. every100ms();
  5. }
  6. }
  7. void every100ms() {
  8. if (count100ms < 10) count100ms++;
  9. else {
  10. count100ms = 0;
  11. everySecond();
  12. }
  13. //checkSaveConfigTriggered();
  14. }
  15. void everySecond() {
  16. if (countSeconds < 60) countSeconds++;
  17. else {
  18. countSeconds = 0;
  19. everyMinute();
  20. }
  21. handleDisplayTimeout();
  22. checkValuesChanged();
  23. if (countMeasureInterval < measureInterval) countMeasureInterval++;
  24. else {
  25. countMeasureInterval = 0;
  26. measureTempHum();
  27. thermostat();
  28. }
  29. if (countDisplayInterval < displayInterval) countDisplayInterval++;
  30. else {
  31. countDisplayInterval = 0;
  32. updateDisplay();
  33. }
  34. if (doRestart) ESP.restart();
  35. if ( (millis() - pendingRestart_lastMillis) > 3000 ) pendingRestart = false;
  36. // if ( preset != pendingPreset) {
  37. // if ( (millis() - pendingPreset_millis) > pendingPreset_timeout ) {
  38. // preset = pendingPreset;
  39. // }
  40. // }
  41. }
  42. void everyMinute() {
  43. updateUptime();
  44. buildUptimeString();
  45. if(mqtt_enable) {
  46. mqttPublishConnectMsg();
  47. mqttPublishStatus();
  48. if(mqtt_enable_heartbeat) mqttPublishHeartbeat();
  49. publishCurrentSensorValues();
  50. publishCurrentThermostatValues();
  51. }
  52. // if(WifiInApMode) {
  53. // if( (millis() - WifiApModeStartedAt) > WIFI_AP_MODE_TIMEOUT ) {
  54. //
  55. // }
  56. // }
  57. // Serial.print("WiFi Status: ");
  58. // Serial.println(WiFi.status());
  59. }