Display battery level in Clock

This commit is contained in:
Correl Roush 2023-01-22 18:19:42 -05:00
parent 6b9ca8c389
commit e2c2594a41

View file

@ -64,9 +64,14 @@ public:
static constexpr const char* const wd[7] = {"Sun","Mon","Tue","Wed","Thr","Fri","Sat"};
static auto last_t = time(nullptr) - 10;
auto t = time(nullptr);
int battery = M5.Power.getBatteryLevel();
if (t >= (last_t + 10)) {
last_t = t;
auto tm = localtime(&t);
M5.Display.setCursor(0,0);
M5.Display.setFont(&fonts::Font2);
M5.Display.printf("%3d%% ", battery);
M5.Display.setCursor(0, M5.Display.height() / 3);
M5.Display.setFont(&fonts::Orbitron_Light_24);
M5.Display.printf("%s\n%04d.%02d.%02d\n"