Merge pull request #63 from petejohanson/display/initial-lvgl-display-support

Initial display support.
This commit is contained in:
Pete Johanson 2020-07-25 23:16:04 -04:00 committed by GitHub
commit 998f42a2ed
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 198 additions and 7 deletions

View file

@ -33,6 +33,7 @@ target_sources(app PRIVATE src/keymap.c)
target_sources(app PRIVATE src/hid_listener.c) target_sources(app PRIVATE src/hid_listener.c)
target_sources(app PRIVATE src/hid.c) target_sources(app PRIVATE src/hid.c)
target_sources(app PRIVATE src/sensors.c) target_sources(app PRIVATE src/sensors.c)
target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c)
target_sources(app PRIVATE src/event_manager.c) target_sources(app PRIVATE src/event_manager.c)
target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/position_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c)

View file

@ -67,6 +67,14 @@ endif
endmenu endmenu
config ZMK_DISPLAY
bool "ZMK display support"
default n
select DISPLAY
select LVGL
select LVGL_THEMES
select LVGL_THEME_MONO
select LVGL_OBJ_LABEL
menu "Split Support" menu "Split Support"
@ -139,7 +147,7 @@ config ZMK_ACTION_MOD_TAP
endmenu endmenu
config HEAP_MEM_POOL_SIZE config HEAP_MEM_POOL_SIZE
default 1024 default 8192
config KERNEL_BIN_NAME config KERNEL_BIN_NAME
default "zmk" default "zmk"

View file

@ -19,4 +19,40 @@ if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT
config ZMK_SPLIT config ZMK_SPLIT
default y default y
if ZMK_DISPLAY
config I2C
default y
config SSD1306
default y
config SSD1306_REVERSE_MODE
default y
endif # ZMK_DISPLAY
if LVGL
config LVGL_HOR_RES
default 128
config LVGL_VER_RES
default 64
config LVGL_VDB_SIZE
default 64
config LVGL_DPI
default 148
config LVGL_BITS_PER_PIXEL
default 1
choice LVGL_COLOR_DEPTH
default LVGL_COLOR_DEPTH_1
endchoice
endif # LVGL
endif endif

View file

@ -81,8 +81,22 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9)
sensors = <&left_encoder &right_encoder>; sensors = <&left_encoder &right_encoder>;
}; };
// TODO: Encoder node(s)
// TODO: OLED node
// TODO: RGB node(s) // TODO: RGB node(s)
}; };
&pro_micro_i2c {
status = "okay";
ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
label = "DISPLAY";
width = <128>;
height = <64>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <63>;
prechargep = <0x22>;
};
};

View file

@ -12,3 +12,43 @@ config ZMK_KEYBOARD_NAME
default "Lily58 Right" default "Lily58 Right"
endif endif
if SHIELD_LILY58_LEFT || SHIELD_LILY58_RIGHT
if ZMK_DISPLAY
config I2C
default y
config SSD1306
default y
config SSD1306_REVERSE_MODE
default y
endif # ZMK_DISPLAY
if LVGL
config LVGL_HOR_RES
default 128
config LVGL_VER_RES
default 32
config LVGL_VDB_SIZE
default 64
config LVGL_DPI
default 148
config LVGL_BITS_PER_PIXEL
default 1
choice LVGL_COLOR_DEPTH
default LVGL_COLOR_DEPTH_1
endchoice
endif # LVGL
endif

View file

@ -44,7 +44,24 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(4,5) RC(4,6) RC(3,6) RC(3,7)
; ;
}; };
// TODO: OLED node
}; };
&pro_micro_i2c {
status = "okay";
ssd1306@3c {
compatible = "solomon,ssd1306fb";
reg = <0x3c>;
label = "DISPLAY";
width = <128>;
height = <32>;
segment-offset = <0>;
page-offset = <0>;
display-offset = <0>;
multiplex-ratio = <31>;
segment-remap;
com-invdir;
com-sequential;
prechargep = <0x22>;
};
};

10
app/include/zmk/display.h Normal file
View file

@ -0,0 +1,10 @@
/*
* Copyright (c) 2020 Peter Johanson <peter@peterjohanson.com>
*
* SPDX-License-Identifier: MIT
*/
#pragma once
int zmk_display_init();
void zmk_display_task_handler();

56
app/src/display.c Normal file
View file

@ -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));
}

View file

@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/matrix.h> #include <zmk/matrix.h>
#include <zmk/kscan.h> #include <zmk/kscan.h>
#include <zmk/endpoints.h> #include <zmk/display.h>
#define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID)
@ -26,4 +26,12 @@ void main(void)
{ {
return; return;
} }
#ifdef CONFIG_ZMK_DISPLAY
zmk_display_init();
while (1) {
zmk_display_task_handler();
}
#endif /* CONFIG_ZMK_DISPLAY */
} }

View file

@ -60,7 +60,8 @@ static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i)
sensors[i].sensor_number = abs_i; sensors[i].sensor_number = abs_i;
if (!sensors[i].dev) { if (!sensors[i].dev) {
LOG_ERR("Failed to find device for %s", node); LOG_WRN("Failed to find device for %s", node);
return;
} }
sensor_trigger_set(sensors[i].dev, &sensors[i].trigger, zmk_sensors_trigger_handler); sensor_trigger_set(sensors[i].dev, &sensors[i].trigger, zmk_sensors_trigger_handler);