-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(board): keychron q8 support (#6)
- feat(board): keychron q8 (WIP)So far compiling works but nothig else - fix(layout): corrected mapping for keychron q8Correct Matrix is located here, https://github.com/qmk/qmk_firmware/blob/master/keyboards%2Fkeychron%2Fq8%2Fansi_encoder%2Fkeyboard.json - fix(board): further improvement to mapping - fix(board): finally working keychron q8added missing the usb clock - refactor: adjusting spacing on matrix - feat(keymap): fully working keys for keychron - refactor: removing unused config - feat(script): adding keychron draw script - feat(scripts): adding keychron build - feat(keychron): adding physical layout with zmk-studio - feat(config): fully working led* for now all led turns on, with red color only. - feat(keychron): adding wakeup source (just in-case) - feat(keychron): RGB adjustment - refactor(keychron): correcting spacing and formats- updated the layout - tab vs space - corrected key index for combo purpose - feat(keychron): adding encoder support - fix(script): adding missing external module - feat(keychron): adding switch support
- Loading branch information
Showing
15 changed files
with
589 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
config BOARD_KEYCHRON_Q8 | ||
bool "Keychron Q8" | ||
depends on SOC_STM32L432XX |
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,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 |
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 @@ | ||
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) |
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,80 @@ | ||
#include <physical_layouts.dtsi> | ||
|
||
/ { | ||
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> | ||
; | ||
}; | ||
}; |
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,265 @@ | ||
/dts-v1/; | ||
#include <freq.h> | ||
#include <mem.h> | ||
|
||
#include <st/l4/stm32l432.dtsi> | ||
#include <st/l4/stm32l432k(b-c)ux-pinctrl.dtsi> | ||
|
||
#include <dt-bindings/zmk/matrix_transform.h> | ||
#include <dt-bindings/zmk/ckled2001.h> | ||
|
||
#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 = <DT_FREQ_M(80)>; | ||
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 = <DT_SIZE_K(0) DT_SIZE_K(124)>; | ||
}; | ||
|
||
storage_partition: partition@1f000 { | ||
label = "storage"; | ||
reg = <DT_SIZE_K(124) DT_SIZE_K(4)>; | ||
}; | ||
}; | ||
}; | ||
|
||
&i2c1 { | ||
pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; | ||
pinctrl-names = "default"; | ||
status = "okay"; | ||
clock-frequency = <DT_FREQ_K(400)>; | ||
|
||
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) | ||
>; | ||
}; | ||
}; |
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,21 @@ | ||
#undef ZMK_BEHAVIORS_KEEP_ALL | ||
|
||
#include <behaviors.dtsi> | ||
#include <dt-bindings/zmk/keys.h> | ||
#include <dt-bindings/zmk/bt.h> | ||
|
||
/ { | ||
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 | ||
>; | ||
}; | ||
}; | ||
}; | ||
|
Oops, something went wrong.