diff options
author | Pete Johanson <peter@peterjohanson.com> | 2020-07-24 16:39:11 -0400 |
---|---|---|
committer | Pete Johanson <peter@peterjohanson.com> | 2020-07-25 23:10:40 -0400 |
commit | d80063ff513969f622a6cffd1a9d074ccc3cfa24 (patch) | |
tree | 1525e3d17f99c0827b93063fc6db1900378d0a09 /app/src | |
parent | 91d8237cab170e16d5a9349c06d15ac6e78e14cd (diff) |
Initial display support.
Diffstat (limited to 'app/src')
-rw-r--r-- | app/src/display.c | 56 | ||||
-rw-r--r-- | app/src/main.c | 10 |
2 files changed, 65 insertions, 1 deletions
diff --git a/app/src/display.c b/app/src/display.c new file mode 100644 index 0000000..9021914 --- /dev/null +++ b/app/src/display.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 Peter Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include <init.h> +#include <device.h> +#include <devicetree.h> + +#include <logging/log.h> +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include <drivers/display.h> +#include <lvgl.h> + +#define ZMK_DISPLAY_NAME CONFIG_LVGL_DISPLAY_DEV_NAME + +static struct device *display; + +static lv_obj_t *screen; + +int zmk_display_init() +{ + lv_obj_t *hello_world_label; + lv_obj_t *count_label; + + LOG_DBG(""); + + display = device_get_binding(ZMK_DISPLAY_NAME); + if (display == NULL) { + LOG_ERR("Failed to find display device"); + return -EINVAL; + } + + screen = lv_obj_create(NULL, NULL); + lv_scr_load(screen); + + hello_world_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(hello_world_label, "ZMK v0.1.0"); + lv_obj_align(hello_world_label, NULL, LV_ALIGN_CENTER, 0, 0); + count_label = lv_label_create(lv_scr_act(), NULL); + lv_label_set_text(count_label, CONFIG_ZMK_KEYBOARD_NAME); + lv_obj_align(count_label, NULL, LV_ALIGN_IN_BOTTOM_MID, 0, 0); + lv_task_handler(); + display_blanking_off(display); + + return 0; +} + +void zmk_display_task_handler() +{ + lv_tick_inc(10); + lv_task_handler(); + k_sleep(K_MSEC(10)); +} diff --git a/app/src/main.c b/app/src/main.c index 5f28158..5a678ee 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); #include <zmk/matrix.h> #include <zmk/kscan.h> -#include <zmk/endpoints.h> +#include <zmk/display.h> #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) @@ -26,4 +26,12 @@ void main(void) { return; } + +#ifdef CONFIG_ZMK_DISPLAY + zmk_display_init(); + + while (1) { + zmk_display_task_handler(); + } +#endif /* CONFIG_ZMK_DISPLAY */ } |