Skip to content

Commit 5796aa0

Browse files
committed
Zen display & battery tweaks
1 parent 9094140 commit 5796aa0

File tree

18 files changed

+314
-27
lines changed

18 files changed

+314
-27
lines changed

app/boards/arm/corneish_zen/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,10 @@ if(CONFIG_ZMK_DISPLAY)
4848
zephyr_library_sources(widgets/icons/layers2.c)
4949
endif()
5050
if(NOT CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
51-
zephyr_library_sources(widgets/icons/zenlogo.c)
51+
target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN app PRIVATE widgets/icons/zenlogo.c)
52+
target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_LPKB app PRIVATE widgets/icons/lpkblogo.c)
53+
target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZMK app PRIVATE widgets/icons/zmklogo.c)
54+
target_sources_ifdef(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU app PRIVATE widgets/icons/miryokulogo.c)
5255
endif()
5356
endif()
5457

app/boards/arm/corneish_zen/Kconfig.defconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,26 @@ menuconfig CUSTOM_WIDGET_LAYER_STATUS
7878
menuconfig CUSTOM_WIDGET_PERIPHERAL_STATUS
7979
bool "custom peripheral status widget"
8080

81+
config CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING
82+
bool "Hide heading strip for layer widget and center widgets on 1/3rds"
83+
84+
choice CUSTOM_WIDGET_LOGO_IMAGE
85+
prompt "custom logo widget image"
86+
87+
config CUSTOM_WIDGET_LOGO_IMAGE_ZEN
88+
bool "Corne-ish Zen"
89+
90+
config CUSTOM_WIDGET_LOGO_IMAGE_LPKB
91+
bool "LPKB"
92+
93+
config CUSTOM_WIDGET_LOGO_IMAGE_ZMK
94+
bool "ZMK"
95+
96+
config CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU
97+
bool "Miryoku"
98+
99+
endchoice
100+
81101
endif # BOARD_CORNEISH_ZEN_LEFT || BOARD_CORNEISH_ZEN_RIGHT
82102

83103
if BOARD_CORNEISH_ZEN_V1_LEFT || BOARD_CORNEISH_ZEN_V1_RIGHT

app/boards/arm/corneish_zen/corneish_zen_v2_left_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ CONFIG_CUSTOM_WIDGET_OUTPUT_STATUS=y
6060
CONFIG_ZMK_WIDGET_OUTPUT_STATUS=n
6161
CONFIG_CUSTOM_WIDGET_LAYER_STATUS=y
6262
CONFIG_ZMK_WIDGET_LAYER_STATUS=n
63+
CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN=y
6364

6465
# Turn on logging, and set ZMK logging to debug output
6566
#CONFIG_LOG=y

app/boards/arm/corneish_zen/corneish_zen_v2_right_defconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ CONFIG_CUSTOM_WIDGET_BATTERY_STATUS=y
5858
CONFIG_ZMK_WIDGET_BATTERY_STATUS=n
5959
CONFIG_CUSTOM_WIDGET_PERIPHERAL_STATUS=y
6060
CONFIG_ZMK_WIDGET_PERIPHERAL_STATUS=n
61+
CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN=y
6162

6263
# Turn on logging, and set ZMK logging to debug output
6364
#CONFIG_LOG=y

app/boards/arm/corneish_zen/custom_status_screen.c

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <zephyr/logging/log.h>
1515
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
1616

17-
LV_IMG_DECLARE(zenlogo);
1817
LV_IMG_DECLARE(layers2);
1918

2019
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_BATTERY_STATUS)
@@ -40,37 +39,72 @@ lv_obj_t *zmk_display_status_screen() {
4039

4140
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_BATTERY_STATUS)
4241
zmk_widget_battery_status_init(&battery_status_widget, screen);
42+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
43+
lv_obj_align(zmk_widget_battery_status_obj(&battery_status_widget), LV_ALIGN_CENTER, 0, -43);
44+
#else
4345
lv_obj_align(zmk_widget_battery_status_obj(&battery_status_widget), LV_ALIGN_TOP_MID, 0, 2);
4446
#endif
47+
#endif
4548

4649
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_OUTPUT_STATUS)
4750
zmk_widget_output_status_init(&output_status_widget, screen);
51+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
52+
lv_obj_align(zmk_widget_output_status_obj(&output_status_widget), LV_ALIGN_CENTER, 0, 0);
53+
#else
4854
lv_obj_align(zmk_widget_output_status_obj(&output_status_widget), LV_ALIGN_TOP_MID, 0, 41);
4955
#endif
56+
#endif
5057

