|
|
|
@ -14,6 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
@@ -14,6 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
|
|
|
|
|
#include <drivers/display.h> |
|
|
|
|
#include <lvgl.h> |
|
|
|
|
|
|
|
|
|
#include <zmk/event-manager.h> |
|
|
|
|
#include <zmk/events/activity-state-changed.h> |
|
|
|
|
#include <zmk/display/status_screen.h> |
|
|
|
|
|
|
|
|
|
#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME |
|
|
|
@ -35,6 +37,18 @@ void display_timer_cb() { k_work_submit(&display_tick_work); }
@@ -35,6 +37,18 @@ void display_timer_cb() { k_work_submit(&display_tick_work); }
|
|
|
|
|
|
|
|
|
|
K_TIMER_DEFINE(display_timer, display_timer_cb, NULL); |
|
|
|
|
|
|
|
|
|
static void start_display_updates() { |
|
|
|
|
display_blanking_off(display); |
|
|
|
|
|
|
|
|
|
k_timer_start(&display_timer, K_MSEC(10), K_MSEC(10)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static void stop_display_updates() { |
|
|
|
|
display_blanking_on(display); |
|
|
|
|
|
|
|
|
|
k_timer_stop(&display_timer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int zmk_display_init() { |
|
|
|
|
LOG_DBG(""); |
|
|
|
|
|
|
|
|
@ -54,10 +68,29 @@ int zmk_display_init() {
@@ -54,10 +68,29 @@ int zmk_display_init() {
|
|
|
|
|
lv_scr_load(screen); |
|
|
|
|
|
|
|
|
|
lv_task_handler(); |
|
|
|
|
display_blanking_off(display); |
|
|
|
|
|
|
|
|
|
k_timer_start(&display_timer, K_MSEC(10), K_MSEC(10)); |
|
|
|
|
start_display_updates(); |
|
|
|
|
|
|
|
|
|
LOG_DBG(""); |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int display_event_handler(const struct zmk_event_header *eh) { |
|
|
|
|
struct activity_state_changed *ev = cast_activity_state_changed(eh); |
|
|
|
|
switch (ev->state) { |
|
|
|
|
case ZMK_ACTIVITY_ACTIVE: |
|
|
|
|
start_display_updates(); |
|
|
|
|
break; |
|
|
|
|
case ZMK_ACTIVITY_IDLE: |
|
|
|
|
case ZMK_ACTIVITY_SLEEP: |
|
|
|
|
stop_display_updates(); |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
LOG_WRN("Unhandled activity state: %d", ev->state); |
|
|
|
|
return -EINVAL; |
|
|
|
|
} |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
ZMK_LISTENER(display, display_event_handler); |
|
|
|
|
ZMK_SUBSCRIPTION(display, activity_state_changed); |