display sensor values only once when button is clicked (physical or mqtt)

This commit is contained in:
Nicu Hodos 2024-05-28 17:26:18 +02:00
parent 2a0dfd9fc3
commit dfcbe7e081
2 changed files with 4 additions and 1 deletions

View File

@ -14,6 +14,7 @@
#define BRIGHTNESS_NIGHT BRIGHTNESS_MIN
#define BRIGHTNESS_DAY 11
#define SECONDS(value) value*1000
#define DISPLAY_SENSOR_ITERATIONS 2
namespace Display {
@ -28,10 +29,11 @@ namespace Display {
}, []() {
drawColon(false);
});
Task tDisplaySensor(5*TASK_SECOND, 4, displayTemp, &ts, false, []() {
Task tDisplaySensor(5*TASK_SECOND, DISPLAY_SENSOR_ITERATIONS, displayTemp, &ts, false, []() {
tDisplayTime.disable();
return true;
}, []() {
tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
tDisplayTime.enableDelayed(tDisplaySensor.getInterval());
});

View File

@ -37,6 +37,7 @@ Task tReadBme(TASK_MINUTE, TASK_FOREVER, []() {
Mqtt::publishBme280();
if (abs(lastTemp - Bme::data.temp) > 0.2) {
lastTemp = Bme::data.temp;
Display::tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS*2);
Display::tDisplaySensor.restart();
}
}, &ts);