5158
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_PERIPHERAL_STATUS)
5259
zmk_widget_peripheral_status_init(&peripheral_status_widget, screen);
60+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
61+
lv_obj_align(zmk_widget_peripheral_status_obj(&peripheral_status_widget), LV_ALIGN_CENTER, 0,
62+
0);
63+
#else
5364
lv_obj_align(zmk_widget_peripheral_status_obj(&peripheral_status_widget), LV_ALIGN_TOP_MID, 0,
5465
41);
5566
#endif
67+
#endif
5668

5769
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS)
70+
#if !IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
5871
lv_obj_t *LayersHeading;
5972
LayersHeading = lv_img_create(screen);
6073
lv_obj_align(LayersHeading, LV_ALIGN_BOTTOM_MID, 0, -30);
6174
lv_img_set_src(LayersHeading, &layers2);
75+
#endif
6276

6377
zmk_widget_layer_status_init(&layer_status_widget, screen);
6478
lv_obj_set_style_text_font(zmk_widget_layer_status_obj(&layer_status_widget),
6579
&lv_font_montserrat_16, LV_PART_MAIN);
80+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
81+
lv_obj_align(zmk_widget_layer_status_obj(&layer_status_widget), LV_ALIGN_CENTER, 0, 43);
82+
#else
6683
lv_obj_align(zmk_widget_layer_status_obj(&layer_status_widget), LV_ALIGN_BOTTOM_MID, 0, -5);
6784
#endif
85+
#endif
6886

6987
#if !IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
7088
lv_obj_t *zenlogo_icon;
7189
zenlogo_icon = lv_img_create(screen);
90+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZEN)
91+
LV_IMG_DECLARE(zenlogo);
7292
lv_img_set_src(zenlogo_icon, &zenlogo);
93+
#elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_LPKB)
94+
LV_IMG_DECLARE(lpkblogo);
95+
lv_img_set_src(zenlogo_icon, &lpkblogo);
96+
#elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_ZMK)
97+
LV_IMG_DECLARE(zmklogo);
98+
lv_img_set_src(zenlogo_icon, &zmklogo);
99+
#elif IS_ENABLED(CONFIG_CUSTOM_WIDGET_LOGO_IMAGE_MIRYOKU)
100+
LV_IMG_DECLARE(miryokulogo);
101+
lv_img_set_src(zenlogo_icon, &miryokulogo);
102+
#endif
103+
#if IS_ENABLED(CONFIG_CUSTOM_WIDGET_LAYER_STATUS_HIDE_HEADING)
104+
lv_obj_align(zenlogo_icon, LV_ALIGN_CENTER, 0, 43);
105+
#else
73106
lv_obj_align(zenlogo_icon, LV_ALIGN_BOTTOM_MID, 0, -5);
107+
#endif
74108
#endif
75109

76110
return screen;

app/boards/arm/corneish_zen/widgets/battery_status.c

Lines changed: 43 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,52 @@ LV_IMG_DECLARE(batt_0);
4141
LV_IMG_DECLARE(batt_0_chg);
4242

