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