small improvement
This commit is contained in:
parent
e2607ffe6d
commit
b90a190504
@ -137,7 +137,7 @@ namespace Devices {
|
||||
Display::Brightness::brightnessChangedCallback = []{
|
||||
brightnessMqtt->updateState(Display::Brightness::current);
|
||||
};
|
||||
Display::Timer::timerCallback = [](int8 current){
|
||||
Display::Timer::remainingCallback = [](int8 current){
|
||||
timerRemainingMqtt->updateState(to_string(current).c_str());
|
||||
};
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace Display {
|
||||
|
||||
namespace Timer {
|
||||
int8 timer = 0, current = 0;
|
||||
void (*timerCallback)(int8);
|
||||
void (*remainingCallback)(int8);
|
||||
|
||||
Task tDisplayTimer(SECONDS(10), TASK_ONCE + 1,
|
||||
[]{
|
||||
@ -108,14 +108,17 @@ namespace Display {
|
||||
tDisplayTimer.setIterations(TASK_FOREVER);
|
||||
tDisplayTimer.restart();
|
||||
}
|
||||
if (timerCallback) timerCallback(current);
|
||||
}, &ts, false, nullptr,
|
||||
if (remainingCallback) remainingCallback(current);
|
||||
}, &ts, false,
|
||||
[]{
|
||||
current = timer+1;
|
||||
return true;
|
||||
},
|
||||
[]{
|
||||
tDisplayTimer.disable();
|
||||
});
|
||||
|
||||
void start() {
|
||||
current = timer+1;
|
||||
tTimer.restart();
|
||||
}
|
||||
|
||||
@ -223,7 +226,7 @@ namespace Display {
|
||||
|
||||
void changeHourFormat24(bool format24) {
|
||||
hourFormat24 = format24;
|
||||
drawTime();
|
||||
tDisplayTime.restart();
|
||||
if (hourFormatChangedCallback) hourFormatChangedCallback();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user