123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148 |
- void checkMillis()
- {
- if ((millis() - lastRun) >= 100)
- {
- lastRun = millis();
- every100ms();
- }
- }
- void every100ms()
- {
- if (count100ms < 10)
- count100ms++;
- else
- {
- count100ms = 0;
- everySecond();
- }
- //checkSaveConfigTriggered();
- }
- void everySecond()
- {
- if (countSeconds < 60)
- countSeconds++;
- else
- {
- countSeconds = 0;
- everyMinute();
- }
- confChangedLogNote(false); // only outputs once if false and only if config is not saved
- //webSocket.sendTXT(num, "Test\n");
- // if(confWeb.enableConsole && webSocket.connectedClients() > 0) {
- // char buf[40];
- // sprintf(buf, "%u\n", millis());
- // webSocket.broadcastTXT(buf);
- // }
- handleDisplayTimeout();
- checkValuesChanged();
- if (sysInfoEverySecond)
- logSysdata();
- #ifdef ENABLE_FEATURE_WEB_CONSOLE_WEBSOCKETS
- clearValidSessionId();
- #endif
- if (countMeasureInterval < confBas.measureInterval)
- countMeasureInterval++;
- else
- {
- countMeasureInterval = 0;
- measureTempHum();
- //thermostat();
- }
- if(heatingPause > 0) {
- heatingPause--;
- publish_heatingPauseTime();
- }
- if(heatingLockTime > 0) {
- heatingLockTime--;
- publish_heatingLockTime();
- }
- thermostat();
- if (countDisplayInterval < confBas.displayInterval)
- countDisplayInterval++;
- else
- {
- countDisplayInterval = 0;
- updateDisplay();
- }
- if (doRestart)
- restart();
- if (configChangedMqttConnResetRequired && !confCheckUnsaved())
- {
- configChangedMqttConnResetRequired = false;
- mqttResetConnection();
- }
- if ((millis() - pendingRestart_lastMillis) > 3000)
- pendingRestart = false;
- // if ( preset != pendingPreset) {
- // if ( (millis() - pendingPreset_millis) > pendingPreset_timeout ) {
- // preset = pendingPreset;
- // }
- // }
- }
- unsigned int outPubInterval_states_count = 0;
- unsigned int outPubInterval_sensors_count = 0;
- void everyMinute()
- {
- #ifdef ENABLE_FEATURE_NTP_TIME
- if (confTime.ntpEnable)
- {
- syncClock();
- }
- #endif
- logSysdata();
- confChangedLogNote(true);
-
- if (confMqtt.mqtt_enable)
- {
- if (!confMqtt.mqtt_willRetain)
- mqttPublishConnectMsg();
- mqttPublishStatus();
- if (confMqtt.mqtt_enable_heartbeat)
- mqttPublishHeartbeat();
- if (confMqtt.mqtt_outPubInterval > 0 && outPubInterval_states_count >= confMqtt.mqtt_outPubInterval)
- {
- outPubInterval_states_count = 0;
- publishCurrentThermostatValues(true); // true forces publishing
- }
- else
- {
- outPubInterval_states_count++;
- publishCurrentThermostatValues(false); // false publishes only changed values
- }
- if (confMqtt.mqtt_outPubInterval_sensors > 0 && outPubInterval_sensors_count >= confMqtt.mqtt_outPubInterval_sensors)
- {
- outPubInterval_sensors_count = 0;
- publishCurrentSensorValues(true); // true forces publishing
- }
- else
- {
- outPubInterval_sensors_count++;
- publishCurrentSensorValues(false); // false publishes only changed values
- }
- }
- }
|