Moved RTC update function outside of draw procedure

Previous implementation caused increased drawing time when RTC datetime needed update every second
This commit is contained in:
Mateusz Faderewski 2023-08-14 21:50:13 +02:00
parent 57dff16ec7
commit 65a7775964
3 changed files with 8 additions and 4 deletions

View File

@ -1,4 +1,5 @@
#include <stdlib.h>
#include <time.h>
#include <libdragon.h>
@ -162,6 +163,8 @@ void menu_run (boot_params_t *boot_params) {
boot_pending = true;
}
}
time(&menu->current_time);
}
while (audio_can_write()) {

View File

@ -8,6 +8,7 @@
#define MENU_STRUCT_H__
#include <time.h>
#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;

View File

@ -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(&current_time)
ctime(&menu->current_time)
);
}