123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- void scheduler_checkMillis()
- {
- if ((millis() - lastMillis_100ms) >= 100)
- {
- lastMillis_100ms = millis();
- scheduler_every100ms();
- }
- if ((millis() - lastMillis_1s) >= 1000)
- {
- lastMillis_1s = millis();
- scheduler_everySecond();
- }
- if ((millis() - lastMillis_1m) >= 60000)
- {
- lastMillis_1m = millis();
- scheduler_everyMinute();
- }
- }
- void scheduler_every100ms()
- {
- //checkSaveConfigTriggered();
- }
- void scheduler_everySecond()
- {
- conf_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);
- // }
- #ifdef ENABLE_LCD_I2C
- display_handleTimeout();
- #endif
- #ifdef FIRMWARE_VARIANT_THERMOSTAT
- thermostat_checkValuesChanged();
- #endif
- if (sysInfoEverySecond) log_sysdata();
- #ifdef ENABLE_FEATURE_WSCONSOLE
- clearValidSessionId();
- #endif
- if ( countMeasureInterval < confSens.measureInterval || (confSens.measureInterval == 0 && countMeasureInterval < 15) ) {
- // default of 15s if confSens.measureInterval was set to 0
- countMeasureInterval++;
- }
- else
- {
- countMeasureInterval = 0;
- #ifdef ENABLE_SENSORS_ONEWIRE
- oneWireSensors_getData();
- #endif
-
- #ifdef ENABLE_SENSOR_DHT22
- if (confSens.DHT_enable) DHT_measureTempHum();
- #endif
-
- #ifdef FIRMWARE_VARIANT_THERMOSTAT
- thermostat_mainFunction();
- #endif
- }
- #ifdef FIRMWARE_VARIANT_THERMOSTAT
- if(thermostat_heatingPause > 0) {
- thermostat_heatingPause--;
- thermostat_publish_heatingPauseTime();
- }
- if(thermostat_heatingLockTime > 0) {
- thermostat_heatingLockTime--;
- thermostat_publish_heatingLockTime();
- }
- #endif // FIRMWARE_VARIANT_THERMOSTAT
- #ifdef ENABLE_LCD_I2C
- if (display_overrideInterval > 0) {
- if (display_countInterval < display_overrideInterval)
- display_countInterval++;
- else
- {
- display_countInterval = 0;
- display_overrideInterval = 0;
- display_update();
- }
- }
- else {
- if (display_countInterval < confDisplay.displayInterval)
- display_countInterval++;
- else
- {
- display_countInterval = 0;
- display_update();
- }
- }
- #endif // ENABLE_LCD_I2C
- if (system_doRestart) {
- restart();
- }
- if(system_restartAtMillis > 0 && millis() > system_restartAtMillis) {
- restart();
- }
- if (configChangedMqttConnResetRequired && !confCheckUnsaved()) {
- configChangedMqttConnResetRequired = false;
- mqttResetConnection();
- }
- if ((millis() - system_pendingRestart_lastMillis) > 3000) {
- system_pendingRestart = false;
- }
- // if ( preset != pendingPreset) {
- // if ( (millis() - pendingPreset_millis) > pendingPreset_timeout ) {
- // preset = pendingPreset;
- // }
- // }
- #ifdef ENABLE_I2C_PORTEXPANDER
- portexpander_readInputs();
- //portexpander_toggleOutputs();
- #endif
- #ifdef FIRMWARE_VARIANT_HEATCONTROL
- heatcontrol_mainFunction();
- #endif
- } // scheduler_everySecond()
- void scheduler_everyMinute()
- {
- #ifdef ENABLE_FEATURE_NTP_TIME
- if (confTime.ntpEnable) {
- syncClock();
- }
- #endif
- log_sysdata();
- conf_confChangedLogNote(true);
-
- if (confMqtt.mqtt_enable) {
- if (!confMqtt.mqtt_willRetain) {
- mqtt_publishConnectMsg();
- }
- mqtt_publishStatus();
- if (confMqtt.mqtt_enable_heartbeat) {
- mqttPublishHeartbeat();
- }
- if (confMqtt.mqtt_outPubInterval > 0 && outPubInterval_states_count >= confMqtt.mqtt_outPubInterval) {
- outPubInterval_states_count = 0;
- #ifdef FIRMWARE_VARIANT_THERMOSTAT
- thermostat_publishCurrentValues(true); // true forces publishing
- #endif
- #ifdef FIRMWARE_VARIANT_HEATCONTROL
- heatcontrol_publish_sw_disableControl_heating();
- heatcontrol_publish_sw_disableControl_pump();
- heatcontrol_publish_in_heat_active();
- heatcontrol_publish_in_heat_request();
- heatcontrol_publish_out_heat();
- heatcontrol_publish_out_pump();
- heatcontrol_publish_lockTime();
- heatcontrol_publish_pumpBacklash();
- heatcontrol_publish_testMode();
- heatcontrol_publish_heatCurve_current();
- heatcontrol_publish_lockActive();
-
- heatcontrol_pump_forceRunAfterTimeout();
- #endif
- }
- else {
- outPubInterval_states_count++;
- #ifdef FIRMWARE_VARIANT_THERMOSTAT
- thermostat_publishCurrentValues(false); // false publishes only changed values
- #endif
- }
- 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
- }
- if (confSens.DHT_enable) DHT_logCurrentData();
- }
- } // scheduler_everyMinute()
|