diff --git a/main.cpp b/main.cpp index 20f6487..6a90ecb 100644 --- a/main.cpp +++ b/main.cpp @@ -144,7 +144,7 @@ int main() { // up the boot time and will show the splash screen // until we are done initializing. menu::splash splash = {}; - menu::totp totp = {}; + menu::totp totp = {}; menu::settings settings = {}; menu::time time(numeric_popup); menu::calibration calibration(numeric_popup, string_popup); diff --git a/ui/totp.hpp b/ui/totp.hpp index 8aeb8a4..86155cb 100644 --- a/ui/totp.hpp +++ b/ui/totp.hpp @@ -25,7 +25,7 @@ namespace menu::detail { } namespace menu { - template + template class totp: public screen { protected: using hash = klib::crypt::sha1; @@ -117,7 +117,7 @@ namespace menu { public: totp(): - current(0) + current(((RtcPeriph::port->GPREG4 >> 5) & 0x1f)) {} virtual void activate(const screen_id id) override { @@ -165,6 +165,9 @@ namespace menu { current--; } + // update the rtc register + RtcPeriph::port->GPREG4 = (RtcPeriph::port->GPREG4 & ~(0x1f << 5)) | ((current & 0x1f) << 5); + // mark the totp as changed to force a redraw of // all the text buffers totp_changed = true; @@ -178,6 +181,9 @@ namespace menu { current++; } + // update the rtc register + RtcPeriph::port->GPREG4 = (RtcPeriph::port->GPREG4 & ~(0x1f << 5)) | ((current & 0x1f) << 5); + // mark the totp as changed to force a redraw of // all the text buffers totp_changed = true;