From e2c2594a41d882196ec3b1c616e452d8d56c046a Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Sun, 22 Jan 2023 18:19:42 -0500 Subject: [PATCH] Display battery level in Clock --- src/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 9b74bb7..9dff769 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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"