Browse Source

Initial display support.

xmkb
Pete Johanson 4 years ago
parent
commit
d80063ff51
  1. 1
      app/CMakeLists.txt
  2. 10
      app/Kconfig
  3. 44
      app/boards/shields/kyria/Kconfig.defconfig
  4. 18
      app/boards/shields/kyria/kyria.dtsi
  5. 10
      app/include/zmk/display.h
  6. 56
      app/src/display.c
  7. 10
      app/src/main.c

1
app/CMakeLists.txt

@ -33,6 +33,7 @@ target_sources(app PRIVATE src/keymap.c) @@ -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.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/events/position_state_changed.c)
target_sources(app PRIVATE src/events/keycode_state_changed.c)

10
app/Kconfig

@ -67,6 +67,14 @@ endif @@ -67,6 +67,14 @@ endif
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"
@ -139,7 +147,7 @@ config ZMK_ACTION_MOD_TAP @@ -139,7 +147,7 @@ config ZMK_ACTION_MOD_TAP
endmenu
config HEAP_MEM_POOL_SIZE
default 1024
default 8192
config KERNEL_BIN_NAME
default "zmk"

44
app/boards/shields/kyria/Kconfig.defconfig

@ -19,4 +19,48 @@ if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT @@ -19,4 +19,48 @@ if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT
config ZMK_SPLIT
default y
config EC11
default y
if EC11
choice EC11_TRIGGER
default EC11_TRIGGER_GLOBAL_THREAD
endchoice
endif
if ZMK_DISPLAY
config I2C
default y
config SSD1306
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

18
app/boards/shields/kyria/kyria.dtsi

@ -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) @@ -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>;
};
// TODO: Encoder node(s)
// TODO: OLED node
// 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>;
};
};

10
app/include/zmk/display.h

@ -0,0 +1,10 @@ @@ -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

@ -0,0 +1,56 @@ @@ -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));
}

10
app/src/main.c

@ -14,7 +14,7 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -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) @@ -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 */
}

Loading…
Cancel
Save