simplify reading/displaying sensor values

This commit is contained in:
Nicu Hodos 2025-02-12 12:05:30 +01:00
parent 985bcd1c09
commit ca31851afe
3 changed files with 4 additions and 4 deletions

View File

@ -79,7 +79,6 @@ namespace Devices {
[](const char* msg) {
if (strcmp("PRESS", msg) == 0 && !Display::tDisplaySensor.isEnabled()) {
Bme::data.readAll();
Display::tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
Display::displayTask.activate(Display::tDisplaySensor);
};
}

View File

@ -70,7 +70,7 @@ namespace Display {
return true;
},
[]() {
tDisplaySensor.setIterations((DISPLAY_SENSOR_ITERATIONS - 1) * 2 + 1);
tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
displayTask.restorePerm();
});
Task tDisplayDate(SECONDS(5), TASK_ONCE + 1, displayDate, &ts, false, nullptr,

View File

@ -30,7 +30,6 @@ Task tButton(TASK_IMMEDIATE, TASK_ONCE,
[]() {
if (Display::tDisplaySensor.isEnabled()) return;
Bme::data.readAll();
Display::tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
Display::displayTask.activate(Display::tDisplaySensor);
}, &ts);
Task tLed(TASK_IMMEDIATE, TASK_ONCE,
@ -46,6 +45,7 @@ Task tReadBme(TASK_MINUTE, TASK_FOREVER, []() {
Devices::publishBme280();
if (abs(lastTemp - Bme::data.temp) > 0.2) {
lastTemp = Bme::data.temp;
Display::tDisplaySensor.setIterations((DISPLAY_SENSOR_ITERATIONS - 1) * 2 + 1);
Display::displayTask.activate(Display::tDisplaySensor);
}
}, &ts);
@ -89,7 +89,8 @@ void setup() {
attachInterrupt(digitalPinToInterrupt(BUTTON), onButtonPressed, FALLING);
attachInterrupt(digitalPinToInterrupt(LED_BUILTIN), onLed, CHANGE);
tReadBme.enable();
tReadBme.enableDelayed();
tButton.restart();
}
void loop() {