4343
static void set_battery_symbol(lv_obj_t *icon, struct battery_status_state state) {
44-
uint8_t level = state.level;
45-
4644
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
47-
if (level > 95) {
48-
lv_img_set_src(icon, state.usb_present ? &batt_100_chg : &batt_100);
49-
} else if (level > 74) {
50-
lv_img_set_src(icon, state.usb_present ? &batt_75_chg : &batt_75);
51-
} else if (level > 49) {
52-
lv_img_set_src(icon, state.usb_present ? &batt_50_chg : &batt_50);
53-
} else if (level > 24) {
54-
lv_img_set_src(icon, state.usb_present ? &batt_25_chg : &batt_25);
45+
static uint8_t stage_prev = 255;
46+
static bool usb_prev = false;
47+
48+
uint8_t level = state.level;
49+
bool usb_present = state.usb_present;
50+
uint8_t stage;
51+
52+
if (level > 87) {
53+
stage = 5;
54+
} else if (level > 62) {
55+
stage = 4;
56+
} else if (level > 37) {
57+
stage = 3;
58+
} else if (level > 12) {
59+
stage = 2;
5560
} else if (level > 5) {
56-
lv_img_set_src(icon, state.usb_present ? &batt_5_chg : &batt_5);
61+
stage = 1;
5762
} else {
58-
lv_img_set_src(icon, state.usb_present ? &batt_0_chg : &batt_0);
63+
stage = 0;
64+
}
65+
66+
// check if there is a change requiring an update
67+
if (usb_present != usb_prev || stage != stage_prev) {
68+
switch (stage) {
69+
case 5:
70+
lv_img_set_src(icon, usb_present ? &batt_100_chg : &batt_100);
71+
break;
72+
case 4:
73+
lv_img_set_src(icon, usb_present ? &batt_75_chg : &batt_75);
74+
break;
75+
case 3:
76+
lv_img_set_src(icon, usb_present ? &batt_50_chg : &batt_50);
77+
break;
78+
case 2:
79+
lv_img_set_src(icon, usb_present ? &batt_25_chg : &batt_25);
80+
break;
81+
case 1:
82+
lv_img_set_src(icon, usb_present ? &batt_5_chg : &batt_5);
83+
break;
84+
default:
85+
lv_img_set_src(icon, usb_present ? &batt_0_chg : &batt_0);
86+
break;
87+
}
88+
usb_prev = usb_present;
89+
stage_prev = stage;
5990
}
6091
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
6192
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Darryl deHaan
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include <lvgl.h>
9+
10+
#ifndef LV_ATTRIBUTE_MEM_ALIGN
11+
#define LV_ATTRIBUTE_MEM_ALIGN
12+
#endif
13+
14+
#ifndef LV_ATTRIBUTE_IMG_LPKBLOGO
15+
#define LV_ATTRIBUTE_IMG_LPKBLOGO
16+
#endif
17+
18+
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_LPKBLOGO uint8_t
19+
lpkblogo_map[] = {
20+
0xff, 0xff, 0xff, 0xff, /*Color of index 0*/
21+
0x00, 0x00, 0x00, 0xff, /*Color of index 1*/
22+
23+
0x7f, 0xff, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xe0, 0xe0, 0x00, 0x00, 0x00, 0xe0,
24+
0xc0, 0x00, 0x00, 0x00, 0x60, 0xc7, 0x83, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60,
25+
0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60,
26+
0xcf, 0xc3, 0xff, 0xfc, 0x60, 0xcf, 0xc0, 0x00, 0xfc, 0x60, 0xcf, 0xc0, 0x00, 0xfc, 0x60,
27+
0xcf, 0xc0, 0x00, 0xfc, 0x60, 0xcf, 0xc0, 0x00, 0xfc, 0x60, 0xcf, 0xc3, 0xff, 0xfc, 0x60,
28+
0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60,
29+
0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc3, 0xff, 0xfc, 0x60, 0xcf, 0xc0, 0x00, 0x00, 0x60,
30+
0xcf, 0xc0, 0x00, 0x00, 0x60, 0xcf, 0xc0, 0x00, 0x00, 0x60, 0xcf, 0xc0, 0x00, 0x00, 0x60,
31+
0xcf, 0xc0, 0x00, 0x00, 0x60, 0xcf, 0xc3, 0xff, 0xf8, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60,
32+
0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60, 0xcf, 0xc7, 0xff, 0xfc, 0x60,
33+
0xc7, 0x83, 0xff, 0xf8, 0x60, 0xc0, 0x00, 0x00, 0x00, 0x60, 0xe0, 0x00, 0x00, 0x00, 0xe0,
34+
0xff, 0xff, 0xff, 0xff, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xc0,
35+
};
36+
37+
const lv_img_dsc_t lpkblogo = {
38+
.header.cf = LV_IMG_CF_INDEXED_1BIT,
39+
.header.always_zero = 0,
40+
.header.reserved = 0,
41+
.header.w = 35,
42+
.header.h = 35,
43+
.data_size = 183,
44+
.data = lpkblogo_map,
45+
};
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright 2022 Manna Harbour
2+
// https://github.com/manna-harbour/miryoku
3+
4+
#include "lvgl.h"
5+
6+
#ifndef LV_ATTRIBUTE_MEM_ALIGN
7+
#define LV_ATTRIBUTE_MEM_ALIGN
8+
#endif
9+
10+
#ifndef LV_ATTRIBUTE_IMG_MIRYOKULOGO
11+
#define LV_ATTRIBUTE_IMG_MIRYOKULOGO
12+
#endif
13+
14+
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_MIRYOKULOGO uint8_t
15+
miryokulogo_map[] = {
16+
0x04, 0x02, 0x04, 0xff, /*Color of index 0*/
17+
0xfc, 0xfe, 0xfc, 0xff, /*Color of index 1*/
18+
19+
0xff, 0xff, 0xff, 0xff, 0x80, 0x00, 0x00, 0x01, 0x80, 0x00, 0x00, 0x01, 0x9f, 0xff, 0xff,
20+
0xf9, 0x9f, 0xff, 0xff, 0xf9, 0x98, 0x01, 0x99, 0x99, 0x98, 0x01, 0x99, 0x99, 0x99, 0x99,
21+
0x80, 0x19, 0x99, 0x99, 0x80, 0x19, 0x98, 0x01, 0xf9, 0xf9, 0x98, 0x01, 0xf9, 0xf9, 0x99,
22+
0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x98, 0x01, 0x80, 0x19, 0x98, 0x01, 0x80, 0x19,
23+
0x9f, 0x9f, 0xf9, 0xf9, 0x9f, 0x9f, 0xf9, 0xf9, 0x98, 0x01, 0x80, 0x19, 0x98, 0x01, 0x80,
24+
0x19, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x99, 0x81, 0x99, 0x99, 0x99, 0x81,
25+
0x99, 0x99, 0x99, 0x9f, 0x99, 0x99, 0x99, 0x9f, 0x99, 0x99, 0x99, 0x80, 0x19, 0x99, 0x99,
26+
0x80, 0x19, 0x99, 0x9f, 0xff, 0xff, 0xf9, 0x9f, 0xff, 0xff, 0xf9, 0x80, 0x00, 0x00, 0x01,
27+
0x80, 0x00, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff,
28+
};
29+
30+
const lv_img_dsc_t miryokulogo = {
31+
.header.always_zero = 0,
32+
.header.w = 32,
33+
.header.h = 32,
34+
.data_size = 136,
35+
.header.cf = LV_IMG_CF_INDEXED_1BIT,
36+
.data = miryokulogo_map,
37+
};
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#include "lvgl.h"
2+
3+
#ifndef LV_ATTRIBUTE_MEM_ALIGN
4+
#define LV_ATTRIBUTE_MEM_ALIGN
5+
#endif
6+
7+
#ifndef LV_ATTRIBUTE_IMG_ZMKLOGO
8+
#define LV_ATTRIBUTE_IMG_ZMKLOGO
9+
#endif
10+
11+
const LV_ATTRIBUTE_MEM_ALIGN LV_ATTRIBUTE_LARGE_CONST LV_ATTRIBUTE_IMG_ZMKLOGO uint8_t
12+
zmklogo_map[] = {
13+
0xff, 0xff, 0xff, 0xff, /*Color of index 0*/
14+
0x00, 0x00, 0x00, 0xfe, /*Color of index 1*/
15+
16+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
17+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
18+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
19+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
20+
0xff, 0xff, 0xff, 0xff, 0xff, 0xf0, 0x0e, 0x7e, 0x73, 0xc7, 0xe0, 0x04, 0x3c, 0x31, 0x87,
21+
0xf0, 0x0c, 0x18, 0x31, 0x0f, 0xff, 0x0c, 0x18, 0x30, 0x1f, 0xff, 0x1c, 0x00, 0x30, 0x3f,
22+
0xfe, 0x3c, 0x00, 0x30, 0x7f, 0xfe, 0x3c, 0x42, 0x30, 0xff, 0xfc, 0x7c, 0x66, 0x30, 0xff,
23+
0xf8, 0x7c, 0x7e, 0x30, 0x7f, 0xf8, 0xfc, 0x7e, 0x30, 0x3f, 0xf0, 0xfc, 0x7e, 0x30, 0x1f,
24+
0xf0, 0x0c, 0x7e, 0x31, 0x0f, 0xe0, 0x04, 0x7e, 0x31, 0x87, 0xf0, 0x0e, 0xff, 0x73, 0xc7,
25+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
26+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
27+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
28+
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
29+
0xff, 0xff, 0xff, 0xff, 0xff,
30+
};
31+
32+
const lv_img_dsc_t zmklogo = {
33+
.header.cf = LV_IMG_CF_INDEXED_1BIT,
34+
.header.always_zero = 0,
35+
.header.reserved = 0,
36+
.header.w = 40,
37+
.header.h = 40,
38+
.data_size = 208,
39+
.data = zmklogo_map,
40+
};

app/boards/arm/corneish_zen/widgets/layer_status.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ static void set_layer_symbol(lv_obj_t *label, struct layer_status_state state) {
2727
const char *layer_label = state.label;
2828
uint8_t active_layer_index = state.index;
2929

30+
#if IS_ENABLED(CONFIG_ZMK_DISPLAY_HIDE_MOMENTARY_LAYERS)
31+
static uint8_t last_perm_index = 255;
32+
if (!zmk_keymap_layer_momentary(active_layer_index) && last_perm_index != active_layer_index) {
33+
last_perm_index = active_layer_index;
34+
LOG_DBG("Last perm layer index updated to %i", active_layer_index);
35+
} else {
36+
return;
37+
}
38+
#endif
39+
3040
if (layer_label == NULL) {
3141
char text[6] = {};
3242

0 commit comments

Comments
 (0)