From 65a777596439eed236c1ec0e9d029066a6dfe1c6 Mon Sep 17 00:00:00 2001 From: Mateusz Faderewski Date: Mon, 14 Aug 2023 21:50:13 +0200 Subject: [PATCH] Moved RTC update function outside of draw procedure Previous implementation caused increased drawing time when RTC datetime needed update every second --- src/menu/menu.c | 3 +++ src/menu/menu_state.h | 3 +++ src/menu/views/browser.c | 6 ++---- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/menu/menu.c b/src/menu/menu.c index 2329d06b..6b32eaef 100644 --- a/src/menu/menu.c +++ b/src/menu/menu.c @@ -1,4 +1,5 @@ #include +#include #include @@ -162,6 +163,8 @@ void menu_run (boot_params_t *boot_params) { boot_pending = true; } } + + time(&menu->current_time); } while (audio_can_write()) { diff --git a/src/menu/menu_state.h b/src/menu/menu_state.h index 148cf002..97aa8e5a 100644 --- a/src/menu/menu_state.h +++ b/src/menu/menu_state.h @@ -8,6 +8,7 @@ #define MENU_STRUCT_H__ +#include #include "boot/boot.h" #include "flashcart/flashcart.h" #include "path.h" @@ -64,6 +65,8 @@ typedef struct { char *error_message; + time_t current_time; + struct { bool go_up; bool go_down; diff --git a/src/menu/views/browser.c b/src/menu/views/browser.c index cec47fae..15b7adfe 100644 --- a/src/menu/views/browser.c +++ b/src/menu/views/browser.c @@ -262,14 +262,12 @@ static void draw (menu_t *menu, surface_t *d) { menu->browser.entries == 0 ? "" : "R: Info" ); - time_t current_time = time(NULL); - - if (current_time >= 0) { + if (menu->current_time >= 0) { component_actions_bar_text_draw( ALIGN_CENTER, VALIGN_TOP, "\n" "%s", - ctime(¤t_time) + ctime(&menu->current_time) ); }