-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
splitted timezone from time to allow changing the timezone without ch…
…anging the time
- Loading branch information
1 parent
a213f13
commit 18a9306
Showing
5 changed files
with
72 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ namespace menu { | |
totp, | ||
settings, | ||
time, | ||
timezone, | ||
calibration, | ||
config, | ||
mouse, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#pragma once | ||
|
||
#include <klib/io/rtc.hpp> | ||
|
||
#include "screen.hpp" | ||
#include "numeric_popup.hpp" | ||
|
||
namespace menu { | ||
template <typename FrameBuffer, typename RtcPeriph> | ||
class timezone: public screen<FrameBuffer> { | ||
protected: | ||
using screen_base = screen<FrameBuffer>; | ||
|
||
// popup to show items | ||
numeric_popup<FrameBuffer>& popup; | ||
|
||
void next(int32_t value) { | ||
// store the timezone in the rtc registers | ||
RtcPeriph::port->GPREG4 = ( | ||
(RtcPeriph::port->GPREG4 & (~0x1f)) | | ||
static_cast<uint8_t>(value + 12) | ||
); | ||
|
||
// go back to the menu | ||
screen_base::buffer.back(); | ||
} | ||
|
||
void cancel() { | ||
// go back to the menu | ||
screen_base::buffer.back(); | ||
} | ||
|
||
public: | ||
timezone(numeric_popup<FrameBuffer>& popup): | ||
popup(popup) | ||
{} | ||
|
||
virtual void main(const klib::time::us delta, const input::buttons& buttons) override { | ||
// show the first screen | ||
popup.configure( | ||
"GMT", (RtcPeriph::port->GPREG4 & 0x1f) - 12, | ||
-12, 14, [&](int32_t value){next(value);}, | ||
[&](){cancel();} | ||
); | ||
|
||
screen_base::buffer.change(screen_id::numeric_popup); | ||
} | ||
|
||
virtual void draw(FrameBuffer& frame_buffer, const klib::vector2u& offset) override { | ||
// clear the background black | ||
frame_buffer.clear(klib::graphics::black); | ||
|
||
// do nothing on a draw call | ||
} | ||
}; | ||
} |