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