configCentis
This commit is contained in:
parent
bec4cc7358
commit
7e5b24a11a
@ -10,10 +10,15 @@
|
||||
#define CONFIG_SECONDS_KEY "seconds"
|
||||
#define CONFIG_SECONDS_DEFAULT (6 * 60)
|
||||
|
||||
#define CONFIG_CENTIS_KEY "centis"
|
||||
#define CONFIG_CENTIS_DEFAULT (6 * 60)
|
||||
|
||||
class AppMatch final : public App {
|
||||
|
||||
unsigned long configMillis = 0;
|
||||
|
||||
bool configCentis = false;
|
||||
|
||||
unsigned long totalMillis = 0;
|
||||
|
||||
unsigned long totalCentis = 0;
|
||||
@ -57,6 +62,14 @@ public:
|
||||
configWrite();
|
||||
return true;
|
||||
}
|
||||
} else if (key.equals(CONFIG_CENTIS_KEY)) {
|
||||
const auto newCentis = valueStr.equals("true");
|
||||
if (configCentis != newCentis) {
|
||||
configCentis = newCentis;
|
||||
configSet(CONFIG_CENTIS_KEY, newCentis);
|
||||
configWrite();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -64,13 +77,14 @@ public:
|
||||
protected:
|
||||
|
||||
void _start() override {
|
||||
const auto seconds = configGet<unsigned long>(CONFIG_SECONDS_KEY, CONFIG_SECONDS_DEFAULT);
|
||||
configMillis = configGet<unsigned long>(CONFIG_SECONDS_KEY, CONFIG_SECONDS_DEFAULT) * 1000;
|
||||
configCentis = configGet<bool>(CONFIG_CENTIS_KEY, CONFIG_CENTIS_DEFAULT);
|
||||
|
||||
info("config:");
|
||||
info(" seconds = %ld", seconds);
|
||||
info(" seconds = %ld", configMillis / 1000);
|
||||
info(" centis = %s", configCentis ? "true" : "false");
|
||||
|
||||
configMillis = seconds * 1000;
|
||||
totalMillis = configMillis;
|
||||
|
||||
setState(PAUSE, true);
|
||||
}
|
||||
|
||||
@ -109,14 +123,14 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
if (state == MINUTES) {
|
||||
if (state == MINUTES || (state == SECONDS && !configCentis)) {
|
||||
if (updateSeconds != totalSeconds) {
|
||||
updateSeconds = totalSeconds;
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
|
||||
if (state == SECONDS) {
|
||||
if (state == SECONDS && configCentis) {
|
||||
markDirty();
|
||||
}
|
||||
}
|
||||
@ -137,12 +151,14 @@ protected:
|
||||
display.printf("%2d:%02d", totalMinutes, partSeconds);
|
||||
info("%2d:%02d", totalMinutes, partSeconds);
|
||||
} else if (totalMillis > 0) {
|
||||
if (configCentis) {
|
||||
display.printf("%2d.%02d", partSeconds, partCentis);
|
||||
} else {
|
||||
display.printf(" %2d", partSeconds);
|
||||
}
|
||||
} else {
|
||||
display.printf("00:00");
|
||||
}
|
||||
} else if (state == PAUSE) {
|
||||
display.printf("PAUS");
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,7 +192,7 @@ private:
|
||||
state = newState;
|
||||
switch (state) {
|
||||
case PAUSE:
|
||||
blinkEnable(500);
|
||||
blinkEnable(0);
|
||||
break;
|
||||
case MINUTES:
|
||||
updateSeconds = totalSeconds;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user