simplify reading/displaying sensor values
This commit is contained in:
parent
985bcd1c09
commit
ca31851afe
@ -79,7 +79,6 @@ namespace Devices {
|
|||||||
[](const char* msg) {
|
[](const char* msg) {
|
||||||
if (strcmp("PRESS", msg) == 0 && !Display::tDisplaySensor.isEnabled()) {
|
if (strcmp("PRESS", msg) == 0 && !Display::tDisplaySensor.isEnabled()) {
|
||||||
Bme::data.readAll();
|
Bme::data.readAll();
|
||||||
Display::tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
|
|
||||||
Display::displayTask.activate(Display::tDisplaySensor);
|
Display::displayTask.activate(Display::tDisplaySensor);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace Display {
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
[]() {
|
[]() {
|
||||||
tDisplaySensor.setIterations((DISPLAY_SENSOR_ITERATIONS - 1) * 2 + 1);
|
tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
|
||||||
displayTask.restorePerm();
|
displayTask.restorePerm();
|
||||||
});
|
});
|
||||||
Task tDisplayDate(SECONDS(5), TASK_ONCE + 1, displayDate, &ts, false, nullptr,
|
Task tDisplayDate(SECONDS(5), TASK_ONCE + 1, displayDate, &ts, false, nullptr,
|
||||||
|
|||||||
@ -30,7 +30,6 @@ Task tButton(TASK_IMMEDIATE, TASK_ONCE,
|
|||||||
[]() {
|
[]() {
|
||||||
if (Display::tDisplaySensor.isEnabled()) return;
|
if (Display::tDisplaySensor.isEnabled()) return;
|
||||||
Bme::data.readAll();
|
Bme::data.readAll();
|
||||||
Display::tDisplaySensor.setIterations(DISPLAY_SENSOR_ITERATIONS);
|
|
||||||
Display::displayTask.activate(Display::tDisplaySensor);
|
Display::displayTask.activate(Display::tDisplaySensor);
|
||||||
}, &ts);
|
}, &ts);
|
||||||
Task tLed(TASK_IMMEDIATE, TASK_ONCE,
|
Task tLed(TASK_IMMEDIATE, TASK_ONCE,
|
||||||
@ -46,6 +45,7 @@ Task tReadBme(TASK_MINUTE, TASK_FOREVER, []() {
|
|||||||
Devices::publishBme280();
|
Devices::publishBme280();
|
||||||
if (abs(lastTemp - Bme::data.temp) > 0.2) {
|
if (abs(lastTemp - Bme::data.temp) > 0.2) {
|
||||||
lastTemp = Bme::data.temp;
|
lastTemp = Bme::data.temp;
|
||||||
|
Display::tDisplaySensor.setIterations((DISPLAY_SENSOR_ITERATIONS - 1) * 2 + 1);
|
||||||
Display::displayTask.activate(Display::tDisplaySensor);
|
Display::displayTask.activate(Display::tDisplaySensor);
|
||||||
}
|
}
|
||||||
}, &ts);
|
}, &ts);
|
||||||
@ -89,7 +89,8 @@ void setup() {
|
|||||||
attachInterrupt(digitalPinToInterrupt(BUTTON), onButtonPressed, FALLING);
|
attachInterrupt(digitalPinToInterrupt(BUTTON), onButtonPressed, FALLING);
|
||||||
attachInterrupt(digitalPinToInterrupt(LED_BUILTIN), onLed, CHANGE);
|
attachInterrupt(digitalPinToInterrupt(LED_BUILTIN), onLed, CHANGE);
|
||||||
|
|
||||||
tReadBme.enable();
|
tReadBme.enableDelayed();
|
||||||
|
tButton.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user