From 62f31a3282f740b5bd7a28f9c94c76dd05e3babc Mon Sep 17 00:00:00 2001 From: Hendrik Sauer Date: Mon, 14 Jun 2021 15:44:07 +0200 Subject: [PATCH] Add thread to handle lvgl events --- src/display.c | 9 +++++++++ src/display.h | 2 ++ src/main.c | 7 ++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/display.c b/src/display.c index d982e90..170483d 100644 --- a/src/display.c +++ b/src/display.c @@ -27,6 +27,15 @@ lv_style_t yellow_button_style; lv_style_t red_button_style; #endif +void display_thread(void* arg1, void* arg2, void* arg3) { + #ifdef DISPLAY + while (1) { + lv_task_handler(); + k_msleep(10); + } + #endif +} + int get_battery_percentage() { return 74; } diff --git a/src/display.h b/src/display.h index c09a2ee..9d3f643 100644 --- a/src/display.h +++ b/src/display.h @@ -5,6 +5,8 @@ int init_display(); int update_display(); +void display_thread(void*, void*, void*); + int display_set_message(char* msg); int display_set_time(int time); diff --git a/src/main.c b/src/main.c index 7f0a1ee..78c6bb3 100644 --- a/src/main.c +++ b/src/main.c @@ -19,6 +19,8 @@ #include "io.h" #include "display.h" +K_THREAD_STACK_DEFINE(display_stack_area, 500); + void main(void) { int err = 0; printk("Starting Covid Contact Tracer\n"); @@ -73,7 +75,10 @@ void main(void) { if (err) { printk("init display failed (err %d)\n", err); } - + + struct k_thread display_thread_data; + k_tid_t display_tid = k_thread_create(&display_thread_data, display_stack_area, K_THREAD_STACK_SIZEOF(display_stack_area), display_thread, NULL, NULL, NULL, 0, 0, K_NO_WAIT); + do{ do_covid(); do_gatt();