@@ -12,8 +12,7 @@ namespace menu {
1212 using screen_base = screen<FrameBuffer>;
1313
1414 enum class steps : uint8_t {
15- timezone = 0 ,
16- year,
15+ year = 0 ,
1716 month,
1817 day,
1918 hour,
@@ -46,9 +45,6 @@ namespace menu {
4645 void next (int32_t value) {
4746 // store the value
4847 switch (current) {
49- case steps::timezone:
50- date.timezone = static_cast <int8_t >(value);
51- break ;
5248 case steps::year:
5349 date.year = static_cast <uint16_t >(value);
5450 break ;
@@ -67,12 +63,6 @@ namespace menu {
6763 case steps::second:
6864 date.second = static_cast <uint8_t >(value);
6965
70- // store the timezone in the rtc registers
71- RtcPeriph::port->GPREG4 = (
72- (RtcPeriph::port->GPREG4 & (~0x1f )) |
73- static_cast <uint8_t >(date.timezone + 12 )
74- );
75-
7666 // we are done. Update the RTC time
7767 Rtc::set (klib::io::rtc::datetime_to_epoch (
7868 date.year , date.month ,
@@ -96,7 +86,7 @@ namespace menu {
9686 }
9787
9888 void cancel () {
99- if (current == steps::timezone ) {
89+ if (current == steps::year ) {
10090 // go back to the menu
10191 screen_base::buffer.back ();
10292
@@ -118,13 +108,6 @@ namespace menu {
118108
119109 // get what state we are in
120110 switch (current) {
121- case steps::timezone:
122- popup.configure (
123- " GMT" , (RtcPeriph::port->GPREG4 & 0x1f ) - 12 ,
124- -12 , 14 , [&](int32_t value){next (value);},
125- [&](){cancel ();}
126- );
127- break ;
128111 case steps::year:
129112 popup.configure (
130113 " Year" , t.year ,
@@ -180,15 +163,18 @@ namespace menu {
180163
181164 public:
182165 time (numeric_popup<FrameBuffer>& popup):
183- current (steps::timezone ), date{}, popup(popup)
166+ current (steps::year ), date{}, popup(popup)
184167 {}
185168
186169 virtual void main (const klib::time::us delta, const input::buttons& buttons) override {
170+ // set the timezone we have in the register
171+ date.timezone = (RtcPeriph::port->GPREG4 & 0x1f ) - 12 ;
172+
187173 // change to the first step when we are called. We
188174 // are only called from the settings menu. The
189175 // popup callbacks will skip this by changing
190176 // directly to the new popup
191- current = steps::timezone ;
177+ current = steps::year ;
192178
193179 // show the first screen
194180 change_screen (current);
0 commit comments