generated from ergonautkb/one-zmk-config
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f92195c
commit b2bf4fe
Showing
35 changed files
with
2,040 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,16 @@ | ||
include: | ||
# Ergonaut One - https://ergonautkb.com/docs/keyboards/ergonaut-one/intro/ | ||
- board: seeeduino_xiao_ble | ||
shield: ergonaut_one_dongle dongle_oled | ||
artifact_name: ergonaut_dongle | ||
- board: seeeduino_xiao_ble | ||
shield: ergonaut_one_left | ||
artifact-name: ergonaut_left | ||
- board: seeeduino_xiao_ble | ||
shield: ergonaut_one_right | ||
artifact-name: ergonaut_right | ||
|
||
# Settings reset | ||
- board: seeeduino_xiao_ble | ||
shield: settings_reset | ||
artifact-name: xiao_reset |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
if(CONFIG_ZMK_DISPLAY AND CONFIG_ZMK_DISPLAY_STATUS_SCREEN_CUSTOM AND ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)) | ||
zephyr_library() | ||
zephyr_library_sources(${ZEPHYR_BASE}/misc/empty_file.c) | ||
zephyr_library_include_directories(${ZEPHYR_LVGL_MODULE_DIR}) | ||
zephyr_library_include_directories(${ZEPHYR_BASE}/lib/gui/lvgl/) | ||
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers) | ||
zephyr_library_include_directories(${CMAKE_SOURCE_DIR}/include) | ||
zephyr_library_sources(custom_status_screen.c) | ||
zephyr_library_sources(widgets/battery_status.c) | ||
zephyr_library_sources(widgets/bongo_cat.c) | ||
zephyr_library_sources(widgets/bongo_cat_images.c) | ||
zephyr_library_sources(widgets/kb_logo.c) | ||
zephyr_library_sources(widgets/layer_status.c) | ||
zephyr_library_sources(widgets/modifiers.c) | ||
zephyr_library_sources(widgets/modifiers_sym.c) | ||
zephyr_library_sources(widgets/output_status.c) | ||
zephyr_library_sources(widgets/output_status_sym.c) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright (c) 2024 The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
if SHIELD_DONGLE_DISPLAY | ||
|
||
choice ZMK_DISPLAY_STATUS_SCREEN | ||
default ZMK_DISPLAY_STATUS_SCREEN_CUSTOM | ||
endchoice | ||
|
||
config ZMK_DISPLAY_STATUS_SCREEN_CUSTOM | ||
select LV_USE_LABEL | ||
select LV_USE_IMG | ||
select LV_USE_CANVAS | ||
select LV_USE_ANIMIMG | ||
select LV_USE_ANIMATION | ||
select LV_USE_LINE | ||
select LV_FONT_UNSCII_8 | ||
select ZMK_WPM | ||
|
||
choice ZMK_DISPLAY_WORK_QUEUE | ||
default ZMK_DISPLAY_WORK_QUEUE_DEDICATED | ||
endchoice | ||
|
||
config LV_Z_MEM_POOL_SIZE | ||
default 8192 | ||
|
||
config LV_Z_VDB_SIZE | ||
default 64 | ||
|
||
config LV_DPI_DEF | ||
default 148 | ||
|
||
config LV_Z_BITS_PER_PIXEL | ||
default 1 | ||
|
||
choice LV_COLOR_DEPTH | ||
default LV_COLOR_DEPTH_1 | ||
endchoice | ||
|
||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# Copyright (c) 2024 The ZMK Contributors | ||
# SPDX-License-Identifier: MIT | ||
|
||
config SHIELD_DONGLE_DISPLAY | ||
def_bool $(shields_list_contains,dongle_display) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include "custom_status_screen.h" | ||
#include "widgets/battery_status.h" | ||
#include "widgets/modifiers.h" | ||
#include "widgets/bongo_cat.h" | ||
#include "widgets/layer_status.h" | ||
#include "widgets/output_status.h" | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
static struct zmk_widget_output_status output_status_widget; | ||
static struct zmk_widget_layer_status layer_status_widget; | ||
static struct zmk_widget_peripheral_battery_status peripheral_battery_status_widget; | ||
static struct zmk_widget_modifiers modifiers_widget; | ||
static struct zmk_widget_bongo_cat bongo_cat_widget; | ||
|
||
lv_style_t global_style; | ||
|
||
lv_obj_t *zmk_display_status_screen() { | ||
lv_obj_t *screen; | ||
|
||
screen = lv_obj_create(NULL); | ||
|
||
lv_style_init(&global_style); | ||
lv_style_set_text_font(&global_style, &lv_font_unscii_8); | ||
lv_style_set_text_letter_space(&global_style, 1); | ||
lv_style_set_text_line_space(&global_style, 1); | ||
lv_obj_add_style(screen, &global_style, LV_PART_MAIN); | ||
|
||
zmk_widget_output_status_init(&output_status_widget, screen); | ||
lv_obj_align(zmk_widget_output_status_obj(&output_status_widget), LV_ALIGN_TOP_LEFT, 0, 0); | ||
|
||
zmk_widget_bongo_cat_init(&bongo_cat_widget, screen); | ||
lv_obj_align(zmk_widget_bongo_cat_obj(&bongo_cat_widget), LV_ALIGN_BOTTOM_RIGHT, 0, 0); | ||
|
||
zmk_widget_modifiers_init(&modifiers_widget, screen); | ||
lv_obj_align(zmk_widget_modifiers_obj(&modifiers_widget), LV_ALIGN_BOTTOM_LEFT, 0, 0); | ||
|
||
zmk_widget_layer_status_init(&layer_status_widget, screen); | ||
// lv_obj_align(zmk_widget_layer_status_obj(&layer_status_widget), LV_ALIGN_BOTTOM_LEFT, 2, -18); | ||
lv_obj_align_to(zmk_widget_layer_status_obj(&layer_status_widget), zmk_widget_output_status_obj(&output_status_widget), LV_ALIGN_BOTTOM_LEFT, 0, 20); | ||
|
||
zmk_widget_peripheral_battery_status_init(&peripheral_battery_status_widget, screen); | ||
lv_obj_align(zmk_widget_peripheral_battery_status_obj(&peripheral_battery_status_widget), LV_ALIGN_TOP_RIGHT, 0, 0); | ||
|
||
return screen; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* SPDX-License-Identifier: MIT | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <lvgl.h> | ||
|
||
lv_obj_t *zmk_display_status_screen(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
CONFIG_ZMK_DISPLAY=y | ||
CONFIG_ZMK_IDLE_TIMEOUT=60000 | ||
CONFIG_BT_BAS=n | ||
CONFIG_ZMK_SPLIT_BLE_CENTRAL_BATTERY_LEVEL_FETCHING=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
// vim: expandtab softtabstop=4 shiftwidth=4 filetype=devicetree |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
file_format: "1" | ||
id: dongle_display | ||
name: dongle_display | ||
type: shield | ||
url: https://github.com/ctranstrum/zmk-config | ||
requires: | ||
- i2c_oled |
140 changes: 140 additions & 0 deletions
140
config/boards/shields/dongle_oled/widgets/battery_status.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/bluetooth/services/bas.h> | ||
|
||
#include <zephyr/logging/log.h> | ||
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); | ||
|
||
#include <zmk/display.h> | ||
#include <zmk/display/widgets/battery_status.h> | ||
#include <zmk/usb.h> | ||
#include <zmk/ble.h> | ||
#include <zmk/events/usb_conn_state_changed.h> | ||
#include <zmk/event_manager.h> | ||
#include <zmk/events/battery_state_changed.h> | ||
|
||
|
||
#include "battery_status.h" | ||
|
||
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets); | ||
|
||
struct battery_status_state { | ||
uint8_t level[ZMK_SPLIT_BLE_PERIPHERAL_COUNT]; | ||
} battery_state; | ||
|
||
struct battery_widget_object { | ||
lv_obj_t *battery_image_canvas; | ||
uint8_t battery_image_buffer[14 * 8]; | ||
lv_obj_t *battery_label; | ||
}; | ||
|
||
struct battery_widget_object battery_widget_objects[ZMK_SPLIT_BLE_PERIPHERAL_COUNT]; | ||
|
||
static void draw_battery(lv_obj_t *canvas, uint8_t level) { | ||
lv_canvas_fill_bg(canvas, lv_color_black(), LV_OPA_COVER); | ||
|
||
lv_draw_rect_dsc_t rect_fill_dsc; | ||
lv_draw_rect_dsc_init(&rect_fill_dsc); | ||
rect_fill_dsc.bg_color = lv_color_white(); | ||
|
||
// Shape of the positive terminal | ||
lv_canvas_draw_rect(canvas, 13, 0, 1, 2, &rect_fill_dsc); | ||
lv_canvas_draw_rect(canvas, 13, 6, 1, 2, &rect_fill_dsc); | ||
lv_canvas_draw_rect(canvas, 12, 3, 1, 2, &rect_fill_dsc); | ||
|
||
// Outline of the inner fuel | ||
lv_canvas_draw_rect(canvas, 1, 1, 11, 1, &rect_fill_dsc); | ||
lv_canvas_draw_rect(canvas, 1, 2, 1, 4, &rect_fill_dsc); | ||
lv_canvas_draw_rect(canvas, 1, 6, 11, 1, &rect_fill_dsc); | ||
lv_canvas_draw_rect(canvas, 11, 2, 1, 4, &rect_fill_dsc); | ||
|
||
|
||
if (level > 85) { | ||
// full | ||
} else if (level > 75) { | ||
lv_canvas_draw_rect(canvas, 10, 2, 1, 4, &rect_fill_dsc); | ||
} else if (level > 65) { | ||
lv_canvas_draw_rect(canvas, 9, 2, 2, 4, &rect_fill_dsc); | ||
} else if (level > 55) { | ||
lv_canvas_draw_rect(canvas, 8, 2, 3, 4, &rect_fill_dsc); | ||
} else if (level > 45) { | ||
lv_canvas_draw_rect(canvas, 7, 2, 4, 4, &rect_fill_dsc); | ||
} else if (level > 35) { | ||
lv_canvas_draw_rect(canvas, 6, 2, 5, 4, &rect_fill_dsc); | ||
} else if (level > 25) { | ||
lv_canvas_draw_rect(canvas, 5, 2, 6, 4, &rect_fill_dsc); | ||
} else if (level > 15) { | ||
lv_canvas_draw_rect(canvas, 4, 2, 7, 4, &rect_fill_dsc); | ||
} else if (level > 5) { | ||
lv_canvas_draw_rect(canvas, 3, 2, 8, 4, &rect_fill_dsc); | ||
} else if (level > 0) { | ||
lv_canvas_draw_rect(canvas, 2, 2, 9, 4, &rect_fill_dsc); | ||
} else { | ||
lv_canvas_fill_bg(canvas, lv_color_white(), LV_OPA_COVER); | ||
} | ||
} | ||
|
||
static void set_battery_symbol(lv_obj_t *widged, struct battery_status_state state) { | ||
|
||
for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { | ||
uint8_t level = state.level[i]; | ||
lv_obj_t *label = battery_widget_objects[i].battery_label; | ||
lv_obj_t *symbol = battery_widget_objects[i].battery_image_canvas; | ||
|
||
char text[5] = {}; | ||
|
||
if (level > 0 && level < 10) { | ||
snprintf(text, sizeof(text), "%3u%%", level); | ||
} | ||
|
||
lv_label_set_text(label, text); | ||
|
||
draw_battery(symbol, level); | ||
} | ||
} | ||
|
||
void battery_status_update_cb(struct battery_status_state state) { | ||
struct zmk_widget_battery_status *widget; | ||
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_battery_symbol(widget->obj, state); } | ||
} | ||
|
||
static struct battery_status_state battery_status_get_state(const zmk_event_t *eh) { | ||
const struct zmk_peripheral_battery_state_changed *ev = as_zmk_peripheral_battery_state_changed(eh); | ||
battery_state.level[ev->source] = ev->state_of_charge; | ||
return battery_state; | ||
} | ||
|
||
ZMK_DISPLAY_WIDGET_LISTENER(widget_battery_status, struct battery_status_state, | ||
battery_status_update_cb, battery_status_get_state) | ||
|
||
ZMK_SUBSCRIPTION(widget_battery_status, zmk_peripheral_battery_state_changed); | ||
|
||
int zmk_widget_peripheral_battery_status_init(struct zmk_widget_peripheral_battery_status *widget, lv_obj_t *parent) { | ||
widget->obj = lv_obj_create(parent); | ||
|
||
lv_obj_set_size(widget->obj, 55, LV_SIZE_CONTENT); | ||
|
||
for (int i = 0; i < ZMK_SPLIT_BLE_PERIPHERAL_COUNT; i++) { | ||
battery_widget_objects[i].battery_image_canvas = lv_canvas_create(widget->obj); | ||
battery_widget_objects[i].battery_label = lv_label_create(widget->obj); | ||
|
||
lv_canvas_set_buffer(battery_widget_objects[i].battery_image_canvas, battery_widget_objects[i].battery_image_buffer, 14, 8, LV_IMG_CF_TRUE_COLOR); | ||
|
||
lv_obj_align(battery_widget_objects[i].battery_image_canvas, LV_ALIGN_TOP_RIGHT, 0, i * 10 + 1); | ||
lv_obj_align(battery_widget_objects[i].battery_label, LV_ALIGN_TOP_RIGHT, -17, i * 10 + 1); | ||
} | ||
|
||
sys_slist_append(&widgets, &widget->node); | ||
|
||
widget_battery_status_init(); | ||
return 0; | ||
} | ||
|
||
lv_obj_t *zmk_widget_peripheral_battery_status_obj(struct zmk_widget_peripheral_battery_status *widget) { | ||
return widget->obj; | ||
} |
18 changes: 18 additions & 0 deletions
18
config/boards/shields/dongle_oled/widgets/battery_status.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright (c) 2024 The ZMK Contributors | ||
* | ||
* SPDX-License-Identifier: MIT | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <lvgl.h> | ||
#include <zephyr/kernel.h> | ||
|
||
struct zmk_widget_peripheral_battery_status { | ||
sys_snode_t node; | ||
lv_obj_t *obj; | ||
}; | ||
|
||
int zmk_widget_peripheral_battery_status_init(struct zmk_widget_peripheral_battery_status *widget, lv_obj_t *parent); | ||
lv_obj_t *zmk_widget_peripheral_battery_status_obj(struct zmk_widget_peripheral_battery_status *widget); |
Oops, something went wrong.