Skip to content

Commit a213f13

Browse files
committed
made it remember the last selected profile
1 parent 659c08b commit a213f13

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ int main() {
144144
// up the boot time and will show the splash screen
145145
// until we are done initializing.
146146
menu::splash<fb_t, storage, rtc, usb_keyboard> splash = {};
147-
menu::totp<fb_t, storage, rtc, usb_keyboard> totp = {};
147+
menu::totp<fb_t, storage, rtc, rtc_periph, usb_keyboard> totp = {};
148148
menu::settings<fb_t> settings = {};
149149
menu::time<fb_t, rtc_periph, rtc> time(numeric_popup);
150150
menu::calibration<fb_t, rtc_periph> calibration(numeric_popup, string_popup);

ui/totp.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace menu::detail {
2525
}
2626

2727
namespace menu {
28-
template <typename FrameBuffer, typename Storage, typename Rtc, typename Usb>
28+
template <typename FrameBuffer, typename Storage, typename Rtc, typename RtcPeriph, typename Usb>
2929
class totp: public screen<FrameBuffer> {
3030
protected:
3131
using hash = klib::crypt::sha1;
@@ -117,7 +117,7 @@ namespace menu {
117117

118118
public:
119119
totp():
120-
current(0)
120+
current(((RtcPeriph::port->GPREG4 >> 5) & 0x1f))
121121
{}
122122

123123
virtual void activate(const screen_id id) override {
@@ -165,6 +165,9 @@ namespace menu {
165165
current--;
166166
}
167167

168+
// update the rtc register
169+
RtcPeriph::port->GPREG4 = (RtcPeriph::port->GPREG4 & ~(0x1f << 5)) | ((current & 0x1f) << 5);
170+
168171
// mark the totp as changed to force a redraw of
169172
// all the text buffers
170173
totp_changed = true;
@@ -178,6 +181,9 @@ namespace menu {
178181
current++;
179182
}
180183

184+
// update the rtc register
185+
RtcPeriph::port->GPREG4 = (RtcPeriph::port->GPREG4 & ~(0x1f << 5)) | ((current & 0x1f) << 5);
186+
181187
// mark the totp as changed to force a redraw of
182188
// all the text buffers
183189
totp_changed = true;

0 commit comments

Comments
 (0)