Browse Source

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

Initial display support.
xmkb
Pete Johanson 4 years ago committed by GitHub
parent
commit
998f42a2ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      app/CMakeLists.txt
  2. 10
      app/Kconfig
  3. 36
      app/boards/shields/kyria/Kconfig.defconfig
  4. 18
      app/boards/shields/kyria/kyria.dtsi
  5. 40
      app/boards/shields/lily58/Kconfig.defconfig
  6. 21
      app/boards/shields/lily58/lily58.dtsi
  7. 10
      app/include/zmk/display.h
  8. 56
      app/src/display.c
  9. 10
      app/src/main.c
  10. 3
      app/src/sensors.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"

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

@ -18,5 +18,41 @@ if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT @@ -18,5 +18,41 @@ if SHIELD_KYRIA_LEFT || SHIELD_KYRIA_RIGHT
config ZMK_SPLIT
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

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

40
app/boards/shields/lily58/Kconfig.defconfig

@ -12,3 +12,43 @@ config ZMK_KEYBOARD_NAME @@ -12,3 +12,43 @@ config ZMK_KEYBOARD_NAME
default "Lily58 Right"
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

21
app/boards/shields/lily58/lily58.dtsi

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

@ -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 */
}

3
app/src/sensors.c

@ -60,7 +60,8 @@ static void zmk_sensors_init_item(const char *node, u8_t i, u8_t abs_i) @@ -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;
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);

Loading…
Cancel
Save