Skip to content

Commit

Permalink
made it remember the last selected profile
Browse files Browse the repository at this point in the history
  • Loading branch information
itzandroidtab committed May 27, 2024
1 parent 659c08b commit a213f13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ int main() {
// up the boot time and will show the splash screen
// until we are done initializing.
menu::splash<fb_t, storage, rtc, usb_keyboard> splash = {};
menu::totp<fb_t, storage, rtc, usb_keyboard> totp = {};
menu::totp<fb_t, storage, rtc, rtc_periph, usb_keyboard> totp = {};
menu::settings<fb_t> settings = {};
menu::time<fb_t, rtc_periph, rtc> time(numeric_popup);
menu::calibration<fb_t, rtc_periph> calibration(numeric_popup, string_popup);
Expand Down
10 changes: 8 additions & 2 deletions ui/totp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace menu::detail {
}

namespace menu {
template <typename FrameBuffer, typename Storage, typename Rtc, typename Usb>
template <typename FrameBuffer, typename Storage, typename Rtc, typename RtcPeriph, typename Usb>
class totp: public screen<FrameBuffer> {
protected:
using hash = klib::crypt::sha1;
Expand Down Expand Up @@ -117,7 +117,7 @@ namespace menu {

public:
totp():
current(0)
current(((RtcPeriph::port->GPREG4 >> 5) & 0x1f))
{}

virtual void activate(const screen_id id) override {
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a213f13

Please sign in to comment.