Improve RTC adjustment logic

Handle events where RTC is unavailable.
This commit is contained in:
Robin Jones 2024-11-07 23:01:32 +00:00
parent 5f14f7876d
commit 866e630952

View File

@ -119,7 +119,7 @@ static void process (menu_t *menu) {
sound_play_effect(SFX_EXIT);
menu->next_mode = MENU_MODE_BROWSER;
}
else if (menu->actions.enter && !is_editing_mode) {
else if (menu->actions.enter && !is_editing_mode && menu->current_time >= 0) {
rtc_tm = *gmtime(&menu->current_time);
is_editing_mode = true;
}
@ -169,6 +169,9 @@ static void draw (menu_t *menu, surface_t *d) {
component_layout_draw();
if (!is_editing_mode) {
if( menu->current_time >= 0 ) {
component_main_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"ADJUST REAL TIME CLOCK\n"
@ -183,13 +186,33 @@ static void draw (menu_t *menu, surface_t *d) {
menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown"
);
if (!is_editing_mode) {
component_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"A: Change\n"
"B: Back"
);
}
else {
component_main_text_draw(
ALIGN_CENTER, VALIGN_TOP,
"ADJUST REAL TIME CLOCK\n"
"\n"
"\n"
"This cart does not support a real time clock."
"\n"
"Current date & time: %s\n"
"\n",
menu->current_time >= 0 ? ctime(&menu->current_time) : "Unknown"
);
component_actions_bar_text_draw(
ALIGN_LEFT, VALIGN_TOP,
"\n"
"B: Back"
);
}
}
else {
component_actions_bar_text_draw(
ALIGN_RIGHT, VALIGN_TOP,