feat(shields): Add ZMK Uno shield.

* Support underglow, backlight, display, encoder, etc.
This commit is contained in:
Peter Johanson 2022-06-13 03:28:56 +00:00 committed by Pete Johanson
parent 12329b388e
commit 63b29ccd32
6 changed files with 304 additions and 0 deletions

View file

@ -0,0 +1,23 @@
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_ZMK_UNO
config ZMK_KEYBOARD_NAME
default "ZMK Uno"
config ZMK_BACKLIGHT
select LED
select LED_GPIO
config SHIELD_SSD1306_128X64
select ZMK_DISPLAY
config SHIELD_SSD1306_128X32
select ZMK_DISPLAY
config ZMK_RGB_UNDERGLOW
select WS2812_STRIP
select SPI
endif

View file

@ -0,0 +1,5 @@
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
config SHIELD_ZMK_UNO
def_bool $(shields_list_contains,zmk_uno)

View file

@ -0,0 +1,18 @@
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
CONFIG_LOG=y
CONFIG_ZMK_LOG_LEVEL_DBG=y
# Uncomment for Single color backlight
# CONFIG_ZMK_BACKLIGHT=y
# Uncomment for RGB
# CONFIG_ZMK_RGB_UNDERGLOW=y
# Uncomment for Display
# CONFIG_ZMK_DISPLAY=y
# Uncomment these two lines to enable encoder support
# CONFIG_EC11=y
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y

View file

@ -0,0 +1,62 @@
/*
* Copyright (c) 2022 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/backlight.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/ext_power.h>
#include <dt-bindings/zmk/outputs.h>
#include <dt-bindings/zmk/rgb.h>
// Uncomment the following block if using the "Direct Wire" jumper to switch the matrix to a direct wire.
/* :REMOVE ME
&kscan_direct_comp { status = "okay"; };
&kscan_direct { status = "okay"; };
&kscan_matrix_comp { status = "disabled"; };
&kscan_matrix { status = "disabled"; };
/ {
chosen {
zmk,matrix-transform = &direct_matrix_transform;
zmk,kscan = &kscan_direct_comp;
};
};
REMOVE ME: */
/ {
macros {
ZMK_MACRO(ble_zero,
wait-ms = <1>;
tap-ms = <1>;
bindings = <&out OUT_BLE &bt BT_SEL 0>;
)
ZMK_MACRO(ble_one,
wait-ms = <1>;
tap-ms = <1>;
bindings = <&out OUT_BLE &bt BT_SEL 1>;
)
};
keymap {
compatible = "zmk,keymap";
default_layer {
bindings = <
&kp A &bl BL_TOG
&rgb_ug RGB_EFF &bt BT_CLR
&out OUT_USB &ble_zero &ble_one
>;
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>;
};
};
};

View file

@ -0,0 +1,186 @@
/*
* Copyright (c) 2022 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/led/led.h>
#include <dt-bindings/zmk/matrix_transform.h>
&arduino_i2c {
status = "okay";
};
&arduino_spi {
status = "okay";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "RGB";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <7>; /* 4 underglow + 3 per-key LEDs */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>;
};
};
/ {
chosen {
zmk,kscan = &kscan_matrix_comp;
zmk,backlight = &backlight;
zmk,underglow = &led_strip;
zmk,matrix-transform = &matrix_transform;
};
// Commented out until we add more powerful power domain support
// external_power {
// compatible = "zmk,ext-power-generic";
// label = "EXT_POWER";
// init-delay-ms = <200>;
// control-gpios = <&arduino_header 1 GPIO_ACTIVE_LOW>;
// };
rgb_power {
compatible = "zmk,ext-power-generic";
label = "EXT_POWER";
// label = "RGB_POWER";
init-delay-ms = <200>;
control-gpios = <&arduino_header 1 GPIO_ACTIVE_LOW>;
};
backlight: gpioleds {
compatible = "gpio-leds";
label = "Backlight LEDs";
gpio_led_0 {
gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>;
label = "Backlight LED 0";
};
};
matrix_transform: matrix_transform {
compatible = "zmk,matrix-transform";
rows = <3>;
columns = <4>;
map = <
RC(0,0) RC(0,1)
RC(1,0) RC(1,1)
RC(2,0) RC(2,1) RC(2,2)
>;
};
direct_matrix_transform: direct_matrix_transform {
compatible = "zmk,matrix-transform";
rows = <3>;
columns = <4>;
map = <
RC(0,0) RC(0,1)
RC(0,2) RC(0,3)
RC(1,0) RC(1,1) RC(1,2)
>;
};
kscan_matrix_comp: kscan_matrix_comp {
compatible = "zmk,kscan-composite";
rows = <1>;
columns = <7>;
label = "KSCAN_MATRIX_COMP";
matrix {
kscan = <&kscan_matrix>;
};
toggle {
kscan = <&kscan_sp3t_toggle>;
row-offset = <2>;
};
};
kscan_direct_comp: kscan_direct_comp {
compatible = "zmk,kscan-composite";
label = "KSCAN_DIRECT_COMP";
status = "disabled";
matrix {
kscan = <&kscan_direct>;
};
toggle {
kscan = <&kscan_sp3t_toggle>;
row-offset = <1>;
};
};
kscan_matrix: kscan_matrix {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN_MATRIX";
diode-direction = "col2row";
col-gpios
= <&arduino_header 10 GPIO_ACTIVE_HIGH>
, <&arduino_header 9 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&arduino_header 13 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&arduino_header 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
kscan_direct: kscan_direct {
compatible = "zmk,kscan-gpio-direct";
status = "disabled";
label = "KSCAN_DIRECT";
input-gpios
= <&arduino_header 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&arduino_header 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&arduino_header 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&arduino_header 11 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
;
};
kscan_sp3t_toggle: kscan_sp3t_toggle {
compatible = "zmk,kscan-gpio-direct";
toggle-mode;
label = "KSCAN_TOGGLE";
input-gpios
= <&arduino_header 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&arduino_header 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
, <&arduino_header 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>
;
};
encoder: encoder {
label = "ENCODER";
resolution = <4>;
compatible = "alps,ec11";
a-gpios = <&arduino_header 14 GPIO_PULL_UP>;
b-gpios = <&arduino_header 15 GPIO_PULL_UP>;
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&encoder>;
};
};

View file

@ -0,0 +1,10 @@
file_format: "1"
id: zmk_uno
name: ZMK Uno
type: shield
url: https://github.com/zmkfirmware/zmk-uno
requires: [arduino_uno]
features:
- keys
- encoder
- display