summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-12-03 22:53:54 -0500
committerPete Johanson <peter@peterjohanson.com>2020-12-06 22:47:21 -0500
commit7ea1892bbb146eb5ce4d8602c136fadb54d454c8 (patch)
treea222a8c0aaf81ae22e2223d54f22fddf6f81761f
parent0d80220e14200b38b3e244d9f24e8bd7b61768d2 (diff)
fix(display): All display updates in work thread.
* Make sure all LVGL access is from main work thread.
-rw-r--r--app/include/zmk/display.h3
-rw-r--r--app/src/display/main.c21
-rw-r--r--app/src/display/widgets/output_status.c4
-rw-r--r--app/src/main.c4
4 files changed, 15 insertions, 17 deletions
diff --git a/app/include/zmk/display.h b/app/include/zmk/display.h
index def4392..3f4eb52 100644
--- a/app/include/zmk/display.h
+++ b/app/include/zmk/display.h
@@ -6,5 +6,4 @@
#pragma once
-int zmk_display_init();
-void zmk_display_task_handler(); \ No newline at end of file
+int zmk_display_init(); \ No newline at end of file
diff --git a/app/src/display/main.c b/app/src/display/main.c
index 001061f..d64fb2a 100644
--- a/app/src/display/main.c
+++ b/app/src/display/main.c
@@ -24,6 +24,17 @@ static lv_obj_t *screen;
__attribute__((weak)) lv_obj_t *zmk_display_status_screen() { return NULL; }
+void display_tick_cb(struct k_work *work) {
+ lv_tick_inc(10);
+ lv_task_handler();
+}
+
+K_WORK_DEFINE(display_tick_work, display_tick_cb);
+
+void display_timer_cb() { k_work_submit(&display_tick_work); }
+
+K_TIMER_DEFINE(display_timer, display_timer_cb, NULL);
+
int zmk_display_init() {
LOG_DBG("");
@@ -45,12 +56,8 @@ int zmk_display_init() {
lv_task_handler();
display_blanking_off(display);
+ k_timer_start(&display_timer, K_MSEC(10), K_MSEC(10));
+
LOG_DBG("");
return 0;
-}
-
-void zmk_display_task_handler() {
- lv_tick_inc(10);
- lv_task_handler();
- k_sleep(K_MSEC(10));
-}
+} \ No newline at end of file
diff --git a/app/src/display/widgets/output_status.c b/app/src/display/widgets/output_status.c
index b00d3fc..723d4f7 100644
--- a/app/src/display/widgets/output_status.c
+++ b/app/src/display/widgets/output_status.c
@@ -41,20 +41,16 @@ void set_status_symbol(lv_obj_t *label) {
switch (selected_endpoint) {
case ZMK_ENDPOINT_USB:
- LOG_DBG("USB, BOY!");
strcat(text, LV_SYMBOL_USB " ");
break;
case ZMK_ENDPOINT_BLE:
if (active_profie_bonded) {
if (active_profile_connected) {
- LOG_DBG("Bonded & connected!");
sprintf(text, LV_SYMBOL_WIFI "%i " LV_SYMBOL_OK, active_profile_index);
} else {
- LOG_DBG("Bonded but not connected!");
sprintf(text, LV_SYMBOL_WIFI "%i " LV_SYMBOL_CLOSE, active_profile_index);
}
} else {
- LOG_DBG("NOT Bonded!");
sprintf(text, LV_SYMBOL_WIFI "%i " LV_SYMBOL_SETTINGS, active_profile_index);
}
break;
diff --git a/app/src/main.c b/app/src/main.c
index eb0275b..ae604a7 100644
--- a/app/src/main.c
+++ b/app/src/main.c
@@ -28,9 +28,5 @@ void main(void) {
#ifdef CONFIG_ZMK_DISPLAY
zmk_display_init();
-
- while (1) {
- zmk_display_task_handler();
- }
#endif /* CONFIG_ZMK_DISPLAY */
}