mirror of
https://github.com/revspace/operame
synced 2024-12-04 21:57:30 +00:00
Make compatible with millis() rollover
This commit is contained in:
parent
5359e62b12
commit
df27d1474a
10
operame.ino
10
operame.ino
@ -214,8 +214,8 @@ void check_sensor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
unsigned long next = millis() + 6000;
|
static unsigned long previous_mqtt = 0;
|
||||||
static unsigned long next_mqtt = 0;
|
unsigned long start = millis();
|
||||||
|
|
||||||
if (mqtt_enabled) mqtt.loop();
|
if (mqtt_enabled) mqtt.loop();
|
||||||
|
|
||||||
@ -227,18 +227,18 @@ void loop() {
|
|||||||
if (CO2) {
|
if (CO2) {
|
||||||
display_ppm(CO2);
|
display_ppm(CO2);
|
||||||
|
|
||||||
if (mqtt_enabled && millis() > next_mqtt) {
|
if (mqtt_enabled && millis() - previous_mqtt >= mqtt_interval) {
|
||||||
|
previous_mqtt = millis();
|
||||||
connect_mqtt();
|
connect_mqtt();
|
||||||
String message = mqtt_template;
|
String message = mqtt_template;
|
||||||
message.replace("{}", String(CO2));
|
message.replace("{}", String(CO2));
|
||||||
retain(mqtt_topic, message);
|
retain(mqtt_topic, message);
|
||||||
next_mqtt = millis() + mqtt_interval;
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
display_big("wacht...");
|
display_big("wacht...");
|
||||||
}
|
}
|
||||||
|
|
||||||
while (millis() < next) {
|
while (millis() - start < 6000) {
|
||||||
if (CO2) display_ppm(CO2); // repeat, for blinking
|
if (CO2) display_ppm(CO2); // repeat, for blinking
|
||||||
if (ota_enabled) ArduinoOTA.handle();
|
if (ota_enabled) ArduinoOTA.handle();
|
||||||
check_buttons();
|
check_buttons();
|
||||||
|
Loading…
Reference in New Issue
Block a user