123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- 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();
- }
-
- //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 (countDisplayInterval < confBas.displayInterval) countDisplayInterval++;
- else {
- countDisplayInterval = 0;
- updateDisplay();
- }
- if (doRestart) restart();
- 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();
- 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
- }
- }
- }
|