feat(display): Add config for modifier chars

This commit is contained in:
Cem Aksoylar 2023-05-12 14:28:01 -07:00
parent 467ff20ea3
commit 20131e4779
3 changed files with 29 additions and 14 deletions

View file

@ -41,4 +41,12 @@ config ZMK_WIDGET_MODS_STATUS
depends on !ZMK_SPLIT || ZMK_SPLIT_ROLE_CENTRAL depends on !ZMK_SPLIT || ZMK_SPLIT_ROLE_CENTRAL
select LV_USE_LABEL select LV_USE_LABEL
if ZMK_WIDGET_MODS_STATUS
config ZMK_WIDGET_MODS_STATUS_CHARACTERS
string "Characters to show for each modifier, corresponding to Control/Shift/Alt/GUI respectively"
default "CSAG"
endif
endmenu endmenu

View file

@ -14,6 +14,12 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/endpoints.h> #include <zmk/endpoints.h>
#include <zmk/hid.h> #include <zmk/hid.h>
#define MOD_CHARS CONFIG_ZMK_WIDGET_MODS_STATUS_CHARACTERS
#define MOD_CHARS_LEN (sizeof(MOD_CHARS) - 1)
BUILD_ASSERT(MOD_CHARS_LEN == 4,
"ERROR: CONFIG_ZMK_WIDGET_MODS_STATUS_CHARACTERS should have exactly 4 characters");
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
struct mods_status_state { struct mods_status_state {
@ -29,13 +35,13 @@ void set_mods_symbol(lv_obj_t *label, struct mods_status_state state) {
LOG_DBG("mods changed to %i", state.mods); LOG_DBG("mods changed to %i", state.mods);
if (state.mods & (MOD_LCTL | MOD_RCTL)) if (state.mods & (MOD_LCTL | MOD_RCTL))
strcat(text, "C"); strncat(text, &MOD_CHARS[0], 1);
if (state.mods & (MOD_LSFT | MOD_RSFT)) if (state.mods & (MOD_LSFT | MOD_RSFT))
strcat(text, "S"); strncat(text, &MOD_CHARS[1], 1);
if (state.mods & (MOD_LALT | MOD_RALT)) if (state.mods & (MOD_LALT | MOD_RALT))
strcat(text, "A"); strncat(text, &MOD_CHARS[2], 1);
if (state.mods & (MOD_LGUI | MOD_RGUI)) if (state.mods & (MOD_LGUI | MOD_RGUI))
strcat(text, "G"); strncat(text, &MOD_CHARS[3], 1);
lv_label_set_text(label, text); lv_label_set_text(label, text);
lv_obj_align(label, LV_ALIGN_BOTTOM_RIGHT, -1, 0); lv_obj_align(label, LV_ALIGN_BOTTOM_RIGHT, -1, 0);

View file

@ -14,16 +14,17 @@ Definition files:
- [zmk/app/src/display/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/display/Kconfig) - [zmk/app/src/display/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/display/Kconfig)
- [zmk/app/src/display/widgets/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/display/widgets/Kconfig) - [zmk/app/src/display/widgets/Kconfig](https://github.com/zmkfirmware/zmk/blob/main/app/src/display/widgets/Kconfig)
| Config | Type | Description | Default | | Config | Type | Description | Default |
| -------------------------------------------------- | ---- | -------------------------------------------------------------- | ------- | | -------------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- | ------- |
| `CONFIG_ZMK_DISPLAY` | bool | Enable support for displays | n | | `CONFIG_ZMK_DISPLAY` | bool | Enable support for displays | n |
| `CONFIG_ZMK_DISPLAY_INVERT` | bool | Invert display colors from black-on-white to white-on-black | n | | `CONFIG_ZMK_DISPLAY_INVERT` | bool | Invert display colors from black-on-white to white-on-black | n |
| `CONFIG_ZMK_WIDGET_LAYER_STATUS` | bool | Enable a widget to show the highest, active layer | y | | `CONFIG_ZMK_WIDGET_LAYER_STATUS` | bool | Enable a widget to show the highest, active layer | y |
| `CONFIG_ZMK_WIDGET_BATTERY_STATUS` | bool | Enable a widget to show battery charge information | y | | `CONFIG_ZMK_WIDGET_BATTERY_STATUS` | bool | Enable a widget to show battery charge information | y |
| `CONFIG_ZMK_WIDGET_BATTERY_STATUS_SHOW_PERCENTAGE` | bool | If battery widget is enabled, show percentage instead of icons | n | | `CONFIG_ZMK_WIDGET_BATTERY_STATUS_SHOW_PERCENTAGE` | bool | If battery widget is enabled, show percentage instead of icons | n |
| `CONFIG_ZMK_WIDGET_OUTPUT_STATUS` | bool | Enable a widget to show the current output (USB/BLE) | y | | `CONFIG_ZMK_WIDGET_OUTPUT_STATUS` | bool | Enable a widget to show the current output (USB/BLE) | y |
| `CONFIG_ZMK_WIDGET_WPM_STATUS` | bool | Enable a widget to show words per minute | n | | `CONFIG_ZMK_WIDGET_WPM_STATUS` | bool | Enable a widget to show words per minute | n |
| `CONFIG_ZMK_WIDGET_MODS_STATUS` | bool | Enable a widget to show active modifiers | n | | `CONFIG_ZMK_WIDGET_MODS_STATUS` | bool | Enable a widget to show active modifiers | n |
| `CONFIG_ZMK_WIDGET_MODS_STATUS_CHARACTERS` | string | Characters to show for each modifier, corresponding to Control/Shift/Alt/GUI respectively | "CSAG" |
Note that WPM and modifiers widgets are both shown on the bottom right of the display and hence can conflict with each other. Note that WPM and modifiers widgets are both shown on the bottom right of the display and hence can conflict with each other.