From 4a1254bc27f23bc5025fb44970796eb425cd8469 Mon Sep 17 00:00:00 2001 From: Lucas Uyezu Date: Tue, 19 Oct 2021 23:39:04 -0400 Subject: [PATCH] Add support for Knob Goblin shield --- .../shields/knob_goblin/Kconfig.defconfig | 45 +++++++++++ app/boards/shields/knob_goblin/Kconfig.shield | 5 ++ .../shields/knob_goblin/knob_goblin.conf | 9 +++ .../shields/knob_goblin/knob_goblin.keymap | 40 ++++++++++ .../shields/knob_goblin/knob_goblin.overlay | 79 +++++++++++++++++++ .../shields/knob_goblin/knob_goblin.zmk.yml | 11 +++ 6 files changed, 189 insertions(+) create mode 100644 app/boards/shields/knob_goblin/Kconfig.defconfig create mode 100644 app/boards/shields/knob_goblin/Kconfig.shield create mode 100644 app/boards/shields/knob_goblin/knob_goblin.conf create mode 100644 app/boards/shields/knob_goblin/knob_goblin.keymap create mode 100644 app/boards/shields/knob_goblin/knob_goblin.overlay create mode 100644 app/boards/shields/knob_goblin/knob_goblin.zmk.yml diff --git a/app/boards/shields/knob_goblin/Kconfig.defconfig b/app/boards/shields/knob_goblin/Kconfig.defconfig new file mode 100644 index 00000000..07df5996 --- /dev/null +++ b/app/boards/shields/knob_goblin/Kconfig.defconfig @@ -0,0 +1,45 @@ +# Copyright (c) 2022 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_KNOB_GOBLIN + +config ZMK_KEYBOARD_NAME + default "Knob Goblin" + +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_MAX + default 128 + +config LVGL_VER_RES_MAX + 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 # SHIELD_KNOB_GOBLIN diff --git a/app/boards/shields/knob_goblin/Kconfig.shield b/app/boards/shields/knob_goblin/Kconfig.shield new file mode 100644 index 00000000..5a140cb9 --- /dev/null +++ b/app/boards/shields/knob_goblin/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2022 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_KNOB_GOBLIN + def_bool $(shields_list_contains,knob_goblin) diff --git a/app/boards/shields/knob_goblin/knob_goblin.conf b/app/boards/shields/knob_goblin/knob_goblin.conf new file mode 100644 index 00000000..2eefae4d --- /dev/null +++ b/app/boards/shields/knob_goblin/knob_goblin.conf @@ -0,0 +1,9 @@ +# Copyright (c) 2022 The ZMK Contributors +# SPDX-License-Identifier: MIT + +# Uncomment to enable Encoders +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y + +# Uncomment the following line to enable the Knob Goblin OLED Display +CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/knob_goblin/knob_goblin.keymap b/app/boards/shields/knob_goblin/knob_goblin.keymap new file mode 100644 index 00000000..8e4a7e66 --- /dev/null +++ b/app/boards/shields/knob_goblin/knob_goblin.keymap @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + + bindings = < + &trans &kp EQUAL &kp KP_SLASH &kp KP_MULTIPLY &kp KP_MINUS + &trans &kp KP_NUMBER_7 &kp KP_NUMBER_8 &kp KP_NUMBER_9 &kp KP_PLUS + &trans &kp KP_NUMBER_4 &kp KP_NUMBER_5 &kp KP_NUMBER_6 &kp KP_PLUS + &kp C_PLAY_PAUSE &kp KP_NUMBER_1 &kp KP_NUMBER_2 &kp KP_NUMBER_3 &kp KP_ENTER + &kp C_MUTE &mo 1 &kp KP_NUMBER_0 &kp KP_DOT &kp KP_ENTER + >; + + sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>; + }; + + num_layer { + bindings = < + &trans &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 + &trans &kp HOME &trans &kp PAGE_UP &trans + &trans &kp END &kp UP_ARROW &kp PAGE_DOWN &trans + &trans &kp LEFT_ARROW &kp DOWN_ARROW &kp RIGHT_ARROW &kp SPACE + &trans &trans &kp BACKSPACE &kp DELETE &trans + >; + + }; + }; +}; + diff --git a/app/boards/shields/knob_goblin/knob_goblin.overlay b/app/boards/shields/knob_goblin/knob_goblin.overlay new file mode 100644 index 00000000..82cc3dc3 --- /dev/null +++ b/app/boards/shields/knob_goblin/knob_goblin.overlay @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2022 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + row-gpios + = <&pro_micro 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + col-gpios + = <&pro_micro 9 GPIO_ACTIVE_HIGH> + , <&pro_micro 8 GPIO_ACTIVE_HIGH> + , <&pro_micro 7 GPIO_ACTIVE_HIGH> + , <&pro_micro 6 GPIO_ACTIVE_HIGH> + , <&pro_micro 5 GPIO_ACTIVE_HIGH> + ; + }; + + top_encoder: encoder_top { + compatible = "alps,ec11"; + label = "TOP_ENCODER"; + a-gpios = <&pro_micro 19 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + b-gpios = <&pro_micro 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + resolution = <4>; + status = "okay"; + }; + + bottom_encoder: encoder_bottom { + compatible = "alps,ec11"; + label = "BOTTOM_ENCODER"; + a-gpios = <&pro_micro 20 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + b-gpios = <&pro_micro 21 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + resolution = <4>; + status = "okay"; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&top_encoder &bottom_encoder>; + }; + +}; + +&pro_micro_i2c { + status = "okay"; + + oled: 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>; + }; +}; diff --git a/app/boards/shields/knob_goblin/knob_goblin.zmk.yml b/app/boards/shields/knob_goblin/knob_goblin.zmk.yml new file mode 100644 index 00000000..5383d1c2 --- /dev/null +++ b/app/boards/shields/knob_goblin/knob_goblin.zmk.yml @@ -0,0 +1,11 @@ +file_format: "1" +id: knob_goblin +name: Knob Goblin +type: shield +url: https://knob-goblin.com/ +requires: [pro_micro] +exposes: [i2c_oled] +features: + - keys + - display + - encoder