From c3cf7cee4eb8eba7f703a7d66f2289033f641f21 Mon Sep 17 00:00:00 2001 From: Colin Date: Sat, 5 Oct 2024 12:15:20 +0000 Subject: [PATCH] use OS sleep instead of polling to reduce CPU usage without this lvgl never releases the CPU, and just pegs one of the cores to 100%. see --- buffyboard/main.c | 3 ++- unl0kr/main.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/buffyboard/main.c b/buffyboard/main.c index 26054f3..ac7b66b 100644 --- a/buffyboard/main.c +++ b/buffyboard/main.c @@ -284,7 +284,8 @@ int main(int argc, char *argv[]) { /* Periodically run timer / task handler */ while(1) { - lv_timer_periodic_handler(); + uint32_t time_till_next = lv_timer_handler(); + usleep(time_till_next); } return 0; diff --git a/unl0kr/main.c b/unl0kr/main.c index e711e44..53640cd 100644 --- a/unl0kr/main.c +++ b/unl0kr/main.c @@ -591,7 +591,8 @@ int main(int argc, char *argv[]) { uint32_t timeout = conf_opts.general.timeout * 1000; /* ms */ while(1) { if (!timeout || lv_disp_get_inactive_time(NULL) < timeout) { - lv_timer_periodic_handler(); + uint32_t time_till_next = lv_timer_handler(); + usleep(time_till_next); } else if (timeout) { shutdown(); }