diff --git a/boards/arm/keychron_q8/Kconfig.board b/boards/arm/keychron_q8/Kconfig.board new file mode 100644 index 0000000..216d149 --- /dev/null +++ b/boards/arm/keychron_q8/Kconfig.board @@ -0,0 +1,3 @@ +config BOARD_KEYCHRON_Q8 + bool "Keychron Q8" + depends on SOC_STM32L432XX diff --git a/boards/arm/keychron_q8/Kconfig.defconfig b/boards/arm/keychron_q8/Kconfig.defconfig new file mode 100644 index 0000000..aaf40af --- /dev/null +++ b/boards/arm/keychron_q8/Kconfig.defconfig @@ -0,0 +1,15 @@ +if BOARD_KEYCHRON_Q8 + +config BOARD + default "keychron_q8" + +config ZMK_KEYBOARD_NAME + default "Keychron Q8" + +config ZMK_KSCAN_MATRIX_POLLING + default y + +config ZMK_USB + default y + +endif diff --git a/boards/arm/keychron_q8/board.cmake b/boards/arm/keychron_q8/board.cmake new file mode 100644 index 0000000..8ec7d47 --- /dev/null +++ b/boards/arm/keychron_q8/board.cmake @@ -0,0 +1,5 @@ +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") + +set_ifndef(BOARD_FLASH_RUNNER dfu-util) + +include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake) diff --git a/boards/arm/keychron_q8/keychron-layout.dtsi b/boards/arm/keychron_q8/keychron-layout.dtsi new file mode 100644 index 0000000..7174570 --- /dev/null +++ b/boards/arm/keychron_q8/keychron-layout.dtsi @@ -0,0 +1,80 @@ +#include + +/ { + keychron_layout: keychron_layout { + compatible = "zmk,physical-layout"; + display-name = "LAYOUT_ansi_69"; + + keys // w h x y rot rx ry + = <&key_physical_attrs 100 100 75 25 0 0 0> + , <&key_physical_attrs 100 100 175 25 0 0 0> + , <&key_physical_attrs 100 100 275 0 0 0 0> + , <&key_physical_attrs 100 100 375 25 0 0 0> + , <&key_physical_attrs 100 100 475 25 0 0 0> + , <&key_physical_attrs 100 100 575 25 0 0 0> + , <&key_physical_attrs 100 100 675 25 0 0 0> + , <&key_physical_attrs 100 100 950 25 0 0 0> + , <&key_physical_attrs 100 100 1050 25 0 0 0> + , <&key_physical_attrs 100 100 1150 25 0 0 0> + , <&key_physical_attrs 100 100 1250 25 0 0 0> + , <&key_physical_attrs 100 100 1350 0 0 0 0> + , <&key_physical_attrs 100 100 1450 25 0 0 0> + , <&key_physical_attrs 200 100 1550 25 0 0 0> + , <&key_physical_attrs 100 100 1800 0 0 0 0> + , <&key_physical_attrs 150 100 50 125 0 0 0> + , <&key_physical_attrs 100 100 200 125 0 0 0> + , <&key_physical_attrs 100 100 325 125 0 0 0> + , <&key_physical_attrs 100 100 425 125 0 0 0> + , <&key_physical_attrs 100 100 525 125 0 0 0> + , <&key_physical_attrs 100 100 625 125 0 0 0> + , <&key_physical_attrs 100 100 900 125 0 0 0> + , <&key_physical_attrs 100 100 1000 125 0 0 0> + , <&key_physical_attrs 100 100 1100 125 0 0 0> + , <&key_physical_attrs 100 100 1200 125 0 0 0> + , <&key_physical_attrs 100 100 1325 125 0 0 0> + , <&key_physical_attrs 100 100 1425 125 0 0 0> + , <&key_physical_attrs 100 100 1525 125 0 0 0> + , <&key_physical_attrs 150 100 1625 125 0 0 0> + , <&key_physical_attrs 100 100 1825 150 0 0 0> + , <&key_physical_attrs 175 100 25 225 0 0 0> + , <&key_physical_attrs 100 100 200 225 0 0 0> + , <&key_physical_attrs 100 100 350 225 0 0 0> + , <&key_physical_attrs 100 100 450 225 0 0 0> + , <&key_physical_attrs 100 100 550 225 0 0 0> + , <&key_physical_attrs 100 100 650 225 0 0 0> + , <&key_physical_attrs 100 100 925 225 0 0 0> + , <&key_physical_attrs 100 100 1025 225 0 0 0> + , <&key_physical_attrs 100 100 1125 225 0 0 0> + , <&key_physical_attrs 100 100 1225 225 0 0 0> + , <&key_physical_attrs 100 100 1375 225 0 0 0> + , <&key_physical_attrs 100 100 1475 225 0 0 0> + , <&key_physical_attrs 225 100 1575 225 0 0 0> + , <&key_physical_attrs 100 100 1850 250 0 0 0> + , <&key_physical_attrs 225 100 0 325 0 0 0> + , <&key_physical_attrs 100 100 225 325 0 0 0> + , <&key_physical_attrs 100 100 375 325 0 0 0> + , <&key_physical_attrs 100 100 475 325 0 0 0> + , <&key_physical_attrs 100 100 575 325 0 0 0> + , <&key_physical_attrs 100 100 675 325 0 0 0> + , <&key_physical_attrs 100 100 850 325 0 0 0> + , <&key_physical_attrs 100 100 950 325 0 0 0> + , <&key_physical_attrs 100 100 1050 325 0 0 0> + , <&key_physical_attrs 100 100 1150 325 0 0 0> + , <&key_physical_attrs 100 100 1250 325 0 0 0> + , <&key_physical_attrs 100 100 1425 325 0 0 0> + , <&key_physical_attrs 175 100 1525 325 0 0 0> + , <&key_physical_attrs 100 100 1725 350 0 0 0> + , <&key_physical_attrs 125 100 0 425 0 0 0> + , <&key_physical_attrs 125 100 125 425 0 0 0> + , <&key_physical_attrs 125 100 375 425 0 0 0> + , <&key_physical_attrs 225 100 500 425 0 0 0> + , <&key_physical_attrs 100 100 725 425 0 0 0> + , <&key_physical_attrs 100 100 875 425 0 0 0> + , <&key_physical_attrs 275 100 975 425 0 0 0> + , <&key_physical_attrs 100 100 1250 425 0 0 0> + , <&key_physical_attrs 100 100 1625 450 0 0 0> + , <&key_physical_attrs 100 100 1725 450 0 0 0> + , <&key_physical_attrs 100 100 1825 450 0 0 0> + ; + }; +}; diff --git a/boards/arm/keychron_q8/keychron_q8.dts b/boards/arm/keychron_q8/keychron_q8.dts new file mode 100644 index 0000000..1ffc308 --- /dev/null +++ b/boards/arm/keychron_q8/keychron_q8.dts @@ -0,0 +1,265 @@ +/dts-v1/; +#include +#include + +#include +#include + +#include +#include + +#include "keychron-layout.dtsi" + +&keychron_layout { + transform = <&transform>; +}; + +/ { + model = "Keychron Q8"; + compatible = "keychron,q8", "st,stm32l032"; + + chosen { + zephyr,code-partition = &code_partition; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zmk,kscan = &kscan; + zmk,underglow = &led_strip; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&encoder>; + }; + + transform: transform { + compatible = "zmk,matrix-transform"; + // "B4", "B3", "A15", "A14", "A13" + rows = <5>; + // "C14", "C15", "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "B0", "B1", "A8", "A9", "H3" + columns = <15>; + + map = < + RC(4,4) + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) RC(2,14) + RC(3,0) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,13) RC(3,14) + RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,12) RC(4,13) RC(4,14) + >; + }; + + kscan: kscan { + compatible = "zmk,kscan-gpio-matrix"; + diode-direction = "col2row"; + wakeup-source; + row-gpios = <&gpiob 4 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpiob 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioa 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioa 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, + <&gpioa 13 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + col-gpios = <&gpioc 14 GPIO_ACTIVE_LOW>, + <&gpioc 15 GPIO_ACTIVE_LOW>, + <&gpioa 0 GPIO_ACTIVE_LOW>, + <&gpioa 1 GPIO_ACTIVE_LOW>, + <&gpioa 2 GPIO_ACTIVE_LOW>, + <&gpioa 3 GPIO_ACTIVE_LOW>, + <&gpioa 4 GPIO_ACTIVE_LOW>, + <&gpioa 5 GPIO_ACTIVE_LOW>, + <&gpioa 6 GPIO_ACTIVE_LOW>, + <&gpioa 7 GPIO_ACTIVE_LOW>, + <&gpiob 0 GPIO_ACTIVE_LOW>, + <&gpiob 1 GPIO_ACTIVE_LOW>, + <&gpioa 8 GPIO_ACTIVE_LOW>, + <&gpioa 9 GPIO_ACTIVE_LOW>, + <&gpioh 3 GPIO_ACTIVE_LOW>; + }; + + encoder: encoder { + compatible = "alps,ec11"; + a-gpios = <&gpiob 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + b-gpios = <&gpioa 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>; + steps = <4>; + status = "okay"; + }; + + led_strip: led-strip-composite { + compatible = "zmk,led-strip-composite"; + chain-length = <82>; + strip-0 { + led-strip = <&led_strip_0>; + }; + strip-1 { + led-strip = <&led_strip_1>; + }; + }; +}; + +&clk_lsi { + status = "okay"; +}; + +&clk_hsi { + status = "okay"; +}; + +&clk_hsi48 { + status = "okay"; +}; + +&pll { + // https://github.com/qmk/qmk_firmware/blob/7f22cb52e3aaafde671fdb994d53914366baf31a/platforms/chibios/boards/GENERIC_STM32_L432XC/configs/mcuconf.h#L54-L59 + div-m = <1>; + mul-n = <20>; + div-p = <7>; + div-q = <2>; + div-r = <4>; + clocks = <&clk_hsi>; + status = "okay"; +}; + +&rcc { + clocks = <&pll>; + clock-frequency = ; + ahb-prescaler = <1>; + apb1-prescaler = <1>; + apb2-prescaler = <1>; +}; + +&sram0 { + reg = <0x20000000 DT_SIZE_K(48)>; +}; + +&usb { + status = "okay"; + pinctrl-0 = <&usb_dm_pa11 &usb_dp_pa12>; + pinctrl-names = "default"; +}; + +&rtc { + status = "okay"; +}; + +zephyr_udc0: &usb { + status = "okay"; +}; + +&flash0 { + reg = <0x8000000 DT_SIZE_K(128)>; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + code_partition: partition@0 { + label = "code_partition"; + reg = ; + }; + + storage_partition: partition@1f000 { + label = "storage"; + reg = ; + }; + }; +}; + +&i2c1 { + pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + pinctrl-names = "default"; + status = "okay"; + clock-frequency = ; + + led_strip_0: ckled2001@77 { + compatible = "zmk,ckled2001"; + reg = <0x77>; + chain-length = <35>; + #led-strip-cells = <0>; + map = < + /* R G B */ + CK(8, 0) CK(6, 0) CK(7, 0) + CK(8, 1) CK(6, 1) CK(7, 1) + CK(8, 2) CK(6, 2) CK(7, 2) + CK(8, 3) CK(6, 3) CK(7, 3) + CK(8, 4) CK(6, 4) CK(7, 4) + CK(8, 5) CK(6, 5) CK(7, 5) + CK(8, 6) CK(6, 6) CK(7, 6) + CK(8, 7) CK(6, 7) CK(7, 7) + CK(8, 8) CK(6, 8) CK(7, 8) + CK(8, 9) CK(6, 9) CK(7, 9) + CK(8,10) CK(6,10) CK(7,10) + CK(8,11) CK(6,11) CK(7,11) + CK(8,12) CK(6,12) CK(7,12) + CK(8,13) CK(6,13) CK(7,13) + CK(8,14) CK(6,14) CK(7,14) + + CK(5, 0) CK(3, 0) CK(4, 0) + CK(5, 1) CK(3, 1) CK(4, 1) + CK(5, 2) CK(3, 2) CK(4, 2) + CK(5, 3) CK(3, 3) CK(4, 3) + CK(5, 4) CK(3, 4) CK(4, 4) + CK(5, 5) CK(3, 5) CK(4, 5) + CK(5, 6) CK(3, 6) CK(4, 6) + CK(5, 7) CK(3, 7) CK(4, 7) + CK(5, 8) CK(3, 8) CK(4, 8) + CK(5, 9) CK(3, 9) CK(4, 9) + CK(5,10) CK(3,10) CK(4,10) + CK(5,11) CK(3,11) CK(4,11) + CK(5,12) CK(3,12) CK(4,12) + CK(5,14) CK(3,14) CK(4,14) + + CK(2, 0) CK(0, 0) CK(1, 0) + CK(2, 1) CK(0, 1) CK(1, 1) + CK(2, 2) CK(0, 2) CK(1, 2) + CK(2, 3) CK(0, 3) CK(1, 3) + CK(2, 4) CK(0, 4) CK(1, 4) + CK(5,13) CK(3,13) CK(4,13) + >; + }; + + led_strip_1: ckled2001@74 { + compatible = "zmk,ckled2001"; + reg = <0x74>; + chain-length = <35>; + #led-strip-cells = <0>; + map = < + /* R G B */ + CK(2, 9) CK(0, 9) CK(1, 9) + CK(2, 7) CK(0, 7) CK(1, 7) + CK(2, 6) CK(0, 6) CK(1, 6) + CK(2, 5) CK(0, 5) CK(1, 5) + CK(2, 4) CK(0, 4) CK(1, 4) + CK(2, 3) CK(0, 3) CK(1, 3) + CK(2, 2) CK(0, 2) CK(1, 2) + CK(2, 1) CK(0, 1) CK(1, 1) + CK(2, 0) CK(0, 0) CK(1, 0) + + CK(8, 14) CK(6, 14) CK(7, 14) + CK(8, 13) CK(6, 13) CK(7, 13) + CK(8, 12) CK(6, 12) CK(7, 12) + CK(8, 11) CK(6, 11) CK(7, 11) + CK(8, 10) CK(6, 10) CK(7, 10) + CK(8, 9) CK(6, 9) CK(7, 9) + CK(8, 8) CK(6, 8) CK(7, 8) + CK(8, 7) CK(6, 7) CK(7, 7) + CK(8, 6) CK(6, 6) CK(7, 6) + CK(8, 5) CK(6, 5) CK(7, 5) + CK(8, 4) CK(6, 4) CK(7, 4) + CK(8, 3) CK(6, 3) CK(7, 3) + CK(8, 2) CK(6, 2) CK(7, 2) + CK(8, 1) CK(6, 1) CK(7, 1) + CK(8, 0) CK(6, 0) CK(7, 0) + + CK(5, 14) CK(3, 14) CK(4, 14) + CK(5, 13) CK(3, 13) CK(4, 13) + CK(5, 12) CK(3, 12) CK(4, 12) + CK(5, 11) CK(3, 11) CK(4, 11) + CK(5, 8) CK(3, 8) CK(4, 8) + CK(5, 7) CK(3, 7) CK(4, 7) + CK(5, 6) CK(3, 6) CK(4, 6) + CK(5, 5) CK(3, 5) CK(4, 5) + CK(5, 2) CK(3, 2) CK(4, 2) + CK(5, 1) CK(3, 1) CK(4, 1) + CK(5, 0) CK(3, 0) CK(4, 0) + >; + }; +}; diff --git a/boards/arm/keychron_q8/keychron_q8.keymap b/boards/arm/keychron_q8/keychron_q8.keymap new file mode 100644 index 0000000..ddff1f2 --- /dev/null +++ b/boards/arm/keychron_q8/keychron_q8.keymap @@ -0,0 +1,21 @@ +#undef ZMK_BEHAVIORS_KEEP_ALL + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + default_layer { + bindings = < + &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A + &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A + &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A + &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A + &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A &kp A + >; + }; + }; +}; + diff --git a/boards/arm/keychron_q8/keychron_q8.yaml b/boards/arm/keychron_q8/keychron_q8.yaml new file mode 100644 index 0000000..c9fc2d6 --- /dev/null +++ b/boards/arm/keychron_q8/keychron_q8.yaml @@ -0,0 +1,7 @@ +identifier: keychron_q8 +name: Keychron Q8 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb diff --git a/boards/arm/keychron_q8/keychron_q8.zmk.yml b/boards/arm/keychron_q8/keychron_q8.zmk.yml new file mode 100644 index 0000000..a82846b --- /dev/null +++ b/boards/arm/keychron_q8/keychron_q8.zmk.yml @@ -0,0 +1,10 @@ +file_format: "1" +id: keychron_q8 +name: Keychron Q8 +type: board +arch: arm +features: + - keys +outputs: + - usb +url: https://www.keychron.com/products/keychron-q8 diff --git a/boards/arm/keychron_q8/keychron_q8_defconfig b/boards/arm/keychron_q8/keychron_q8_defconfig new file mode 100644 index 0000000..9fc75fb --- /dev/null +++ b/boards/arm/keychron_q8/keychron_q8_defconfig @@ -0,0 +1,56 @@ +CONFIG_BOARD_KEYCHRON_Q8=y + +# SoC +CONFIG_SOC_SERIES_STM32L4X=y +CONFIG_SOC_STM32L432XX=y + +# 80MHz system clock +CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=80000000 + +# enable GPIO +CONFIG_GPIO=y + +# ZMK Settings +CONFIG_ZMK_USB=y +CONFIG_ZMK_KSCAN_MATRIX_POLLING=y +CONFIG_USB_SELF_POWERED=n +CONFIG_ZMK_HID_REPORT_TYPE_NKRO=y + +# Needed to reduce this to size that will fit on L432 +CONFIG_HEAP_MEM_POOL_SIZE=1024 + +# clock configuration +CONFIG_CLOCK_CONTROL=y + +# enable PINCTRL +CONFIG_PINCTRL=y + +CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y + +# Key scanning +CONFIG_ZMK_KSCAN_MATRIX_POLLING=y +CONFIG_ZMK_KSCAN_MATRIX_WAIT_BETWEEN_OUTPUTS=30 + +# Storage +CONFIG_FLASH=y +CONFIG_FLASH_MAP=y +CONFIG_NVS=y +CONFIG_SETTINGS=y + +# USB +CONFIG_USB_DEVICE_MANUFACTURER="Keychron" +CONFIG_USB_DEVICE_PRODUCT="Q8" + +# Use the STRIP config specific to the LEDs you're using +# NOTE: This is required for extrnal module, zmk-ckled2001 +CONFIG_ZMK_RGB_UNDERGLOW=y +CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=n +CONFIG_ZMK_RGB_UNDERGLOW_EFF_START=3 +CONFIG_ZMK_RGB_UNDERGLOW_BRT_START=80 +CONFIG_ZMK_RGB_UNDERGLOW_AUTO_OFF_IDLE=y +CONFIG_LED_STRIP_INIT_PRIORITY=81 + +# Encoder +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y diff --git a/config/include/base.dtsi b/config/include/base.dtsi index 637d514..6df4328 100644 --- a/config/include/base.dtsi +++ b/config/include/base.dtsi @@ -135,3 +135,27 @@ }; }; }; + +#ifdef CONFIG_ENCODER + #include + + / { + behaviors { + rgb_encoder: rgb_encoder { + compatible = "zmk,behavior-sensor-rotate"; + #sensor-binding-cells = <0>; + bindings = <&rgb_ug RGB_BRI>, <&rgb_ug RGB_BRD>; + }; + }; + + keymap { + default_layer { + sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN>; + }; + + number_layer { + sensor-bindings = <&rgb_encoder>; + }; + }; + }; +#endif diff --git a/config/keychron_q8.conf b/config/keychron_q8.conf new file mode 100644 index 0000000..3eb27a8 --- /dev/null +++ b/config/keychron_q8.conf @@ -0,0 +1 @@ +CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048 diff --git a/config/keychron_q8.keymap b/config/keychron_q8.keymap new file mode 100644 index 0000000..1473206 --- /dev/null +++ b/config/keychron_q8.keymap @@ -0,0 +1,89 @@ +// vim: set ts=4 sw=4 ft=devicetree: + +/* KEY POSITIONS + + RC(4,4) + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(1,7) RC(1,8) RC(1,9) RC(1,10) RC(1,11) RC(1,12) RC(1,13) RC(1,14) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,7) RC(2,8) RC(2,9) RC(2,10) RC(2,11) RC(2,12) RC(2,13) RC(2,14) + RC(3,0) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(3,8) RC(3,9) RC(3,10) RC(3,11) RC(3,12) RC(3,13) RC(3,14) + RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,6) RC(4,7) RC(4,8) RC(4,9) RC(4,12) RC(4,13) RC(4,14) + + SW + ╭───────────────────────────╮ ╭───────────────────────────────────────╮ + │ 0 1 2 3 4 5 6 │ │ 7 8 9 10 11 12 13 14 │ + │ 15 16 17 18 19 20 │ │ 21 22 23 24 25 26 27 28 29 │ + │ 30 31 32 33 34 35 │ │ 36 37 38 39 40 41 42 43 │ + │ 44 45 46 47 48 49 │ │50 51 52 53 54 55 56 57 │ + │ 58 59 60 61 62 │ │ 63 64 65 66 67 68 │ + ╰───────────────────────────╯ ╰───────────────────────────────────────╯ + ╭───────────────────────────╮ ╭───────────────────────────────────────╮ + │ │ │ │ + │ LT4 LT3 LT2 LT1 LT0 │ │ RT0 RT1 RT2 RT3 RT4 RT5 │ + │ LM4 LM3 LM2 LM1 LM0 │ │ RM0 RM1 RM2 RM3 RM4 │ + │ LB4 LB3 LB2 LB1 LB0 │ │ RB0 RB1 RB2 RB3 RB4 │ + │ LH1 LH0│ │ RH0 RH1 │ + ╰───────────────────────────╯ ╰───────────────────────────────────────╯ +*/ + +#define CONFIG_ENCODER + +/* key positions */ +#define LT0 20 // left-top row +#define LT1 19 +#define LT2 18 +#define LT3 17 +#define LT4 16 + +#define RT0 21 // right-top row +#define RT1 22 +#define RT2 23 +#define RT3 24 +#define RT4 25 + +#define LM0 35 // left-middle row +#define LM1 34 +#define LM2 33 +#define LM3 32 +#define LM4 31 + +#define RM0 36 // right-middle row +#define RM1 37 +#define RM2 38 +#define RM3 39 +#define RM4 40 + +#define LB0 49 // left-bottom row +#define LB1 48 +#define LB2 47 +#define LB3 46 +#define LB4 45 + +#define RB0 51 // right-bottom row +#define RB1 52 +#define RB2 53 +#define RB3 54 +#define RB4 55 + +#define LH0 62 // left thumb keys +#define LH1 61 + +#define RH0 63 // right thumb keys +#define RH1 64 + +/* kinesis extra keys */ +#define X_LT &mo DEF \ + &kp ESC &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp MINUS &kp EQUAL &kp BSPC &kp C_MUTE \ + &kp TAB +#define X_LM &kp CAPS +#define X_LB &kp LSHFT +#define X_LH &kp LCTRL &kp LGUI &kp LALT + +#define X_MB XXX + +#define X_RT &kp LBKT &kp RBKT &kp BSLH &kp DEL +#define X_RM &kp SQT &kp ENTER &kp HOME +#define X_RB &kp RSHFT &kp UP +#define X_RH &kp RALT &kp LEFT &kp DOWN &kp RIGHT + +#include "include/base.dtsi" diff --git a/config/west.yml b/config/west.yml index f9adb79..ce40a55 100644 --- a/config/west.yml +++ b/config/west.yml @@ -15,5 +15,8 @@ manifest: - name: zmk-tri-state remote: dhruvinsh revision: main + - name: zmk-ckled2001 + remote: dhruvinsh + revision: main self: path: config diff --git a/scripts/firmware_build.sh b/scripts/firmware_build.sh index b903636..2b4526e 100755 --- a/scripts/firmware_build.sh +++ b/scripts/firmware_build.sh @@ -31,6 +31,10 @@ west build -p -d build/eros_right -b nice_nano_v2 -S studio-rpc-usb-uart -- -DSH echo -e "${RED}---> Building helios..${NC}" west build -p -d build/helios -b blackpill_f411ce -S studio-rpc-usb-uart -- -DSHIELD="helios" -DZMK_EXTRA_MODULES="$WORKSPACE_DIR/../zmk-config;$WORKSPACE_DIR/../zmk-tri-state;$WORKSPACE_DIR/../zmk-num-word" -DZMK_CONFIG="$WORKSPACE_DIR"/../zmk-config/config +echo -e "${RED}---> Building keychron..${NC}" +# west build -p -d build/helios -b keychron_q8 -S studio-rpc-usb-uart -- -DSHIELD="helios" -DZMK_EXTRA_MODULES="$WORKSPACE_DIR/../zmk-config;$WORKSPACE_DIR/../zmk-tri-state;$WORKSPACE_DIR/../zmk-num-word" -DZMK_CONFIG="$WORKSPACE_DIR"/../zmk-config/config +west build -p -d build/keychron -b keychron_q8 -S studio-rpc-usb-uart -- -DZMK_EXTRA_MODULES="$WORKSPACE_DIR/../zmk-config;$WORKSPACE_DIR/../zmk-tri-state;$WORKSPACE_DIR/../zmk-num-word;$WORKSPACE_DIR/../zmk-ckled2001" -DZMK_CONFIG="$WORKSPACE_DIR"/../zmk-config/config + echo -e "${RED}---> Building nice_nano_v2 reset firmware..${NC}" west build -p -d build/reset -b nice_nano_v2 -- -DSHIELD="settings_reset" @@ -45,3 +49,4 @@ cp build/lynx_right/zephyr/zmk.uf2 "$WORKSPACE_DIR"/../zmk-config/builds/lynx_ri cp build/reset/zephyr/zmk.uf2 "$WORKSPACE_DIR"/../zmk-config/builds/nice_nano_v2_reset.uf2 cp build/helios/zephyr/zmk.uf2 "$WORKSPACE_DIR"/../zmk-config/builds/helios.uf2 +cp build/keychron/zephyr/zmk.bin "$WORKSPACE_DIR"/../zmk-config/builds/keychron.bin diff --git a/scripts/keymap_build.sh b/scripts/keymap_build.sh index 0ca0092..e4455ff 100755 --- a/scripts/keymap_build.sh +++ b/scripts/keymap_build.sh @@ -29,3 +29,8 @@ echo -n "Building Helios keymaps.." keymap -c keymap_drawer.config.yaml parse -z config/helios.keymap >assets/helios.yaml keymap -c keymap_drawer.config.yaml draw -k kinesis/stapelberg -l LAYOUT assets/helios.yaml >assets/helios.svg echo " Done" + +echo -n "Building Keychron keymaps.." +keymap -c keymap_drawer.config.yaml parse -z config/keychron_q8.keymap >assets/keychron.yaml +keymap -c keymap_drawer.config.yaml draw -k keychron/q8/ansi_encoder -l LAYOUT_ansi_69 assets/keychron.yaml >assets/keychron.svg +echo " Done"