summaryrefslogtreecommitdiff
path: root/app/src/display
diff options
context:
space:
mode:
authorPete Johanson <peter@peterjohanson.com>2020-12-29 00:19:51 -0500
committerPete Johanson <peter@peterjohanson.com>2021-01-04 13:02:38 -0500
commit992cee1bac816696839e52eb1f7c4e5f3e51c4db (patch)
tree78aec1ec369e23ab328af675da5559614fc60720 /app/src/display
parenta55b1397c9558cead989dfc5920b162f7c8b4c8b (diff)
feat(display): Show layer label in widget.
Diffstat (limited to 'app/src/display')
-rw-r--r--app/src/display/widgets/layer_status.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/app/src/display/widgets/layer_status.c b/app/src/display/widgets/layer_status.c
index fb9f689..6700bb3 100644
--- a/app/src/display/widgets/layer_status.c
+++ b/app/src/display/widgets/layer_status.c
@@ -33,12 +33,23 @@ void layer_status_init() {
void set_layer_symbol(lv_obj_t *label) {
int active_layer_index = zmk_keymap_highest_layer_active();
- char text[6] = {};
LOG_DBG("Layer changed to %i", active_layer_index);
- sprintf(text, LV_SYMBOL_KEYBOARD "%i ", active_layer_index);
- lv_label_set_text(label, text);
+ const char *layer_label = zmk_keymap_layer_label(active_layer_index);
+ if (layer_label == NULL) {
+ char text[6] = {};
+
+ sprintf(text, LV_SYMBOL_KEYBOARD "%i", active_layer_index);
+
+ lv_label_set_text(label, text);
+ } else {
+ char text[12] = {};
+
+ snprintf(text, 12, LV_SYMBOL_KEYBOARD "%s", layer_label);
+
+ lv_label_set_text(label, text);
+ }
}
int zmk_widget_layer_status_init(struct zmk_widget_layer_status *widget, lv_obj_t *parent) {