Skip to content

Commit

Permalink
fix(display): Avoid fault w/ LVGL API usage.
Browse files Browse the repository at this point in the history
* Increment the tick from within the ISR itself.
* Don't call task handler until in the display callback.

PR: zmkfirmware#736
  • Loading branch information
petejohanson committed Jul 17, 2021
1 parent bdf94b1 commit ec708b1
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions app/src/display/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,16 @@ 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();
}
void display_tick_cb(struct k_work *work) { lv_task_handler(); }

#define TICK_MS 10

K_WORK_DEFINE(display_tick_work, display_tick_cb);

void display_timer_cb() { k_work_submit(&display_tick_work); }
void display_timer_cb() {
lv_tick_inc(TICK_MS);
k_work_submit(&display_tick_work);
}

K_TIMER_DEFINE(display_timer, display_timer_cb, NULL);

Expand All @@ -44,7 +46,7 @@ static void start_display_updates() {

display_blanking_off(display);

k_timer_start(&display_timer, K_MSEC(10), K_MSEC(10));
k_timer_start(&display_timer, K_MSEC(TICK_MS), K_MSEC(TICK_MS));
}

static void stop_display_updates() {
Expand Down Expand Up @@ -75,8 +77,6 @@ int zmk_display_init() {

lv_scr_load(screen);

lv_task_handler();

start_display_updates();

LOG_DBG("");
Expand Down

0 comments on commit ec708b1

Please sign in to comment.