globalVars.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  1. #include "settings.h"
  2. // Uptime
  3. struct sysUptimeStruct
  4. {
  5. unsigned int day = 0;
  6. unsigned int hour = 0;
  7. unsigned int min = 0;
  8. unsigned int sec = 0;
  9. unsigned int highMillis = 0;
  10. unsigned int rollover = 0;
  11. char uptimeStr[16];
  12. } sysUptime;
  13. unsigned long system_restartAtMillis = 0;
  14. bool system_pendingRestart = false;
  15. bool system_doRestart = false;
  16. unsigned long system_pendingRestart_lastMillis = 0;
  17. bool mqtt_tempDisabled_credentialError = false;
  18. char mqtt_topic_in_cmd[61];
  19. char mqtt_topic_in_setTemp[61];
  20. char mqtt_topic_in_setMode[61];
  21. char mqtt_topic_in_setPreset[61];
  22. char mqtt_topic_in_setPause[61];
  23. // Sensors - global
  24. unsigned long sensors_maxMeasurementAge = MAX_MEASUREMENT_AGE;
  25. unsigned long sensors_maxMeasurementAge_outside = MAX_MEASUREMENT_AGE_OUT;
  26. // DHT Sensor
  27. float sensor_DHT_currTemp; // last reading from DHT sensor with smoothing
  28. float sensor_DHT_currTemp_raw; // last reading from DHT sensor (raw)
  29. uint16_t sensor_DHT_currHum; // last reading from DHT sensor with smoothing
  30. uint16_t sensor_DHT_currHum_raw; // last reading from DHT sensor (raw)
  31. float sensor_DHT_tmpHum, sensor_DHT_tmpTemp;
  32. int sensor_DHT_readRetries = 2;
  33. unsigned long sensor_DHT_lastUpdate = 0; // last update time of DHT reading
  34. // OneWire Sensors
  35. float owTemp_feed;
  36. float owTemp_return;
  37. float owTemp_out;
  38. // Outside Temp/Hum via MQTT
  39. float outTemp; // outside temp (via MQTT if enabled and in-topic configured)
  40. uint16_t outHum; // outside temp (via MQTT if enabled and in-topic configured)
  41. unsigned long outTempHumLastUpdate; // last reading from out temp/hum source
  42. char outTemp_newValue[6];
  43. bool outTemp_parseNewValue;
  44. char outHum_newValue[4];
  45. bool outHum_parseNewValue;
  46. unsigned long lastMeasure = 0; // millis of last temp/hum measurement
  47. //char msg[101]; // buffer MQTT in payload
  48. //char topic[70]; // buffer MQTT in topic
  49. bool PIRSensorOn = false;
  50. //bool config_was_changed = false;
  51. bool configChangedRestartRequired = false;
  52. bool configChangedMqttConnResetRequired = false;
  53. char cmdPayload[101]; // buffer for commands
  54. bool cmdInQueue = false; // command is queued and will be processed next loop() run
  55. // not used any more, now triggered directly
  56. //bool saveConfigToFlash = false; // conf is saved in next loop() run
  57. //bool saveConfig2ToFlash = false; // conf2 is saved in next loop() run
  58. // ----
  59. unsigned long lastConfigChange;
  60. bool lastConfigChangeNoteAlreadyDone = false;
  61. unsigned long lastMillis_100ms = 0;
  62. unsigned long lastMillis_1s = 0;
  63. unsigned long lastMillis_1m = 0;
  64. //uint16_t count100ms = 0;
  65. //uint16_t countSeconds = 0;
  66. uint16_t countMeasureInterval = 0;
  67. unsigned long mqttLastReconnectAttempt = 0;
  68. uint16_t mqttReconnectAttempts = 0;
  69. uint16_t mqtt_reconnects = 0;
  70. bool mqtt_connected = false;
  71. unsigned long mqtt_lastHeartbeat;
  72. bool mqttInTopicSubscribed = false;
  73. char mqtt_topic_log[50];
  74. // Display
  75. uint16_t display_countInterval = 0;
  76. uint16_t display_overlayMsgTimeout = 2;
  77. bool display_showFullscreenMsg = false;
  78. bool display_updateImmediately = false;
  79. bool display_showRow2OverlayMsg = false;
  80. //uint16_t displayInterval;
  81. uint16_t display_overrideInterval;
  82. unsigned long display_lastDisplayUpdate = 0; // millis of last display update
  83. unsigned long display_lastDisplayToggle = 0; // millis of last display toggle
  84. bool display_active = false; // gets true when button is pressed. display light
  85. // gets switched on until timeout. button actions
  86. // are only performed while display is active
  87. // MQTT publishing
  88. unsigned int outPubInterval_states_count = 0;
  89. unsigned int outPubInterval_sensors_count = 0;
  90. // if command "debugmode 1" is called...
  91. bool debug = false;
  92. bool debug2 = false;
  93. bool sysInfoEverySecond = false;
  94. // global buffer variable for use with sendLog function
  95. char logBuf[LOG_BUFFER_SIZE];
  96. bool WifiInApMode = false;
  97. unsigned long WifiApModeStartedAt;
  98. #ifdef ENABLE_FEATURE_SECRETS_ENCRYPTION
  99. char encKey[] = SECRETS_ENCRYPTION_KEY;
  100. #endif
  101. bool confEncryptionEnabled = false;
  102. #ifdef ENABLE_FEATURE_NTP_TIME
  103. struct tm lt; // http://www.cplusplus.com/reference/ctime/tm/
  104. //const char *const PROGMEM dayNames[] = {"Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"};
  105. //const char *const PROGMEM dayShortNames[] = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"};
  106. //const char *const PROGMEM monthNames[] = {"Januar", "Februar", "März", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"};
  107. //const char *const PROGMEM monthShortNames[] = {"Jan", "Feb", "Mrz", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"};
  108. #endif
  109. #ifdef ENABLE_FEATURE_WEB_CONSOLE
  110. char webLogBuffer[WEB_CONSOLE_BUFFER_SIZE];
  111. unsigned int webLogBuffer_index = 0;
  112. #endif
  113. char mqttCurrentStateName[25];
  114. char httpServer_returnPage[21];