47 lines
1.0 KiB
C++
47 lines
1.0 KiB
C++
#ifndef MODE_CLOCK_H
|
|
#define MODE_CLOCK_H
|
|
|
|
#include "mode/Mode.h"
|
|
|
|
class Clock : public Mode {
|
|
|
|
public:
|
|
|
|
explicit Clock(Display &display) :
|
|
Mode(display) {
|
|
// nothing
|
|
}
|
|
|
|
const char *getName() override {
|
|
return "Clock";
|
|
}
|
|
|
|
protected:
|
|
|
|
void step(microseconds_t dt) override {
|
|
if (realtimeChanged) {
|
|
markDirty();
|
|
}
|
|
}
|
|
|
|
void draw(Display &display) override {
|
|
display.clear();
|
|
|
|
uint8_t x = 2;
|
|
x += display.print(x, 1, realtimeOK ? now.tm_hour / 10 : 13, WHITE);
|
|
x++;
|
|
x += display.print(x, 1, realtimeOK ? now.tm_hour % 10 : 13, WHITE);
|
|
x += display.print(x, 1, 10, WHITE);
|
|
x += display.print(x, 1, realtimeOK ? now.tm_min / 10 : 13, WHITE);
|
|
x++;
|
|
x += display.print(x, 1, realtimeOK ? now.tm_min % 10 : 13, WHITE);
|
|
x += display.print(x, 1, 10, WHITE);
|
|
x += display.print(x, 1, realtimeOK ? now.tm_sec / 10 : 13, WHITE);
|
|
x++;
|
|
x += display.print(x, 1, realtimeOK ? now.tm_sec % 10 : 13, WHITE);
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|