diff --git a/README.md b/README.md index 210fb22..cc1309c 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,35 @@ Compared to the original Egret, besides having two thumb buttons per side, the R ![Re-gret Underglow](images/IMG_0812.jpeg) +## Build guide + Check the docs for a [PCB Build Guide](docs/pcb_build_guide.md) and [Case Build Guide](docs/case_build_guide.md). + +## RGB Underglow + +I powered the RGB underglow directly from the USB 5v, so it will automagically turn itself off when in wireless bluetooth mode. There's no need for ZMK's [External Power Control](https://zmk.dev/docs/behaviors/power#external-power-control) because you physically can't run the LEDs from battery power even if you wanted to. There's a [clever trick](https://hackaday.com/2017/01/20/cheating-at-5v-ws2812-control-to-use-a-3-3v-data-line/) using a diode that allows the 5v LEDs to be controlled by the Xiao's 3.3v logic. + +## Firmware + +### ZMK + +Copy the contents of `firmware/zmk/config/boards/shields/regret/` into `[your-zmk-config]/config/boards/shields/regret/` + +Be advised that right now the underglow only works on the XIAO nRF52840 board, and does not work on the XIAO RP2040 (although it [might in the future](https://github.com/zmkfirmware/zmk/issues/1085)). The original XIAO SAMD21 should work but I haven't tested it. + +| Board | Chip | USB Wired | Bluetooth Wireless | RGB Underglow | Comments | +| --------------------- | -------- | ------------------ | ------------------ | ------------------ | ------------------------------------------------------------ | +| XIAO | SAMD21 | :white_check_mark: | :x: | :x: | Should work but untested | +| Adafruit Qt PY | SAMD21 | :white_check_mark: | :x: | :x: | Should work but untested | +| XIAO BLE | nRF52840 | :white_check_mark: | :white_check_mark: | :white_check_mark: | | +| XIAO RP2040 | RP2040 | :white_check_mark: | :x: | :x: for now | Underglow [maybe someday](https://github.com/zmkfirmware/zmk/issues/1085) | +| Adafruit Qt PY RP2040 | RP2040 | :white_check_mark: | :x: | :x: for now | Should work but untested | + +### QMK + +I have not written QMK firmware yet, but maybe I will for the RP2040. + +## Related + +* I cribbed the Xiao footprint, pogo pin idea, and battery from the [revxlp](https://gitlab.com/lpgalaxy/revxlp) +* My original 36 key [Egret](https://github.com/rschenk/egret) was the starting point diff --git a/firmware/zmk/config/boards/shields/regret/Kconfig.defconfig b/firmware/zmk/config/boards/shields/regret/Kconfig.defconfig new file mode 100644 index 0000000..527711a --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/Kconfig.defconfig @@ -0,0 +1,6 @@ +if SHIELD_REGRET + +config ZMK_KEYBOARD_NAME + default "Re-gret" + +endif diff --git a/firmware/zmk/config/boards/shields/regret/Kconfig.shield b/firmware/zmk/config/boards/shields/regret/Kconfig.shield new file mode 100644 index 0000000..68b7100 --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/Kconfig.shield @@ -0,0 +1,3 @@ +config SHIELD_REGRET + def_bool $(shields_list_contains,regret) + select SPI diff --git a/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao.conf b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao.conf new file mode 100644 index 0000000..81b8cd7 --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao.conf @@ -0,0 +1,2 @@ +CONFIG_SPI=y +CONFIG_ZMK_KSCAN_MATRIX_POLLING=y diff --git a/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.conf b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.conf new file mode 100644 index 0000000..5616bfc --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.conf @@ -0,0 +1 @@ +CONFIG_SPI=y diff --git a/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.overlay b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.overlay new file mode 100644 index 0000000..65459bb --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/boards/seeeduino_xiao_ble.overlay @@ -0,0 +1,66 @@ +/* Shift register */ + +&spi2_default { + group1 { + psels = , + ; + }; +}; + +&spi2_sleep { + group1 { + psels = , + ; + }; +}; + + +/* LED underglow */ + +#include + +&pinctrl { + spi3_default: spi3_default { + group1 { + psels = ; + }; + }; + + spi3_sleep: spi3_sleep { + group1 { + psels = ; + low-power-enable; + }; + }; +}; + +&spi3 { + compatible = "nordic,nrf-spim"; + status = "okay"; + + pinctrl-0 = <&spi3_default>; + pinctrl-1 = <&spi3_sleep>; + pinctrl-names = "default", "sleep"; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <11>; /* number of LEDs */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + color-mapping = ; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/firmware/zmk/config/boards/shields/regret/regret.conf b/firmware/zmk/config/boards/shields/regret/regret.conf new file mode 100644 index 0000000..08cdc16 --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/regret.conf @@ -0,0 +1,6 @@ +# Uncomment the following lines to enable RGB underglow +# CONFIG_ZMK_RGB_UNDERGLOW=y +CONFIG_WS2812_STRIP=y +CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=n +CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_USB=y + diff --git a/firmware/zmk/config/boards/shields/regret/regret.keymap b/firmware/zmk/config/boards/shields/regret/regret.keymap new file mode 100644 index 0000000..4ba3fe5 --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/regret.keymap @@ -0,0 +1,22 @@ +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------------------ +// | Q | W | E | R | T | Y | U | I | O | P | +// | A | S | D | F | G | H | J | K | L | ; | +// | Z | X | C | V | B | N | M | , | . | / | +// | ESC | SPACE | RETURN | BSPC | + bindings = < + &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P + &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &kp FSLH + &kp ESC &kp SPACE &kp RET &kp BSPC + >; + }; + }; +}; diff --git a/firmware/zmk/config/boards/shields/regret/regret.overlay b/firmware/zmk/config/boards/shields/regret/regret.overlay new file mode 100644 index 0000000..6729afd --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/regret.overlay @@ -0,0 +1,61 @@ +#include + +&xiao_serial { status = "disabled"; }; + +&xiao_spi { + status = "okay"; + cs-gpios = <&xiao_d 9 GPIO_ACTIVE_LOW>; + shifter: 595@0 { + compatible = "zmk,gpio-595"; + status = "okay"; + gpio-controller; + spi-max-frequency = <200000>; + reg = <0>; + #gpio-cells = <2>; + ngpios = <8>; + }; +}; + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <5>; + rows = <8>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(4,4) RC(4,3) RC(4,2) RC(4,1) RC(4,0) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(5,4) RC(5,3) RC(5,2) RC(5,1) RC(5,0) +RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) + RC(3,3) RC(3,4) RC(7,4) RC(7,3) + >; + }; + + kscan0: kscan_0 { + compatible = "zmk,kscan-gpio-matrix"; + diode-direction = "row2col"; + wakeup-source; + + col-gpios + = <&xiao_d 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&xiao_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&xiao_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&xiao_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&xiao_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + row-gpios + = <&shifter 7 GPIO_ACTIVE_HIGH> + , <&shifter 6 GPIO_ACTIVE_HIGH> + , <&shifter 5 GPIO_ACTIVE_HIGH> + , <&shifter 4 GPIO_ACTIVE_HIGH> + , <&shifter 0 GPIO_ACTIVE_HIGH> + , <&shifter 1 GPIO_ACTIVE_HIGH> + , <&shifter 2 GPIO_ACTIVE_HIGH> + , <&shifter 3 GPIO_ACTIVE_HIGH> + ; + }; +}; diff --git a/firmware/zmk/config/boards/shields/regret/regret.zmk.yml b/firmware/zmk/config/boards/shields/regret/regret.zmk.yml new file mode 100644 index 0000000..457a2d9 --- /dev/null +++ b/firmware/zmk/config/boards/shields/regret/regret.zmk.yml @@ -0,0 +1,8 @@ +file_format: "1" +id: regret +name: Re-gret +type: shield +url: https://github.com/rschenk/regret +requires: [seeed_xiao] +features: + - keys