From 3ee2d1196b9335a081d841ff3918d2fdf722d5b9 Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 20 Aug 2020 00:07:04 -0500 Subject: feat(rgb): underglow state Kconfig and settings --- app/Kconfig | 24 +++++++++++++++ app/src/rgb_underglow.c | 77 +++++++++++++++++++++++++++++++++++++------------ 2 files changed, 83 insertions(+), 18 deletions(-) (limited to 'app') diff --git a/app/Kconfig b/app/Kconfig index 416c985..cefae21 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -180,6 +180,30 @@ config ZMK_RGB_UNDERGLOW_BRT_STEP int "RGB underglow brightness step in percent" default 10 +config ZMK_RGB_UNDERGLOW_HUE_START + int "RGB underglow start hue value from 0-359" + default 0 + +config ZMK_RGB_UNDERGLOW_SAT_START + int "RGB underglow start saturations value from 0-100" + default 100 + +config ZMK_RGB_UNDERGLOW_BRT_START + int "RGB underglow start brightness value from 0-100" + default 100 + +config ZMK_RGB_UNDERGLOW_SPD_START + int "RGB underglow start animation speed value from 1-5" + default 3 + +config ZMK_RGB_UNDERGLOW_EFF_START + int "RGB underglow start effect int value related to the effect enum list" + default 0 + +config ZMK_RGB_UNDERGLOW_ON_START + bool "Whether RGB underglow starts on by default" + default y + endif endmenu diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 95adcec..5f55798 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -45,12 +46,39 @@ struct rgb_underglow_state { bool on; }; -struct rgb_underglow_state state; - struct device *led_strip; struct led_rgb pixels[STRIP_NUM_PIXELS]; +struct rgb_underglow_state state; + +static int rgb_settings_set(const char *name, size_t len, + settings_read_cb read_cb, void *cb_arg) +{ + const char *next; + int rc; + + if (settings_name_steq(name, "state", &next) && !next) { + if (len != sizeof(state)) { + return -EINVAL; + } + + rc = read_cb(cb_arg, &state, sizeof(state)); + if (rc >= 0) { + return 0; + } + + return rc; + } + + return -ENOENT; +} + +struct settings_handler rgb_conf = { + .name = "rgb", + .h_set = rgb_settings_set +}; + static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { double r, g, b; @@ -187,20 +215,35 @@ static int zmk_rgb_underglow_init(struct device *_arg) } state = (struct rgb_underglow_state){ - hue: 0, - saturation: 100, - brightness: 100, - animation_speed: 3, - current_effect: 0, + hue: CONFIG_ZMK_RGB_UNDERGLOW_HUE_START, + saturation: CONFIG_ZMK_RGB_UNDERGLOW_SAT_START, + brightness: CONFIG_ZMK_RGB_UNDERGLOW_BRT_START, + animation_speed: CONFIG_ZMK_RGB_UNDERGLOW_SPD_START, + current_effect: CONFIG_ZMK_RGB_UNDERGLOW_EFF_START, animation_step: 0, +#ifdef CONFIG_ZMK_RGB_UNDERGLOW_ON_START on: true +#else + on: false +#endif }; - k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); + settings_subsys_init(); + settings_register(&rgb_conf); + settings_load(); + + if (state.on) { + k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); + } return 0; } +int zmk_rgb_underglow_save_state() +{ + return settings_save_one("rgb/state", &state, sizeof(state)); +} + int zmk_rgb_underglow_cycle_effect(int direction) { if (!led_strip) return -ENODEV; @@ -218,7 +261,7 @@ int zmk_rgb_underglow_cycle_effect(int direction) state.animation_step = 0; - return 0; + return zmk_rgb_underglow_save_state(); } int zmk_rgb_underglow_toggle() @@ -242,7 +285,7 @@ int zmk_rgb_underglow_toggle() k_timer_stop(&underglow_tick); } - return 0; + return zmk_rgb_underglow_save_state(); } int zmk_rgb_underglow_change_hue(int direction) @@ -250,17 +293,15 @@ int zmk_rgb_underglow_change_hue(int direction) if (!led_strip) return -ENODEV; if (state.hue == 0 && direction < 0) { - state.hue = 350; + state.hue = 360 - CONFIG_ZMK_RGB_UNDERGLOW_HUE_STEP; return 0; } state.hue += direction * CONFIG_ZMK_RGB_UNDERGLOW_HUE_STEP; - if (state.hue > 350) { - state.hue = 0; - } + state.hue = state.hue % 360; - return 0; + return zmk_rgb_underglow_save_state(); } int zmk_rgb_underglow_change_sat(int direction) @@ -277,7 +318,7 @@ int zmk_rgb_underglow_change_sat(int direction) state.saturation = 100; } - return 0; + return zmk_rgb_underglow_save_state(); } int zmk_rgb_underglow_change_brt(int direction) @@ -294,7 +335,7 @@ int zmk_rgb_underglow_change_brt(int direction) state.brightness = 100; } - return 0; + return zmk_rgb_underglow_save_state(); } int zmk_rgb_underglow_change_spd(int direction) @@ -311,7 +352,7 @@ int zmk_rgb_underglow_change_spd(int direction) state.animation_speed = 5; } - return 0; + return zmk_rgb_underglow_save_state(); } SYS_INIT(zmk_rgb_underglow_init, -- cgit v1.2.3 From 74fd4fc997c0cf78cc9acabdd61466fa4857e7ba Mon Sep 17 00:00:00 2001 From: Nick Date: Thu, 20 Aug 2020 21:13:17 -0500 Subject: fix(rgb): fix underglow settings location --- app/src/rgb_underglow.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 5f55798..86223b1 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -75,7 +75,7 @@ static int rgb_settings_set(const char *name, size_t len, } struct settings_handler rgb_conf = { - .name = "rgb", + .name = "rgb/underglow", .h_set = rgb_settings_set }; @@ -241,7 +241,7 @@ static int zmk_rgb_underglow_init(struct device *_arg) int zmk_rgb_underglow_save_state() { - return settings_save_one("rgb/state", &state, sizeof(state)); + return settings_save_one("rgb/underglow/state", &state, sizeof(state)); } int zmk_rgb_underglow_cycle_effect(int direction) -- cgit v1.2.3 From c5c21022a23cae3fecaf17e13d18d7d1ebd5f150 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 23 Aug 2020 10:33:19 -0500 Subject: Move settings load --- app/CMakeLists.txt | 1 + app/src/rgb_underglow.c | 40 ++++++++++++++++++++++------------------ app/src/settings.c | 13 +++++++++++++ 3 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 app/src/settings.c (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 054f84a..bb4af55 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -55,4 +55,5 @@ target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/hid_listener.c) +target_sources(app PRIVATE src/settings.c) target_sources(app PRIVATE src/main.c) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 86223b1..3851421 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -15,7 +15,6 @@ #include #include -#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -106,6 +105,16 @@ static struct led_rgb hsb_to_rgb(struct led_hsb hsb) return rgb; } +static void zmk_rgb_underglow_off() +{ + for (int i=0; i +#include +#include +#include + +static int zmk_settings_init(struct device *_arg) +{ + return settings_load(); +} + +SYS_INIT(zmk_settings_init, + APPLICATION, + CONFIG_APPLICATION_INIT_PRIORITY); -- cgit v1.2.3 From 979a5bffffeac0fed12db00409dedb8ed6c4ad87 Mon Sep 17 00:00:00 2001 From: Nick Date: Sun, 23 Aug 2020 15:56:18 -0500 Subject: fix(rgb): check if settings enabled --- app/CMakeLists.txt | 2 +- app/src/rgb_underglow.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index bb4af55..bbb54b9 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -55,5 +55,5 @@ target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) target_sources(app PRIVATE src/hid_listener.c) -target_sources(app PRIVATE src/settings.c) +target_sources_ifdef(CONFIG_SETTINGS app PRIVATE src/settings.c) target_sources(app PRIVATE src/main.c) diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index 3851421..cb98e8d 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -51,6 +51,7 @@ struct led_rgb pixels[STRIP_NUM_PIXELS]; struct rgb_underglow_state state; +#if IS_ENABLED(CONFIG_SETTINGS) static int rgb_settings_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) { @@ -77,6 +78,7 @@ struct settings_handler rgb_conf = { .name = "rgb/underglow", .h_set = rgb_settings_set }; +#endif static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { @@ -242,7 +244,9 @@ static int zmk_rgb_underglow_init(struct device *_arg) on: IS_ENABLED(CONFIG_ZMK_RGB_UNDERGLOW_ON_START) }; +#if IS_ENABLED(CONFIG_SETTINGS) settings_register(&rgb_conf); +#endif k_timer_start(&underglow_tick, K_NO_WAIT, K_MSEC(50)); @@ -251,7 +255,11 @@ static int zmk_rgb_underglow_init(struct device *_arg) int zmk_rgb_underglow_save_state() { +#if IS_ENABLED(CONFIG_SETTINGS) return settings_save_one("rgb/underglow/state", &state, sizeof(state)); +#else + return 0; +#endif } int zmk_rgb_underglow_cycle_effect(int direction) -- cgit v1.2.3 From 4551d307693dae30802a3f06d5f62fcf3155f8c0 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 3 Sep 2020 13:20:05 +0100 Subject: ad cradios --- app/boards/shields/cradios/Kconfig.defconfig | 14 +++++++++ app/boards/shields/cradios/Kconfig.shield | 5 ++++ app/boards/shields/cradios/cradios.dtsi | 31 +++++++++++++++++++ app/boards/shields/cradios/cradios.keymap | 17 +++++++++++ app/boards/shields/cradios/cradios_left.conf | 2 ++ app/boards/shields/cradios/cradios_left.overlay | 34 +++++++++++++++++++++ app/boards/shields/cradios/cradios_right.conf | 2 ++ app/boards/shields/cradios/cradios_right.overlay | 38 ++++++++++++++++++++++++ app/boards/shields/cradios/default.keymap | 19 ++++++++++++ 9 files changed, 162 insertions(+) create mode 100644 app/boards/shields/cradios/Kconfig.defconfig create mode 100644 app/boards/shields/cradios/Kconfig.shield create mode 100644 app/boards/shields/cradios/cradios.dtsi create mode 100644 app/boards/shields/cradios/cradios.keymap create mode 100644 app/boards/shields/cradios/cradios_left.conf create mode 100644 app/boards/shields/cradios/cradios_left.overlay create mode 100644 app/boards/shields/cradios/cradios_right.conf create mode 100644 app/boards/shields/cradios/cradios_right.overlay create mode 100644 app/boards/shields/cradios/default.keymap (limited to 'app') diff --git a/app/boards/shields/cradios/Kconfig.defconfig b/app/boards/shields/cradios/Kconfig.defconfig new file mode 100644 index 0000000..0aca38f --- /dev/null +++ b/app/boards/shields/cradios/Kconfig.defconfig @@ -0,0 +1,14 @@ + +if SHIELD_CRADIOS + +config ZMK_KEYBOARD_NAME + default "cradios" + +# Unable to use interrupts as the same pin number is used +# across A & B controllers, and STM32F303CCT6 can't enable +# interrutps for multiple controllers for the same "line" +# for the external interrupts. +config ZMK_KSCAN_GPIO_POLLING + default y + +endif diff --git a/app/boards/shields/cradios/Kconfig.shield b/app/boards/shields/cradios/Kconfig.shield new file mode 100644 index 0000000..844d433 --- /dev/null +++ b/app/boards/shields/cradios/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_CRADIOS + def_bool $(shields_list_contains,cradios) diff --git a/app/boards/shields/cradios/cradios.dtsi b/app/boards/shields/cradios/cradios.dtsi new file mode 100644 index 0000000..7c20c00 --- /dev/null +++ b/app/boards/shields/cradios/cradios.dtsi @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + #include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <10>; + rows = <4>; + map = < +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(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(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) + RC(3,4) RC(3,5) RC(3,6) RC(3,7) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + }; + + }; diff --git a/app/boards/shields/cradios/cradios.keymap b/app/boards/shields/cradios/cradios.keymap new file mode 100644 index 0000000..2939224 --- /dev/null +++ b/app/boards/shields/cradios/cradios.keymap @@ -0,0 +1,17 @@ +#include +#include + + +/ { + keymap0: keymap { + compatible = "zmk,keymap"; + + default_layer { + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp DEL &kp RET &kp RET &SPC + }; + }; +}; diff --git a/app/boards/shields/cradios/cradios_left.conf b/app/boards/shields/cradios/cradios_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/cradios/cradios_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradios/cradios_left.overlay b/app/boards/shields/cradios/cradios_left.overlay new file mode 100644 index 0000000..6f53d8b --- /dev/null +++ b/app/boards/shields/cradios/cradios_left.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradios.dtsi" + +kscan_0 { + + input-gpios + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; +}; + +&bt_unpair_combo { + key-positions = <0 38>; +}; + diff --git a/app/boards/shields/cradios/cradios_right.conf b/app/boards/shields/cradios/cradios_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/cradios/cradios_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradios/cradios_right.overlay b/app/boards/shields/cradios/cradios_right.overlay new file mode 100644 index 0000000..f991ef9 --- /dev/null +++ b/app/boards/shields/cradios/cradios_right.overlay @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradios.dtsi" + +&default_transform { + col-offset = <5>; +}; + + &kscan0 { + input-gpios + + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; +}; + +&bt_unpair_combo { + key-positions = <0 38>; +}; + diff --git a/app/boards/shields/cradios/default.keymap b/app/boards/shields/cradios/default.keymap new file mode 100644 index 0000000..0821005 --- /dev/null +++ b/app/boards/shields/cradios/default.keymap @@ -0,0 +1,19 @@ +#include +#include + + +/ { + keymap0: keymap { + compatible = "zmk,keymap"; + + default_layer { + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp DEL &kp RET &kp RET &kp SPC + + >; + }; + }; +}; -- cgit v1.2.3 From 95bb220702121756a1f7458dcf549bd3c9187216 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 3 Sep 2020 14:46:54 +0100 Subject: now compiles, not work, baby steps --- app/boards/shields/cradios/cradios.dtsi | 11 ++++++----- app/boards/shields/cradios/cradios.keymap | 13 +++++++------ app/boards/shields/cradios/cradios_left.overlay | 7 +++---- app/boards/shields/cradios/cradios_right.overlay | 9 +++------ 4 files changed, 19 insertions(+), 21 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradios/cradios.dtsi b/app/boards/shields/cradios/cradios.dtsi index 7c20c00..f5ebb96 100644 --- a/app/boards/shields/cradios/cradios.dtsi +++ b/app/boards/shields/cradios/cradios.dtsi @@ -14,18 +14,19 @@ default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; - columns = <10>; - rows = <4>; + columns = <34>; + rows = <1>; map = < 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(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(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) RC(2,10) - RC(3,4) RC(3,5) RC(3,6) RC(3,7) +RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,15) RC(0,16) RC(0,17) RC(0,18) RC(0,19) RC(0,20) +RC(0,21) RC(0,22) RC(0,23) RC(0,24) RC(0,25) RC(0,26) RC(0,27) RC(0,28) RC(0,29) RC(0,30) +RC(0,31) RC(0,32) RC(0,33) RC(0,34) >; }; kscan0: kscan { compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; }; }; diff --git a/app/boards/shields/cradios/cradios.keymap b/app/boards/shields/cradios/cradios.keymap index 2939224..3da61b7 100644 --- a/app/boards/shields/cradios/cradios.keymap +++ b/app/boards/shields/cradios/cradios.keymap @@ -3,15 +3,16 @@ / { - keymap0: keymap { - compatible = "zmk,keymap"; + keymap { + compatible = "zmk,keymap"; - default_layer { + default_layer { 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 SCLN - &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp DEL &kp RET &kp RET &SPC + &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp 3 &kp 4 &kp 2 &kp 1 + >; }; }; }; diff --git a/app/boards/shields/cradios/cradios_left.overlay b/app/boards/shields/cradios/cradios_left.overlay index 6f53d8b..3c3e986 100644 --- a/app/boards/shields/cradios/cradios_left.overlay +++ b/app/boards/shields/cradios/cradios_left.overlay @@ -5,7 +5,8 @@ */ #include "cradios.dtsi" -kscan_0 { + +&kscan0 { input-gpios = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> @@ -28,7 +29,5 @@ kscan_0 { ; }; -&bt_unpair_combo { - key-positions = <0 38>; -}; + diff --git a/app/boards/shields/cradios/cradios_right.overlay b/app/boards/shields/cradios/cradios_right.overlay index f991ef9..7b47924 100644 --- a/app/boards/shields/cradios/cradios_right.overlay +++ b/app/boards/shields/cradios/cradios_right.overlay @@ -6,12 +6,11 @@ #include "cradios.dtsi" &default_transform { - col-offset = <5>; + col-offset = <17>; }; - &kscan0 { +&kscan0 { input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> @@ -32,7 +31,5 @@ ; }; -&bt_unpair_combo { - key-positions = <0 38>; -}; + -- cgit v1.2.3 From 8bad40282b89859766cd28949b48fe34c24371fe Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 3 Sep 2020 22:02:25 +0100 Subject: actually working --- app/boards/shields/cradios/Kconfig.defconfig | 4 ++-- app/boards/shields/cradios/cradios.dtsi | 10 +++++----- app/boards/shields/cradios/cradios.keymap | 2 +- app/boards/shields/cradios/cradios_left.overlay | 3 +-- app/boards/shields/cradios/cradios_right.overlay | 5 ++--- 5 files changed, 11 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradios/Kconfig.defconfig b/app/boards/shields/cradios/Kconfig.defconfig index 0aca38f..5b9ca9a 100644 --- a/app/boards/shields/cradios/Kconfig.defconfig +++ b/app/boards/shields/cradios/Kconfig.defconfig @@ -1,5 +1,5 @@ -if SHIELD_CRADIOS + config ZMK_KEYBOARD_NAME default "cradios" @@ -11,4 +11,4 @@ config ZMK_KEYBOARD_NAME config ZMK_KSCAN_GPIO_POLLING default y -endif + diff --git a/app/boards/shields/cradios/cradios.dtsi b/app/boards/shields/cradios/cradios.dtsi index f5ebb96..95b4f27 100644 --- a/app/boards/shields/cradios/cradios.dtsi +++ b/app/boards/shields/cradios/cradios.dtsi @@ -17,11 +17,11 @@ columns = <34>; rows = <1>; map = < -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(0,15) RC(0,16) RC(0,17) RC(0,18) RC(0,19) RC(0,20) -RC(0,21) RC(0,22) RC(0,23) RC(0,24) RC(0,25) RC(0,26) RC(0,27) RC(0,28) RC(0,29) RC(0,30) -RC(0,31) RC(0,32) RC(0,33) RC(0,34) - >; +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,17) RC(0,18) RC(0,19) RC(0,20) RC(0,21) +RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,22) RC(0,23) RC(0,24) RC(0,25) RC(0,26) +RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,27) RC(0,28) RC(0,29) RC(0,30) RC(0,31) +RC(0,15) RC(0,16) RC(0,32) RC(0,33) +>; }; kscan0: kscan { diff --git a/app/boards/shields/cradios/cradios.keymap b/app/boards/shields/cradios/cradios.keymap index 3da61b7..c46468d 100644 --- a/app/boards/shields/cradios/cradios.keymap +++ b/app/boards/shields/cradios/cradios.keymap @@ -11,7 +11,7 @@ &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 SCLN &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp 3 &kp 4 &kp 2 &kp 1 + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 >; }; }; diff --git a/app/boards/shields/cradios/cradios_left.overlay b/app/boards/shields/cradios/cradios_left.overlay index 3c3e986..ab5a874 100644 --- a/app/boards/shields/cradios/cradios_left.overlay +++ b/app/boards/shields/cradios/cradios_left.overlay @@ -7,9 +7,8 @@ &kscan0 { - input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> diff --git a/app/boards/shields/cradios/cradios_right.overlay b/app/boards/shields/cradios/cradios_right.overlay index 7b47924..59a81ba 100644 --- a/app/boards/shields/cradios/cradios_right.overlay +++ b/app/boards/shields/cradios/cradios_right.overlay @@ -8,10 +8,9 @@ &default_transform { col-offset = <17>; }; - &kscan0 { input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + = <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> @@ -27,7 +26,7 @@ , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> ; }; -- cgit v1.2.3 From 64c11f15b0cbc494045b8c2ba06e90e6a878d0ca Mon Sep 17 00:00:00 2001 From: kurtis-lew Date: Mon, 14 Sep 2020 20:19:54 -0700 Subject: Removed Copyright Header causing Parse Error --- app/boards/shields/iris/iris.keymap | 3 --- 1 file changed, 3 deletions(-) (limited to 'app') diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 46b0817..4607adf 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -1,6 +1,3 @@ -# Copyright (c) 2020 Pete Johanson, Kurtis Lew -# SPDX-License-Identifier: MIT - #include #include -- cgit v1.2.3 From d86e571757aef33dd0e9256715752a462b5a60fe Mon Sep 17 00:00:00 2001 From: Kurtis Lew Date: Mon, 14 Sep 2020 20:47:55 -0700 Subject: Update iris.keymap --- app/boards/shields/iris/iris.keymap | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app') diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 4607adf..8765402 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * + * SPDX-License-Identifier: MIT + */ + #include #include -- cgit v1.2.3 From 81bc157f539235ad032fde78b6f6cec7a16d2c39 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Sep 2020 14:31:59 -0500 Subject: Fix underglow not working by default --- app/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/Kconfig b/app/Kconfig index cefae21..cda5c58 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -168,6 +168,10 @@ menuconfig ZMK_RGB_UNDERGLOW if ZMK_RGB_UNDERGLOW +# This default value cuts down on tons of excess .conf files, if you're using GPIO, manually disable this +config SPI + default y + config ZMK_RGB_UNDERGLOW_HUE_STEP int "RGB underglow hue step in degrees of 360" default 10 -- cgit v1.2.3 From 608ae0df6dfe4d75bc98c36f6756dc4d69399109 Mon Sep 17 00:00:00 2001 From: Nick Date: Tue, 15 Sep 2020 14:47:19 -0500 Subject: fix lint with clang-format --- app/src/rgb_underglow.c | 57 +++++++++++++++++++------------------------------ app/src/settings.c | 9 ++------ 2 files changed, 24 insertions(+), 42 deletions(-) (limited to 'app') diff --git a/app/src/rgb_underglow.c b/app/src/rgb_underglow.c index d453755..b371c94 100644 --- a/app/src/rgb_underglow.c +++ b/app/src/rgb_underglow.c @@ -52,9 +52,7 @@ struct led_rgb pixels[STRIP_NUM_PIXELS]; struct rgb_underglow_state state; #if IS_ENABLED(CONFIG_SETTINGS) -static int rgb_settings_set(const char *name, size_t len, - settings_read_cb read_cb, void *cb_arg) -{ +static int rgb_settings_set(const char *name, size_t len, settings_read_cb read_cb, void *cb_arg) { const char *next; int rc; @@ -74,14 +72,10 @@ static int rgb_settings_set(const char *name, size_t len, return -ENOENT; } -struct settings_handler rgb_conf = { - .name = "rgb/underglow", - .h_set = rgb_settings_set -}; +struct settings_handler rgb_conf = {.name = "rgb/underglow", .h_set = rgb_settings_set}; #endif -static struct led_rgb hsb_to_rgb(struct led_hsb hsb) -{ +static struct led_rgb hsb_to_rgb(struct led_hsb hsb) { double r, g, b; u8_t i = hsb.h / 60; @@ -130,20 +124,16 @@ static struct led_rgb hsb_to_rgb(struct led_hsb hsb) return rgb; } -static void zmk_rgb_underglow_off() -{ - for (int i=0; i #include -static int zmk_settings_init(struct device *_arg) -{ - return settings_load(); -} +static int zmk_settings_init(struct device *_arg) { return settings_load(); } -SYS_INIT(zmk_settings_init, - APPLICATION, - CONFIG_APPLICATION_INIT_PRIORITY); +SYS_INIT(zmk_settings_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); -- cgit v1.2.3 From 2855ba75f53554887f6e788736c45b7c818d09ac Mon Sep 17 00:00:00 2001 From: David Barr Date: Sat, 19 Sep 2020 10:55:07 +0100 Subject: Actually really working Ok, both sides work as expected, need to write a keymap. --- app/boards/shields/Kconfig.defconfig | 14 +++++++ app/boards/shields/Kconfig.shield | 5 +++ app/boards/shields/cradios.dtsi | 67 ++++++++++++++++++++++++++++++++ app/boards/shields/cradios.keymap | 18 +++++++++ app/boards/shields/cradios_left.conf | 2 + app/boards/shields/cradios_left.overlay | 15 +++++++ app/boards/shields/cradios_right.conf | 2 + app/boards/shields/cradios_right.overlay | 17 ++++++++ 8 files changed, 140 insertions(+) create mode 100644 app/boards/shields/Kconfig.defconfig create mode 100644 app/boards/shields/Kconfig.shield create mode 100644 app/boards/shields/cradios.dtsi create mode 100644 app/boards/shields/cradios.keymap create mode 100644 app/boards/shields/cradios_left.conf create mode 100644 app/boards/shields/cradios_left.overlay create mode 100644 app/boards/shields/cradios_right.conf create mode 100644 app/boards/shields/cradios_right.overlay (limited to 'app') diff --git a/app/boards/shields/Kconfig.defconfig b/app/boards/shields/Kconfig.defconfig new file mode 100644 index 0000000..5b9ca9a --- /dev/null +++ b/app/boards/shields/Kconfig.defconfig @@ -0,0 +1,14 @@ + + + +config ZMK_KEYBOARD_NAME + default "cradios" + +# Unable to use interrupts as the same pin number is used +# across A & B controllers, and STM32F303CCT6 can't enable +# interrutps for multiple controllers for the same "line" +# for the external interrupts. +config ZMK_KSCAN_GPIO_POLLING + default y + + diff --git a/app/boards/shields/Kconfig.shield b/app/boards/shields/Kconfig.shield new file mode 100644 index 0000000..844d433 --- /dev/null +++ b/app/boards/shields/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_CRADIOS + def_bool $(shields_list_contains,cradios) diff --git a/app/boards/shields/cradios.dtsi b/app/boards/shields/cradios.dtsi new file mode 100644 index 0000000..68d1fc5 --- /dev/null +++ b/app/boards/shields/cradios.dtsi @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + #include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <34>; + rows = <1>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) +RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) +RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) +RC(0,15) RC(0,16) RC(0,33) RC(0,32) +>; + + + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + }; + + + + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; + + + + }; + + + &kscan0 { + input-gpios + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; +}; + + diff --git a/app/boards/shields/cradios.keymap b/app/boards/shields/cradios.keymap new file mode 100644 index 0000000..c46468d --- /dev/null +++ b/app/boards/shields/cradios.keymap @@ -0,0 +1,18 @@ +#include +#include + + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 + >; + }; + }; +}; diff --git a/app/boards/shields/cradios_left.conf b/app/boards/shields/cradios_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/cradios_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradios_left.overlay b/app/boards/shields/cradios_left.overlay new file mode 100644 index 0000000..b0bdc6f --- /dev/null +++ b/app/boards/shields/cradios_left.overlay @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradios.dtsi" + + + + + + +&bt_unpair_combo { + key-positions = <0 16>; +}; diff --git a/app/boards/shields/cradios_right.conf b/app/boards/shields/cradios_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/cradios_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradios_right.overlay b/app/boards/shields/cradios_right.overlay new file mode 100644 index 0000000..ef920ac --- /dev/null +++ b/app/boards/shields/cradios_right.overlay @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradios.dtsi" + +&default_transform { + col-offset = <17>; +}; + + + + +&bt_unpair_combo { + key-positions = <21 32>; +}; -- cgit v1.2.3 From ed5d3646fe7596fb40d0b7505f8062cdac6537be Mon Sep 17 00:00:00 2001 From: David Barr Date: Sat, 19 Sep 2020 10:56:40 +0100 Subject: Add files via upload --- app/boards/shields/cradios/cradios.dtsi | 51 ++++++++++++++++++++---- app/boards/shields/cradios/cradios_left.overlay | 25 ++---------- app/boards/shields/cradios/cradios_right.overlay | 25 ++---------- 3 files changed, 51 insertions(+), 50 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradios/cradios.dtsi b/app/boards/shields/cradios/cradios.dtsi index 95b4f27..68d1fc5 100644 --- a/app/boards/shields/cradios/cradios.dtsi +++ b/app/boards/shields/cradios/cradios.dtsi @@ -10,23 +10,58 @@ zmk,kscan = &kscan0; zmk,matrix_transform = &default_transform; }; - default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <34>; rows = <1>; map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,17) RC(0,18) RC(0,19) RC(0,20) RC(0,21) -RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,22) RC(0,23) RC(0,24) RC(0,25) RC(0,26) -RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,27) RC(0,28) RC(0,29) RC(0,30) RC(0,31) -RC(0,15) RC(0,16) RC(0,32) RC(0,33) +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) +RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) +RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) +RC(0,15) RC(0,16) RC(0,33) RC(0,32) >; + + }; - kscan0: kscan { - compatible = "zmk,kscan-gpio-direct"; - label = "KSCAN"; + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + }; + + + + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; }; + + }; + + + &kscan0 { + input-gpios + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; +}; + + diff --git a/app/boards/shields/cradios/cradios_left.overlay b/app/boards/shields/cradios/cradios_left.overlay index ab5a874..b0bdc6f 100644 --- a/app/boards/shields/cradios/cradios_left.overlay +++ b/app/boards/shields/cradios/cradios_left.overlay @@ -6,27 +6,10 @@ #include "cradios.dtsi" -&kscan0 { - input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - ; -}; + +&bt_unpair_combo { + key-positions = <0 16>; +}; diff --git a/app/boards/shields/cradios/cradios_right.overlay b/app/boards/shields/cradios/cradios_right.overlay index 59a81ba..ef920ac 100644 --- a/app/boards/shields/cradios/cradios_right.overlay +++ b/app/boards/shields/cradios/cradios_right.overlay @@ -8,27 +8,10 @@ &default_transform { col-offset = <17>; }; -&kscan0 { - input-gpios - = <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - ; -}; + +&bt_unpair_combo { + key-positions = <21 32>; +}; -- cgit v1.2.3 From 90bfe6026da99f352af750403880fb55defa1b42 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 21 Sep 2020 09:49:56 -0400 Subject: fix(boards): Flash Planck with `dfu-util`. --- app/boards/arm/planck/board.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/arm/planck/board.cmake b/app/boards/arm/planck/board.cmake index 4843c41..772796d 100644 --- a/app/boards/arm/planck/board.cmake +++ b/app/boards/arm/planck/board.cmake @@ -1,6 +1,7 @@ # SPDX-License-Identifier: MIT +board_runner_args(dfu-util "--pid=0483:df11" "--alt=0" "--dfuse") board_runner_args(jlink "--device=STM32F303VC" "--speed=4000") -include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/dfu-util.board.cmake) include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) -- cgit v1.2.3 From c044fe853275a6322834bfdeaf61b9f62becf085 Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Mon, 21 Sep 2020 22:29:54 -0700 Subject: Add RoMac plus v4 support on nice nano v1 --- app/boards/shields/romac_plus/Kconfig.defconfig | 9 ++++ app/boards/shields/romac_plus/Kconfig.shield | 5 ++ .../shields/romac_plus/boards/nice_nano.overlay | 28 ++++++++++ app/boards/shields/romac_plus/romac_plus.conf | 3 ++ app/boards/shields/romac_plus/romac_plus.dtsi | 61 ++++++++++++++++++++++ app/boards/shields/romac_plus/romac_plus.keymap | 48 +++++++++++++++++ app/boards/shields/romac_plus/romac_plus.overlay | 37 +++++++++++++ 7 files changed, 191 insertions(+) create mode 100644 app/boards/shields/romac_plus/Kconfig.defconfig create mode 100644 app/boards/shields/romac_plus/Kconfig.shield create mode 100644 app/boards/shields/romac_plus/boards/nice_nano.overlay create mode 100644 app/boards/shields/romac_plus/romac_plus.conf create mode 100644 app/boards/shields/romac_plus/romac_plus.dtsi create mode 100644 app/boards/shields/romac_plus/romac_plus.keymap create mode 100644 app/boards/shields/romac_plus/romac_plus.overlay (limited to 'app') diff --git a/app/boards/shields/romac_plus/Kconfig.defconfig b/app/boards/shields/romac_plus/Kconfig.defconfig new file mode 100644 index 0000000..45b15b8 --- /dev/null +++ b/app/boards/shields/romac_plus/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2020 Pete Johanson, Richard Jones +# SPDX-License-Identifier: MIT + +if SHIELD_ROMAC_PLUS + +config ZMK_KEYBOARD_NAME + default "RoMac_plus-v4" + +endif \ No newline at end of file diff --git a/app/boards/shields/romac_plus/Kconfig.shield b/app/boards/shields/romac_plus/Kconfig.shield new file mode 100644 index 0000000..c89ef02 --- /dev/null +++ b/app/boards/shields/romac_plus/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johanson, Richard Jones +# SPDX-License-Identifier: MIT + +config SHIELD_ROMAC_PLUS + def_bool $(shields_list_contains,romac_plus) diff --git a/app/boards/shields/romac_plus/boards/nice_nano.overlay b/app/boards/shields/romac_plus/boards/nice_nano.overlay new file mode 100644 index 0000000..a8dafa2 --- /dev/null +++ b/app/boards/shields/romac_plus/boards/nice_nano.overlay @@ -0,0 +1,28 @@ +&spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "WS2812"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <10>; /* arbitrary; change at will */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.conf b/app/boards/shields/romac_plus/romac_plus.conf new file mode 100644 index 0000000..8ec9fa9 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.conf @@ -0,0 +1,3 @@ +# Uncomment to enable encoder +CONFIG_EC11=y +CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi new file mode 100644 index 0000000..3895f86 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <3>; + rows = <4>; + + map = < +RC(0,0) RC(0,1) RC(0,2) +RC(1,0) RC(1,1) RC(1,2) +RC(2,0) RC(2,1) RC(2,2) +RC(3,0) RC(3,1) RC(3,2) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + left_encoder: encoder_left { + compatible = "alps,ec11"; + label = "LEFT_ENCODER"; + a-gpios = <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + b-gpios = <&pro_micro_d 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>; + resolution = <4>; + status = "disabled"; + }; + + sensors { + compatible = "zmk,keymap-sensors"; + sensors = <&left_encoder>; + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; + + // TODO: per-key RGB node(s)? +}; \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.keymap b/app/boards/shields/romac_plus/romac_plus.keymap new file mode 100644 index 0000000..77485dc --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.keymap @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2020 Pete Johanson, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------- +// | 7 | 8 | 9 | +// | 4 | 5 | 6 | +// | 1 | 2 | 3 | +// | MO(1) | 0 | . | +// ---------------------- + bindings = < + &kp NUM_7 &kp NUM_8 &kp NUM_9 + &kp NUM_4 &kp NUM_5 &kp NUM_6 + &kp NUM_1 &kp NUM_2 &kp NUM_3 + &cp M_PLAY &kp NUM_0 &kp DOT + >; + + sensor-bindings = <&inc_dec_cp M_NEXT M_PREV>; + }; + + // nav_layer { +// ----------------------- +// | _ | HOME | PGUP | +// | _ | END | PGDN | +// | _ | _ | _ | +// | _ | _ | RET | +// ----------------------- + // bindings = < + // &trans &kp HOME &kp PGUP + // &trans &kp END &kp PGDN + // &trans &trans &trans .0 + // &trans &trans &kp RET + // >; + + // sensor-bindings = <&inc_dec_kp A B>; + // }; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.overlay b/app/boards/shields/romac_plus/romac_plus.overlay new file mode 100644 index 0000000..23ef3e6 --- /dev/null +++ b/app/boards/shields/romac_plus/romac_plus.overlay @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2020 Pete Johanson, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + +#include "romac_plus.dtsi" + +/ { + chosen { + zmk,kscan = &kscan0; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; + + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + key-positions = <0 11>; + }; + +}; + +&left_encoder { + status = "okay"; +}; \ No newline at end of file -- cgit v1.2.3 From f1fd71c231ab75d2e2563d7b40cb1460dca0eed7 Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 12:39:06 -0700 Subject: Disabled ec11 since it's an optional configuration --- app/boards/shields/romac_plus/romac_plus.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/romac_plus.conf b/app/boards/shields/romac_plus/romac_plus.conf index 8ec9fa9..cff5b30 100644 --- a/app/boards/shields/romac_plus/romac_plus.conf +++ b/app/boards/shields/romac_plus/romac_plus.conf @@ -1,3 +1,3 @@ # Uncomment to enable encoder -CONFIG_EC11=y -CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y \ No newline at end of file +#CONFIG_EC11=y +#CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y \ No newline at end of file -- cgit v1.2.3 From 31af9646e6d1316cd960d8cff98c524c2f25934a Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Wed, 23 Sep 2020 16:05:29 -0400 Subject: Adding kconfig flag for enabling matrix polling (vs interrupts) on the matrix gpio driver. --- app/drivers/zephyr/Kconfig | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index 0237846..a5b6d20 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -9,6 +9,10 @@ config ZMK_KSCAN_GPIO_POLLING bool "Poll for key event triggers instead of using interrupts" default n +config ZMK_KSCAN_GPIO_MATRIX_POLLING + bool "Poll for key event triggers instead of using interrupts on matrix boards." + default n + endif config ZMK_KSCAN_INIT_PRIORITY -- cgit v1.2.3 From 4c092044ce22f0c60c3bf0ef860ecc543328d5bf Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 16:21:42 -0700 Subject: Adopt single authors headers --- app/boards/shields/romac_plus/Kconfig.defconfig | 2 +- app/boards/shields/romac_plus/Kconfig.shield | 2 +- app/boards/shields/romac_plus/romac_plus.conf | 3 +++ app/boards/shields/romac_plus/romac_plus.dtsi | 2 +- app/boards/shields/romac_plus/romac_plus.keymap | 2 +- app/boards/shields/romac_plus/romac_plus.overlay | 2 +- 6 files changed, 8 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/Kconfig.defconfig b/app/boards/shields/romac_plus/Kconfig.defconfig index 45b15b8..1d04082 100644 --- a/app/boards/shields/romac_plus/Kconfig.defconfig +++ b/app/boards/shields/romac_plus/Kconfig.defconfig @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johanson, Richard Jones +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT if SHIELD_ROMAC_PLUS diff --git a/app/boards/shields/romac_plus/Kconfig.shield b/app/boards/shields/romac_plus/Kconfig.shield index c89ef02..a7c7c61 100644 --- a/app/boards/shields/romac_plus/Kconfig.shield +++ b/app/boards/shields/romac_plus/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johanson, Richard Jones +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config SHIELD_ROMAC_PLUS diff --git a/app/boards/shields/romac_plus/romac_plus.conf b/app/boards/shields/romac_plus/romac_plus.conf index cff5b30..d784dc4 100644 --- a/app/boards/shields/romac_plus/romac_plus.conf +++ b/app/boards/shields/romac_plus/romac_plus.conf @@ -1,3 +1,6 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + # Uncomment to enable encoder #CONFIG_EC11=y #CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi index 3895f86..be05618 100644 --- a/app/boards/shields/romac_plus/romac_plus.dtsi +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/romac_plus/romac_plus.keymap b/app/boards/shields/romac_plus/romac_plus.keymap index 77485dc..947b20a 100644 --- a/app/boards/shields/romac_plus/romac_plus.keymap +++ b/app/boards/shields/romac_plus/romac_plus.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Richard Jones + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/romac_plus/romac_plus.overlay b/app/boards/shields/romac_plus/romac_plus.overlay index 23ef3e6..7b57001 100644 --- a/app/boards/shields/romac_plus/romac_plus.overlay +++ b/app/boards/shields/romac_plus/romac_plus.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Richard Jones + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 0ce36865b2026c8739c01cebd3031180aa0f3b1f Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 16:23:54 -0700 Subject: Update keyboard name to be more user friendly --- app/boards/shields/romac_plus/Kconfig.defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/Kconfig.defconfig b/app/boards/shields/romac_plus/Kconfig.defconfig index 1d04082..c4efdb9 100644 --- a/app/boards/shields/romac_plus/Kconfig.defconfig +++ b/app/boards/shields/romac_plus/Kconfig.defconfig @@ -4,6 +4,6 @@ if SHIELD_ROMAC_PLUS config ZMK_KEYBOARD_NAME - default "RoMac_plus-v4" + default "RoMac+ v4" endif \ No newline at end of file -- cgit v1.2.3 From 9fffebd5dac13d0a57f6f6aaff0654a2bd0986c1 Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 16:31:02 -0700 Subject: Adopt new BT unpairing standards --- app/boards/shields/romac_plus/romac_plus.dtsi | 3 --- app/boards/shields/romac_plus/romac_plus.keymap | 5 +++-- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi index be05618..d04b214 100644 --- a/app/boards/shields/romac_plus/romac_plus.dtsi +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -53,9 +53,6 @@ RC(3,0) RC(3,1) RC(3,2) sensors = <&left_encoder>; }; - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; // TODO: per-key RGB node(s)? }; \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.keymap b/app/boards/shields/romac_plus/romac_plus.keymap index 947b20a..3fa9441 100644 --- a/app/boards/shields/romac_plus/romac_plus.keymap +++ b/app/boards/shields/romac_plus/romac_plus.keymap @@ -5,6 +5,7 @@ */ #include +#include #include / { @@ -30,13 +31,13 @@ // nav_layer { // ----------------------- -// | _ | HOME | PGUP | +// | BT_CLR | HOME | PGUP | // | _ | END | PGDN | // | _ | _ | _ | // | _ | _ | RET | // ----------------------- // bindings = < - // &trans &kp HOME &kp PGUP + // &bt BT_CLR &kp HOME &kp PGUP // &trans &kp END &kp PGDN // &trans &trans &trans .0 // &trans &trans &kp RET -- cgit v1.2.3 From 641524b1b9564fd2b433b9bc430736fb3205a3c5 Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 16:37:46 -0700 Subject: Update Keymap legends for consistency --- app/boards/shields/romac_plus/romac_plus.dtsi | 2 -- app/boards/shields/romac_plus/romac_plus.keymap | 44 ++++++++++++------------- 2 files changed, 22 insertions(+), 24 deletions(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/romac_plus.dtsi b/app/boards/shields/romac_plus/romac_plus.dtsi index d04b214..9b148ca 100644 --- a/app/boards/shields/romac_plus/romac_plus.dtsi +++ b/app/boards/shields/romac_plus/romac_plus.dtsi @@ -36,7 +36,6 @@ RC(3,0) RC(3,1) RC(3,2) , <&pro_micro_d 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> , <&pro_micro_d 1 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> ; - }; left_encoder: encoder_left { @@ -52,7 +51,6 @@ RC(3,0) RC(3,1) RC(3,2) compatible = "zmk,keymap-sensors"; sensors = <&left_encoder>; }; - // TODO: per-key RGB node(s)? }; \ No newline at end of file diff --git a/app/boards/shields/romac_plus/romac_plus.keymap b/app/boards/shields/romac_plus/romac_plus.keymap index 3fa9441..d8d1f78 100644 --- a/app/boards/shields/romac_plus/romac_plus.keymap +++ b/app/boards/shields/romac_plus/romac_plus.keymap @@ -13,37 +13,37 @@ compatible = "zmk,keymap"; default_layer { -// ------------------- -// | 7 | 8 | 9 | -// | 4 | 5 | 6 | -// | 1 | 2 | 3 | -// | MO(1) | 0 | . | -// ---------------------- +// -------------------------- +// | 7 | 8 | 9 | +// | 4 | 5 | 6 | +// | 1 | 2 | 3 | +// | M_PLAY | 0 | MO(1) | +// -------------------------- bindings = < &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_1 &kp NUM_2 &kp NUM_3 - &cp M_PLAY &kp NUM_0 &kp DOT + &cp M_PLAY &kp NUM_0 &mo 1 >; sensor-bindings = <&inc_dec_cp M_NEXT M_PREV>; }; - // nav_layer { -// ----------------------- -// | BT_CLR | HOME | PGUP | -// | _ | END | PGDN | -// | _ | _ | _ | -// | _ | _ | RET | -// ----------------------- - // bindings = < - // &bt BT_CLR &kp HOME &kp PGUP - // &trans &kp END &kp PGDN - // &trans &trans &trans .0 - // &trans &trans &kp RET - // >; + nav_layer { +// -------------------------- +// | BT_CLR | HOME | PGUP | +// | _ | END | PGDN | +// | _ | _ | _ | +// | _ | _ | _ | +// -------------------------- + bindings = < + &bt BT_CLR &kp HOME &kp PGUP + &trans &kp END &kp PGDN + &trans &trans &trans + &trans &trans &trans + >; - // sensor-bindings = <&inc_dec_kp A B>; - // }; + sensor-bindings = <&inc_dec_kp A B>; + }; }; }; \ No newline at end of file -- cgit v1.2.3 From 8e92ae30893e620ca1c615637a3bcf3f05088225 Mon Sep 17 00:00:00 2001 From: Kristoffer Onias Date: Wed, 23 Sep 2020 17:49:13 -0700 Subject: Remove bt_unpair_combo from romac_plus.overlay --- app/boards/shields/romac_plus/romac_plus.overlay | 6 ------ 1 file changed, 6 deletions(-) (limited to 'app') diff --git a/app/boards/shields/romac_plus/romac_plus.overlay b/app/boards/shields/romac_plus/romac_plus.overlay index 7b57001..8643034 100644 --- a/app/boards/shields/romac_plus/romac_plus.overlay +++ b/app/boards/shields/romac_plus/romac_plus.overlay @@ -22,12 +22,6 @@ , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> ; - - }; - - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - key-positions = <0 11>; }; }; -- cgit v1.2.3 From 53425aa3c4719908eb8e6ed23057188f4e502237 Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Thu, 24 Sep 2020 07:55:32 -0400 Subject: Rename kscan direct wired driver polling kscan flag in preparationfor addition of new matrix driver flag that enables polling. --- app/drivers/zephyr/Kconfig | 4 ++-- app/drivers/zephyr/kscan_gpio_direct.c | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index a5b6d20..0bf6c0a 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -5,11 +5,11 @@ config ZMK_KSCAN_GPIO_DRIVER if ZMK_KSCAN_GPIO_DRIVER -config ZMK_KSCAN_GPIO_POLLING +config ZMK_KSCAN_MATRIX_POLLING bool "Poll for key event triggers instead of using interrupts" default n -config ZMK_KSCAN_GPIO_MATRIX_POLLING +config ZMK_KSCAN_DIRECT_POLLING bool "Poll for key event triggers instead of using interrupts on matrix boards." default n diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 1e5ab59..7ba3399 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -33,9 +33,9 @@ struct kscan_gpio_config { }; struct kscan_gpio_data { -#if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if defined(ZMK_KSCAN_DIRECT_POLLING) struct k_timer poll_timer; -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ kscan_callback_t callback; union work_reference work; struct device *dev; @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi return cfg->inputs; } -#if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if !defined(ZMK_KSCAN_DIRECT_POLLING) struct kscan_gpio_irq_callback { union work_reference *work; @@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call } } -#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#else /* !defined(ZMK_KSCAN_DIRECT_POLLING) */ static void kscan_gpio_timer_handler(struct k_timer *timer) { struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); @@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { return 0; } -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) { struct kscan_gpio_data *data = dev->driver_data; @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_0(ZMK_KSCAN_DIRECT_POLLING, \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + ZMK_KSCAN_DIRECT_POLLING, \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_1(ZMK_KSCAN_DIRECT_POLLING, \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ @@ -227,4 +227,4 @@ static const struct kscan_driver_api gpio_driver_api = { DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ \ No newline at end of file +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ -- cgit v1.2.3 From 5c4705d465d4b5f742299cf77f549186c9cc7933 Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Thu, 24 Sep 2020 14:30:47 -0400 Subject: Add new matrix scan flag and implementation in the gpio matrix driver. --- app/boards/arm/planck/Kconfig.defconfig | 3 + .../shields/clueboard_california/Kconfig.defconfig | 2 +- app/drivers/zephyr/Kconfig | 6 +- app/drivers/zephyr/kscan_gpio_matrix.c | 133 ++++++++++++++------- 4 files changed, 95 insertions(+), 49 deletions(-) (limited to 'app') diff --git a/app/boards/arm/planck/Kconfig.defconfig b/app/boards/arm/planck/Kconfig.defconfig index 6f5bf52..913c1c1 100644 --- a/app/boards/arm/planck/Kconfig.defconfig +++ b/app/boards/arm/planck/Kconfig.defconfig @@ -11,4 +11,7 @@ config ZMK_KEYBOARD_NAME config ZMK_USB default y +config ZMK_KSCAN_MATRIX_POLLING + default y + endif # BOARD_PLANCK_REV6 diff --git a/app/boards/shields/clueboard_california/Kconfig.defconfig b/app/boards/shields/clueboard_california/Kconfig.defconfig index 2408f9f..e101ea7 100644 --- a/app/boards/shields/clueboard_california/Kconfig.defconfig +++ b/app/boards/shields/clueboard_california/Kconfig.defconfig @@ -8,7 +8,7 @@ config ZMK_KEYBOARD_NAME # across A & B controllers, and STM32F303CCT6 can't enable # interrutps for multiple controllers for the same "line" # for the external interrupts. -config ZMK_KSCAN_GPIO_POLLING +config ZMK_KSCAN_DIRECT_POLLING default y endif diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index 0bf6c0a..c5ff3a6 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -6,11 +6,11 @@ config ZMK_KSCAN_GPIO_DRIVER if ZMK_KSCAN_GPIO_DRIVER config ZMK_KSCAN_MATRIX_POLLING - bool "Poll for key event triggers instead of using interrupts" - default n + bool "Poll for key event triggers instead of using interrupts on matrix boards." + default y config ZMK_KSCAN_DIRECT_POLLING - bool "Poll for key event triggers instead of using interrupts on matrix boards." + bool "Poll for key event triggers instead of using interrupts on direct wired boards." default n endif diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 634f694..46616ff 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,6 +31,8 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) +#if !defined(ZMK_KSCAN_MATRIX_POLLING) +/* Set up for interrupt-based input. */ static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { @@ -48,6 +50,61 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; } + +#define KSCAN_GPIO_MATRIX_ENABLE(n) \ +static int kscan_gpio_matrix_enable(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ +} \ + +#define KSCAN_GPIO_MATRIX_DISABLE(n) \ +static int kscan_gpio_matrix_disable(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DISABLE); \ +} \ + +#define KSCAN_GPIO_CALLBACK_HANDLER(n) \ +static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ + gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit(data->work, \ + K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ +} \ + +#else /* !defined(ZMK_KSCAN_MATRIX_POLLING) */ +/* Set up for matrix scanning. */ + +static void kscan_gpio_timer_handler(struct k_timer *timer) { + struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); + + k_work_submit(&data->work.direct); +} + +#define KSCAN_GPIO_MATRIX_ENABLE(n) \ +static int kscan_gpio_matrix_enable(struct device *dev) { \ + struct kscan_gpio_data *data = dev->driver_data; \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ + return 0; \ +} \ + +#define KSCAN_GPIO_MATRIX_DISABLE(n) \ +static int kscan_gpio_matrix_disable(struct device *dev) { \ + struct kscan_gpio_data *data = dev->driver_data; \ + k_timer_stop(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ + return 0; \ +} \ + +#define KSCAN_GPIO_MATRIX_ENABLE(n) \ + + +#endif /* !defined(ZMK_KSCAN_MATRIX_POLLING) */ + #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_OUTPUT_LEN(n) \ @@ -58,17 +115,22 @@ static int kscan_gpio_config_interrupts(struct device **devices, (INST_MATRIX_ROWS(n))) #define GPIO_INST_INIT(n) \ - struct kscan_gpio_irq_callback_##n { \ - struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ - struct gpio_callback callback; \ - }; \ - static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ + COND_CODE_0( \ + ZMK_KSCAN_MATRIX_POLLING, \ + (struct kscan_gpio_irq_callback_##n { \ + struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ + struct gpio_callback callback; \ + }; \ + static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ + KSCAN_GPIO_ENTABLE_INTERRUPTS(n)), \ + ()) \ struct kscan_gpio_config_##n { \ struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \ struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \ }; \ struct kscan_gpio_data_##n { \ - kscan_callback_t callback; \ + COND_CODE_1(ZMK_KSCAN_MATRIX_POLLING, \ + (struct k_timer poll_timer;),(kscan_callback_t callback;)) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -96,16 +158,6 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DISABLE); \ - } \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ @@ -128,7 +180,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - kscan_gpio_disable_interrupts_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_disable_interrupts_##n(dev);), ()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -146,7 +198,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Set all our outputs as active again, then re-enable interrupts, */ \ /* so we can trigger interrupts again for future press/release */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - kscan_gpio_enable_interrupts_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -172,16 +224,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ - gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit(data->work, \ - K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ - } \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (KSCAN_GPIO_CALLBACK_HANDLER(n)), ()) \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \ @@ -192,13 +235,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, data->callback = callback; \ return 0; \ }; \ - static int kscan_gpio_enable_##n(struct device *dev) { \ - int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { \ - return err; \ - } \ - return kscan_gpio_read_##n(dev); \ - }; \ + KSCAN_GPIO_MATRIX_ENABLE(n) \ + KSCAN_GPIO_MATRIX_DISABLE(n) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -215,16 +253,21 @@ static int kscan_gpio_config_interrupts(struct device **devices, LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ return err; \ } \ - irq_callbacks_##n[i].work = &data->work; \ - gpio_init_callback(&irq_callbacks_##n[i].callback, \ - kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ - err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ - if (err) { \ - LOG_ERR("Error adding the callback to the column device"); \ - return err; \ - } \ + COND_CODE_0( \ + ZMK_KSCAN_MATRIX_POLLING, \ + (irq_callbacks_##n[i].work = &data->work; \ + gpio_init_callback(&irq_callbacks_##n[i].callback, \ + kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ + err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ + if (err) { \ + LOG_ERR("Error adding the callback to the column device"); \ + return err; \ + }), \ + ()) \ } \ struct device **output_devices = kscan_gpio_output_devices_##n(dev); \ + COND_CODE_1(ZMK_KSCAN_MATRIX_POLLING, \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ output_devices[o] = device_get_binding(out_cfg->label); \ @@ -247,8 +290,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ static const struct kscan_driver_api gpio_driver_api_##n = { \ .config = kscan_gpio_configure_##n, \ - .enable_callback = kscan_gpio_enable_##n, \ - .disable_callback = kscan_gpio_disable_interrupts_##n, \ + .enable_callback = kscan_gpio_matrix_enable, \ + .disable_callback = kscan_gpio_matrix_disable, \ }; \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ -- cgit v1.2.3 From 966830562182bca5645ec5c7f44c1e7390408bdd Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Thu, 24 Sep 2020 17:35:51 -0400 Subject: Restore original matrix driver to correct implementation errors. --- app/drivers/zephyr/kscan_gpio_matrix.c | 133 +++++++++++---------------------- 1 file changed, 45 insertions(+), 88 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 46616ff..634f694 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,8 +31,6 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) -#if !defined(ZMK_KSCAN_MATRIX_POLLING) -/* Set up for interrupt-based input. */ static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { @@ -50,61 +48,6 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; } - -#define KSCAN_GPIO_MATRIX_ENABLE(n) \ -static int kscan_gpio_matrix_enable(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ -} \ - -#define KSCAN_GPIO_MATRIX_DISABLE(n) \ -static int kscan_gpio_matrix_disable(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DISABLE); \ -} \ - -#define KSCAN_GPIO_CALLBACK_HANDLER(n) \ -static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ - gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit(data->work, \ - K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ -} \ - -#else /* !defined(ZMK_KSCAN_MATRIX_POLLING) */ -/* Set up for matrix scanning. */ - -static void kscan_gpio_timer_handler(struct k_timer *timer) { - struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); - - k_work_submit(&data->work.direct); -} - -#define KSCAN_GPIO_MATRIX_ENABLE(n) \ -static int kscan_gpio_matrix_enable(struct device *dev) { \ - struct kscan_gpio_data *data = dev->driver_data; \ - k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ - return 0; \ -} \ - -#define KSCAN_GPIO_MATRIX_DISABLE(n) \ -static int kscan_gpio_matrix_disable(struct device *dev) { \ - struct kscan_gpio_data *data = dev->driver_data; \ - k_timer_stop(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ - return 0; \ -} \ - -#define KSCAN_GPIO_MATRIX_ENABLE(n) \ - - -#endif /* !defined(ZMK_KSCAN_MATRIX_POLLING) */ - #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_OUTPUT_LEN(n) \ @@ -115,22 +58,17 @@ static int kscan_gpio_matrix_disable(struct device *dev) { (INST_MATRIX_ROWS(n))) #define GPIO_INST_INIT(n) \ - COND_CODE_0( \ - ZMK_KSCAN_MATRIX_POLLING, \ - (struct kscan_gpio_irq_callback_##n { \ - struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ - struct gpio_callback callback; \ - }; \ - static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ - KSCAN_GPIO_ENTABLE_INTERRUPTS(n)), \ - ()) \ + struct kscan_gpio_irq_callback_##n { \ + struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ + struct gpio_callback callback; \ + }; \ + static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ struct kscan_gpio_config_##n { \ struct kscan_gpio_item_config rows[INST_MATRIX_ROWS(n)]; \ struct kscan_gpio_item_config cols[INST_MATRIX_COLS(n)]; \ }; \ struct kscan_gpio_data_##n { \ - COND_CODE_1(ZMK_KSCAN_MATRIX_POLLING, \ - (struct k_timer poll_timer;),(kscan_callback_t callback;)) \ + kscan_callback_t callback; \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -158,6 +96,16 @@ static int kscan_gpio_matrix_disable(struct device *dev) { return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ + static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ + } \ + static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ + GPIO_INT_DISABLE); \ + } \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ @@ -180,7 +128,7 @@ static int kscan_gpio_matrix_disable(struct device *dev) { /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_disable_interrupts_##n(dev);), ()) \ + kscan_gpio_disable_interrupts_##n(dev); \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -198,7 +146,7 @@ static int kscan_gpio_matrix_disable(struct device *dev) { /* Set all our outputs as active again, then re-enable interrupts, */ \ /* so we can trigger interrupts again for future press/release */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_enable_interrupts_##n(dev);), ()) \ + kscan_gpio_enable_interrupts_##n(dev); \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -224,7 +172,16 @@ static int kscan_gpio_matrix_disable(struct device *dev) { struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (KSCAN_GPIO_CALLBACK_HANDLER(n)), ()) \ + static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ + gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit(data->work, \ + K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + } \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \ @@ -235,8 +192,13 @@ static int kscan_gpio_matrix_disable(struct device *dev) { data->callback = callback; \ return 0; \ }; \ - KSCAN_GPIO_MATRIX_ENABLE(n) \ - KSCAN_GPIO_MATRIX_DISABLE(n) \ + static int kscan_gpio_enable_##n(struct device *dev) { \ + int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { \ + return err; \ + } \ + return kscan_gpio_read_##n(dev); \ + }; \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -253,21 +215,16 @@ static int kscan_gpio_matrix_disable(struct device *dev) { LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ return err; \ } \ - COND_CODE_0( \ - ZMK_KSCAN_MATRIX_POLLING, \ - (irq_callbacks_##n[i].work = &data->work; \ - gpio_init_callback(&irq_callbacks_##n[i].callback, \ - kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ - err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ - if (err) { \ - LOG_ERR("Error adding the callback to the column device"); \ - return err; \ - }), \ - ()) \ + irq_callbacks_##n[i].work = &data->work; \ + gpio_init_callback(&irq_callbacks_##n[i].callback, \ + kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ + err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ + if (err) { \ + LOG_ERR("Error adding the callback to the column device"); \ + return err; \ + } \ } \ struct device **output_devices = kscan_gpio_output_devices_##n(dev); \ - COND_CODE_1(ZMK_KSCAN_MATRIX_POLLING, \ - (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ const struct kscan_gpio_item_config *out_cfg = &kscan_gpio_output_configs_##n(dev)[o]; \ output_devices[o] = device_get_binding(out_cfg->label); \ @@ -290,8 +247,8 @@ static int kscan_gpio_matrix_disable(struct device *dev) { } \ static const struct kscan_driver_api gpio_driver_api_##n = { \ .config = kscan_gpio_configure_##n, \ - .enable_callback = kscan_gpio_matrix_enable, \ - .disable_callback = kscan_gpio_matrix_disable, \ + .enable_callback = kscan_gpio_enable_##n, \ + .disable_callback = kscan_gpio_disable_interrupts_##n, \ }; \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ -- cgit v1.2.3 From b1dce208f8accab56c7864e01cff70a88bc39b3f Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Fri, 25 Sep 2020 11:29:21 -0400 Subject: Add matrix polling logic to matrix GPIO driver. --- app/drivers/zephyr/Kconfig | 2 +- app/drivers/zephyr/kscan_gpio_matrix.c | 65 ++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 19 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index c5ff3a6..0534cab 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -7,7 +7,7 @@ if ZMK_KSCAN_GPIO_DRIVER config ZMK_KSCAN_MATRIX_POLLING bool "Poll for key event triggers instead of using interrupts on matrix boards." - default y + default n config ZMK_KSCAN_DIRECT_POLLING bool "Poll for key event triggers instead of using interrupts on direct wired boards." diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 634f694..8c6cabd 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,7 +31,8 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) -static int kscan_gpio_config_interrupts(struct device **devices, +COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, +(static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { for (int i = 0; i < len; i++) { @@ -47,7 +48,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } return 0; -} +}), ()) + #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_OUTPUT_LEN(n) \ @@ -69,6 +71,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -96,16 +99,17 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + } \ + static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ GPIO_INT_DISABLE); \ - } \ + }), ()) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ @@ -128,7 +132,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - kscan_gpio_disable_interrupts_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (kscan_gpio_disable_interrupts_##n(dev);),()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -143,10 +148,11 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ gpio_pin_set(out_dev, out_cfg->pin, 0); \ } \ - /* Set all our outputs as active again, then re-enable interrupts, */ \ - /* so we can trigger interrupts again for future press/release */ \ + /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - kscan_gpio_enable_interrupts_##n(dev); \ + /*Re-enable interrupts so that they can be triggered again for future press/release*/ \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -190,15 +196,34 @@ static int kscan_gpio_config_interrupts(struct device **devices, return -EINVAL; \ } \ data->callback = callback; \ + LOG_DBG("Configured GPIO %d", n); \ return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { \ - return err; \ - } \ - return kscan_gpio_read_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { \ + return err; \ + } \ + return kscan_gpio_read_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ + return 0;)) \ + }; \ + static int kscan_gpio_disable_##n(struct device *dev) { \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (return kscan_gpio_disable_interrupts_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_stop(&data->poll_timer); \ + return 0;)) \ }; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ + struct kscan_gpio_data_##n *data = \ + CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ + k_work_submit(&data->work.work); \ + LOG_DBG("Submitted work in timer handler."); \ + })) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -214,6 +239,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, if (err) { \ LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ return err; \ + } else { \ + LOG_DBG("Configured pin %d on %s for input", in_cfg->pin, in_cfg->label); \ } \ irq_callbacks_##n[i].work = &data->work; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -241,6 +268,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ data->dev = dev; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);)) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ return 0; \ @@ -248,7 +277,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, static const struct kscan_driver_api gpio_driver_api_##n = { \ .config = kscan_gpio_configure_##n, \ .enable_callback = kscan_gpio_enable_##n, \ - .disable_callback = kscan_gpio_disable_interrupts_##n, \ + .disable_callback = kscan_gpio_disable_##n, \ }; \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ -- cgit v1.2.3 From cca8337f0562afbfb11de5af92ba5dc3c9334991 Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Wed, 23 Sep 2020 16:05:29 -0400 Subject: Add support to GPIO matrix driver for matrix polling, rather than interrupt-based IO. - Add ZMK_KSCAN_MATRIX_POLLING config flag to Kconfig - Update matrix driver code to use the above flag to conditionally add the handling code for polling operations. --- app/boards/arm/planck/Kconfig.defconfig | 3 ++ .../shields/clueboard_california/Kconfig.defconfig | 2 +- app/drivers/zephyr/Kconfig | 8 ++- app/drivers/zephyr/kscan_gpio_direct.c | 18 +++---- app/drivers/zephyr/kscan_gpio_matrix.c | 63 +++++++++++++++------- 5 files changed, 64 insertions(+), 30 deletions(-) (limited to 'app') diff --git a/app/boards/arm/planck/Kconfig.defconfig b/app/boards/arm/planck/Kconfig.defconfig index 6f5bf52..913c1c1 100644 --- a/app/boards/arm/planck/Kconfig.defconfig +++ b/app/boards/arm/planck/Kconfig.defconfig @@ -11,4 +11,7 @@ config ZMK_KEYBOARD_NAME config ZMK_USB default y +config ZMK_KSCAN_MATRIX_POLLING + default y + endif # BOARD_PLANCK_REV6 diff --git a/app/boards/shields/clueboard_california/Kconfig.defconfig b/app/boards/shields/clueboard_california/Kconfig.defconfig index 2408f9f..e101ea7 100644 --- a/app/boards/shields/clueboard_california/Kconfig.defconfig +++ b/app/boards/shields/clueboard_california/Kconfig.defconfig @@ -8,7 +8,7 @@ config ZMK_KEYBOARD_NAME # across A & B controllers, and STM32F303CCT6 can't enable # interrutps for multiple controllers for the same "line" # for the external interrupts. -config ZMK_KSCAN_GPIO_POLLING +config ZMK_KSCAN_DIRECT_POLLING default y endif diff --git a/app/drivers/zephyr/Kconfig b/app/drivers/zephyr/Kconfig index 0237846..0534cab 100644 --- a/app/drivers/zephyr/Kconfig +++ b/app/drivers/zephyr/Kconfig @@ -5,10 +5,14 @@ config ZMK_KSCAN_GPIO_DRIVER if ZMK_KSCAN_GPIO_DRIVER -config ZMK_KSCAN_GPIO_POLLING - bool "Poll for key event triggers instead of using interrupts" +config ZMK_KSCAN_MATRIX_POLLING + bool "Poll for key event triggers instead of using interrupts on matrix boards." default n +config ZMK_KSCAN_DIRECT_POLLING + bool "Poll for key event triggers instead of using interrupts on direct wired boards." + default n + endif config ZMK_KSCAN_INIT_PRIORITY diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 1e5ab59..7ba3399 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -33,9 +33,9 @@ struct kscan_gpio_config { }; struct kscan_gpio_data { -#if defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if defined(ZMK_KSCAN_DIRECT_POLLING) struct k_timer poll_timer; -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ kscan_callback_t callback; union work_reference work; struct device *dev; @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi return cfg->inputs; } -#if !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) +#if !defined(ZMK_KSCAN_DIRECT_POLLING) struct kscan_gpio_irq_callback { union work_reference *work; @@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call } } -#else /* !defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#else /* !defined(ZMK_KSCAN_DIRECT_POLLING) */ static void kscan_gpio_timer_handler(struct k_timer *timer) { struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); @@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { return 0; } -#endif /* defined(CONFIG_ZMK_KSCAN_GPIO_POLLING) */ +#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) { struct kscan_gpio_data *data = dev->driver_data; @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_0(ZMK_KSCAN_DIRECT_POLLING, \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + ZMK_KSCAN_DIRECT_POLLING, \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_GPIO_POLLING, \ + COND_CODE_1(ZMK_KSCAN_DIRECT_POLLING, \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ @@ -227,4 +227,4 @@ static const struct kscan_driver_api gpio_driver_api = { DT_INST_FOREACH_STATUS_OKAY(GPIO_INST_INIT) -#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ \ No newline at end of file +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 634f694..72709ba 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,7 +31,8 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) -static int kscan_gpio_config_interrupts(struct device **devices, +COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, +(static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { for (int i = 0; i < len; i++) { @@ -47,7 +48,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } return 0; -} +}), ()) + #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) #define INST_OUTPUT_LEN(n) \ @@ -69,6 +71,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -96,16 +99,17 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + } \ + static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ GPIO_INT_DISABLE); \ - } \ + }), ()) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ @@ -128,7 +132,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - kscan_gpio_disable_interrupts_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (kscan_gpio_disable_interrupts_##n(dev);),()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -143,10 +148,11 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ gpio_pin_set(out_dev, out_cfg->pin, 0); \ } \ - /* Set all our outputs as active again, then re-enable interrupts, */ \ - /* so we can trigger interrupts again for future press/release */ \ + /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - kscan_gpio_enable_interrupts_##n(dev); \ + /*Re-enable interrupts so that they can be triggered again for future press/release*/ \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -193,12 +199,29 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { \ - return err; \ - } \ - return kscan_gpio_read_##n(dev); \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { \ + return err; \ + } \ + return kscan_gpio_read_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ + return 0;)) \ + }; \ + static int kscan_gpio_disable_##n(struct device *dev) { \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + (return kscan_gpio_disable_interrupts_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_stop(&data->poll_timer); \ + return 0;)) \ }; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ + struct kscan_gpio_data_##n *data = \ + CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ + k_work_submit(&data->work.work); \ + })) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -214,6 +237,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, if (err) { \ LOG_ERR("Unable to configure pin %d on %s for input", in_cfg->pin, in_cfg->label); \ return err; \ + } else { \ + LOG_DBG("Configured pin %d on %s for input", in_cfg->pin, in_cfg->label); \ } \ irq_callbacks_##n[i].work = &data->work; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -241,6 +266,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ data->dev = dev; \ + COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);)) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ return 0; \ @@ -248,7 +275,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, static const struct kscan_driver_api gpio_driver_api_##n = { \ .config = kscan_gpio_configure_##n, \ .enable_callback = kscan_gpio_enable_##n, \ - .disable_callback = kscan_gpio_disable_interrupts_##n, \ + .disable_callback = kscan_gpio_disable_##n, \ }; \ static const struct kscan_gpio_config_##n kscan_gpio_config_##n = { \ .rows = {UTIL_LISTIFY(INST_MATRIX_ROWS(n), _KSCAN_GPIO_ROW_CFG_INIT, n)}, \ -- cgit v1.2.3 From 7f7c7037b04c78d8a3b74557197e0a2996eb980e Mon Sep 17 00:00:00 2001 From: Noah Thornton Date: Sat, 26 Sep 2020 11:59:12 -0700 Subject: Add quefrency shield --- app/boards/shields/quefrency/Kconfig.defconfig | 17 ++++++++ app/boards/shields/quefrency/Kconfig.shield | 8 ++++ app/boards/shields/quefrency/quefrency.conf | 0 app/boards/shields/quefrency/quefrency.dtsi | 29 ++++++++++++ app/boards/shields/quefrency/quefrency.keymap | 51 ++++++++++++++++++++++ app/boards/shields/quefrency/quefrency_left.conf | 2 + .../shields/quefrency/quefrency_left.overlay | 34 +++++++++++++++ app/boards/shields/quefrency/quefrency_right.conf | 2 + .../shields/quefrency/quefrency_right.overlay | 42 ++++++++++++++++++ 9 files changed, 185 insertions(+) create mode 100644 app/boards/shields/quefrency/Kconfig.defconfig create mode 100644 app/boards/shields/quefrency/Kconfig.shield create mode 100644 app/boards/shields/quefrency/quefrency.conf create mode 100644 app/boards/shields/quefrency/quefrency.dtsi create mode 100644 app/boards/shields/quefrency/quefrency.keymap create mode 100644 app/boards/shields/quefrency/quefrency_left.conf create mode 100644 app/boards/shields/quefrency/quefrency_left.overlay create mode 100644 app/boards/shields/quefrency/quefrency_right.conf create mode 100644 app/boards/shields/quefrency/quefrency_right.overlay (limited to 'app') diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig new file mode 100644 index 0000000..c383340 --- /dev/null +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -0,0 +1,17 @@ +#Copyright (c) 2020 Noah Thornton +#SPDX-License-Identifier: MIT + + +if SHIELD_QUEFRENCY_LEFT + +config ZMK_KEYBOARD_NAME + default "Quefrency Left" + +endif + +if SHIELD_QUEFRENCY_RIGHT + +config ZMK_KEYBOARD_NAME + default "Quefrency Right" + +endif diff --git a/app/boards/shields/quefrency/Kconfig.shield b/app/boards/shields/quefrency/Kconfig.shield new file mode 100644 index 0000000..d56a1b2 --- /dev/null +++ b/app/boards/shields/quefrency/Kconfig.shield @@ -0,0 +1,8 @@ +# Copyright (c) 2020 Noah Thornton +# SPDX-License-Identifier: MIT + +config SHIELD_QUEFRENCY_LEFT + def_bool $(shields_list_contains,quefrency_left) + +config SHIELD_QUEFRENCY_RIGHT + def_bool $(shields_list_contains,quefrency_right) diff --git a/app/boards/shields/quefrency/quefrency.conf b/app/boards/shields/quefrency/quefrency.conf new file mode 100644 index 0000000..e69de29 diff --git a/app/boards/shields/quefrency/quefrency.dtsi b/app/boards/shields/quefrency/quefrency.dtsi new file mode 100644 index 0000000..76f9b2e --- /dev/null +++ b/app/boards/shields/quefrency/quefrency.dtsi @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2020 Noah Thornton + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <15>; + rows = <6>; + map = < +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,14) RC(5,13) +RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) /**/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(5,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,14) RC(2,13) +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,12) RC(3,13) RC(3,14) RC(3,11) +RC(4,0) RC(4,1) RC(4,2) RC(4,4) RC(4,6) /**/ RC(4,7) RC(4,10) RC(4,11) RC(4,12) RC(4,13) RC(4,14) RC(4,9) + >; + }; +}; + diff --git a/app/boards/shields/quefrency/quefrency.keymap b/app/boards/shields/quefrency/quefrency.keymap new file mode 100644 index 0000000..1eb7caa --- /dev/null +++ b/app/boards/shields/quefrency/quefrency.keymap @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2020 Noah Thornton + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + +// ---------------------------------------------- ----------------------------------------------------- +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | | 7 | 8 | 9 | 0 | - | = | BKSPC | ` | +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | [ | ] | \ | DEL | +// | LCTRL | A | S | D | F | G | | H | J | K | L | ; | ' | ENTER | PGUP | +// | SHIFT | Z | X | C | V | B | | N | M | , | . | / | RSHFT | UP | PGDN | +// | LCTRL | LGUI | LALT | SPACE | FN | | SPACE | RALT | FN | RCTRL | LFT | DWN | RGHT | +// ------------------------------------------- ------------------------------------------------------ + + default_layer { + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 /**/ &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP &kp GRAV + &kp TAB &kp Q &kp W &kp E &kp R &kp T /**/ &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH &kp HOME + &kp LCTL &kp A &kp S &kp D &kp F &kp G /**/ &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET &kp PGUP + &kp LSFT &kp Z &kp X &kp C &kp V &kp B /**/ &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT &kp UARW &kp PGDN + &kp LCTL &kp LGUI &kp LALT &kp SPC &mo 1 /**/ &kp SPC &kp RALT &mo 1 &kp RCTL &kp LARW &kp DARW &kp RARW + >; + }; + +// ---------------------------------------------- ----------------------------------------------------- +// |BT_CLR| F1 | F2 | F3 | F4 | F5 | F6 | | F7 | F8 | F9 | F10 | F11 | F12 | |BT_CLR| +// | | BT-0 | BT-1| BT-2 | | | | | | | | | | | | | +// | | | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | | | +// | | | | | | | | | | | | | | +// ------------------------------------------- ------------------------------------------------------ + + fn_layer { + bindings = < + &bt BT_CLR &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 /**/ &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &trans &bt BT_CLR + &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &trans &trans /**/ &trans &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans &trans &trans + &trans &trans &trans &trans &trans /**/ &trans &trans &trans &trans &trans &trans &trans + >; + }; + }; +}; diff --git a/app/boards/shields/quefrency/quefrency_left.conf b/app/boards/shields/quefrency/quefrency_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/quefrency/quefrency_left.overlay b/app/boards/shields/quefrency/quefrency_left.overlay new file mode 100644 index 0000000..a62ac8f --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_left.overlay @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2020 Noah Thornton + * + * SPDX-License-Identifier: MIT + */ + +#include "quefrency.dtsi" + +/ { + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + + col-gpios + = <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; diff --git a/app/boards/shields/quefrency/quefrency_right.conf b/app/boards/shields/quefrency/quefrency_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/quefrency/quefrency_right.overlay b/app/boards/shields/quefrency/quefrency_right.overlay new file mode 100644 index 0000000..f4037ce --- /dev/null +++ b/app/boards/shields/quefrency/quefrency_right.overlay @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2020 Noah Thornton + * + * SPDX-License-Identifier: MIT + */ + +#include "quefrency.dtsi" + +&default_transform { + col-offset = <7>; +}; + +/ { + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + + + col-gpios + = <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 16 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 10 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 5 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + }; +}; -- cgit v1.2.3 From 24b638dfa37211fc5f0c09844d38760bae5eda5f Mon Sep 17 00:00:00 2001 From: Noah Thornton Date: Sat, 26 Sep 2020 21:09:19 -0500 Subject: Apply suggestions from code review Revise copyright header Co-authored-by: Pete Johanson --- app/boards/shields/quefrency/Kconfig.defconfig | 2 +- app/boards/shields/quefrency/Kconfig.shield | 2 +- app/boards/shields/quefrency/quefrency.dtsi | 3 +-- app/boards/shields/quefrency/quefrency.keymap | 2 +- app/boards/shields/quefrency/quefrency_left.overlay | 2 +- app/boards/shields/quefrency/quefrency_right.overlay | 2 +- 6 files changed, 6 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/boards/shields/quefrency/Kconfig.defconfig b/app/boards/shields/quefrency/Kconfig.defconfig index c383340..2b00cb6 100644 --- a/app/boards/shields/quefrency/Kconfig.defconfig +++ b/app/boards/shields/quefrency/Kconfig.defconfig @@ -1,4 +1,4 @@ -#Copyright (c) 2020 Noah Thornton +#Copyright (c) 2020 The ZMK Contributors #SPDX-License-Identifier: MIT diff --git a/app/boards/shields/quefrency/Kconfig.shield b/app/boards/shields/quefrency/Kconfig.shield index d56a1b2..d205e58 100644 --- a/app/boards/shields/quefrency/Kconfig.shield +++ b/app/boards/shields/quefrency/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Noah Thornton +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config SHIELD_QUEFRENCY_LEFT diff --git a/app/boards/shields/quefrency/quefrency.dtsi b/app/boards/shields/quefrency/quefrency.dtsi index 76f9b2e..74ddc33 100644 --- a/app/boards/shields/quefrency/quefrency.dtsi +++ b/app/boards/shields/quefrency/quefrency.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noah Thornton + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ @@ -26,4 +26,3 @@ RC(4,0) RC(4,1) RC(4,2) RC(4,4) RC(4,6) /**/ RC(4,7) >; }; }; - diff --git a/app/boards/shields/quefrency/quefrency.keymap b/app/boards/shields/quefrency/quefrency.keymap index 1eb7caa..21c5ed4 100644 --- a/app/boards/shields/quefrency/quefrency.keymap +++ b/app/boards/shields/quefrency/quefrency.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noah Thornton + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/quefrency/quefrency_left.overlay b/app/boards/shields/quefrency/quefrency_left.overlay index a62ac8f..a1d205e 100644 --- a/app/boards/shields/quefrency/quefrency_left.overlay +++ b/app/boards/shields/quefrency/quefrency_left.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noah Thornton + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/quefrency/quefrency_right.overlay b/app/boards/shields/quefrency/quefrency_right.overlay index f4037ce..3876144 100644 --- a/app/boards/shields/quefrency/quefrency_right.overlay +++ b/app/boards/shields/quefrency/quefrency_right.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Noah Thornton + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 9afd44b9d4a6790d315f2824ca6d21953804b1af Mon Sep 17 00:00:00 2001 From: Noah Thornton Date: Sat, 26 Sep 2020 22:10:14 -0500 Subject: Provide context on Quefrency physical PCB layouts The Quefrency board has two options for each left and right half, resulting in 4 unique combinations. This has been noted in the overlay and dtsi files. --- app/boards/shields/quefrency/quefrency.dtsi | 4 ++++ app/boards/shields/quefrency/quefrency_left.overlay | 3 +++ app/boards/shields/quefrency/quefrency_right.overlay | 3 +++ 3 files changed, 10 insertions(+) (limited to 'app') diff --git a/app/boards/shields/quefrency/quefrency.dtsi b/app/boards/shields/quefrency/quefrency.dtsi index 74ddc33..5f1e908 100644 --- a/app/boards/shields/quefrency/quefrency.dtsi +++ b/app/boards/shields/quefrency/quefrency.dtsi @@ -13,6 +13,10 @@ zmk,matrix_transform = &default_transform; }; + /* + * This transform correspondsto the 60% left without macro keypad and 65% right, even this + * combination of PCBs can have keys in different locations based on configuration. + */ default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <15>; diff --git a/app/boards/shields/quefrency/quefrency_left.overlay b/app/boards/shields/quefrency/quefrency_left.overlay index a1d205e..a385cc5 100644 --- a/app/boards/shields/quefrency/quefrency_left.overlay +++ b/app/boards/shields/quefrency/quefrency_left.overlay @@ -7,6 +7,9 @@ #include "quefrency.dtsi" / { + /* This kscan is for the 60% left half without macro keys the + * macro pad layout may require different column and row pins + */ kscan0: kscan { compatible = "zmk,kscan-gpio-matrix"; label = "KSCAN"; diff --git a/app/boards/shields/quefrency/quefrency_right.overlay b/app/boards/shields/quefrency/quefrency_right.overlay index 3876144..53e0f77 100644 --- a/app/boards/shields/quefrency/quefrency_right.overlay +++ b/app/boards/shields/quefrency/quefrency_right.overlay @@ -12,6 +12,9 @@ / { + /* This kscan is for the 65% right half the 60% right half + * may require different column and row pins + */ kscan0: kscan { compatible = "zmk,kscan-gpio-matrix"; label = "KSCAN"; -- cgit v1.2.3 From 9392c4f9ffbe815a44d007cf85a2a17955f46edb Mon Sep 17 00:00:00 2001 From: jason Date: Sun, 27 Sep 2020 21:27:30 -0400 Subject: Fix preprocessor flag issues for pull request. --- app/drivers/zephyr/kscan_gpio_direct.c | 16 ++++++++-------- app/drivers/zephyr/kscan_gpio_matrix.c | 23 ++++++++++++----------- 2 files changed, 20 insertions(+), 19 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index 7ba3399..c3414fb 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -33,9 +33,9 @@ struct kscan_gpio_config { }; struct kscan_gpio_data { -#if defined(ZMK_KSCAN_DIRECT_POLLING) +#if defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) struct k_timer poll_timer; -#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ +#endif /* defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ kscan_callback_t callback; union work_reference work; struct device *dev; @@ -53,7 +53,7 @@ static const struct kscan_gpio_item_config *kscan_gpio_input_configs(struct devi return cfg->inputs; } -#if !defined(ZMK_KSCAN_DIRECT_POLLING) +#if !defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) struct kscan_gpio_irq_callback { union work_reference *work; @@ -101,7 +101,7 @@ static void kscan_gpio_irq_callback_handler(struct device *dev, struct gpio_call } } -#else /* !defined(ZMK_KSCAN_DIRECT_POLLING) */ +#else /* !defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ static void kscan_gpio_timer_handler(struct k_timer *timer) { struct kscan_gpio_data *data = CONTAINER_OF(timer, struct kscan_gpio_data, poll_timer); @@ -120,7 +120,7 @@ static int kscan_gpio_direct_disable(struct device *dev) { return 0; } -#endif /* defined(ZMK_KSCAN_DIRECT_POLLING) */ +#endif /* defined(CONFIG_ZMK_KSCAN_DIRECT_POLLING) */ static int kscan_gpio_direct_configure(struct device *dev, kscan_callback_t callback) { struct kscan_gpio_data *data = dev->driver_data; @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - ZMK_KSCAN_DIRECT_POLLING, \ + CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_1(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index e581d33..b940c6d 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,8 +31,8 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) -COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, -(static int kscan_gpio_config_interrupts(struct device **devices, +#ifdef CONFIG_ZMK_KSCAN_MATRIX_POLLING +static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { for (int i = 0; i < len; i++) { @@ -48,7 +48,8 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, } return 0; -}), ()) +} +#endif #define INST_MATRIX_ROWS(n) DT_INST_PROP_LEN(n, row_gpios) #define INST_MATRIX_COLS(n) DT_INST_PROP_LEN(n, col_gpios) @@ -71,7 +72,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -99,7 +100,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ @@ -132,7 +133,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (kscan_gpio_disable_interrupts_##n(dev);),()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ @@ -151,7 +152,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ /*Re-enable interrupts so that they can be triggered again for future press/release*/ \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ @@ -200,7 +201,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (int err = kscan_gpio_enable_interrupts_##n(dev); \ if (err) { \ return err; \ @@ -211,13 +212,13 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, return 0;)) \ }; \ static int kscan_gpio_disable_##n(struct device *dev) { \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (return kscan_gpio_disable_interrupts_##n(dev);), \ (struct kscan_gpio_data_##n *data = dev->driver_data; \ k_timer_stop(&data->poll_timer); \ return 0;)) \ }; \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ struct kscan_gpio_data_##n *data = \ CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ @@ -267,7 +268,7 @@ COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, } \ } \ data->dev = dev; \ - COND_CODE_0(ZMK_KSCAN_MATRIX_POLLING, (), \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);)) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ -- cgit v1.2.3 From c2a861c0e6a731fd92368768a9b07d5feac7d374 Mon Sep 17 00:00:00 2001 From: Jason Chestnut Date: Mon, 28 Sep 2020 08:24:51 -0400 Subject: Modify preprocessor directives to use basic #if !defined() rather than Zephyr macros where appropriate. --- app/drivers/zephyr/kscan_gpio_matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index b940c6d..5fa618b 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -31,7 +31,7 @@ struct kscan_gpio_item_config { #define _KSCAN_GPIO_ROW_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, row_gpios, idx) #define _KSCAN_GPIO_COL_CFG_INIT(idx, n) _KSCAN_GPIO_ITEM_CFG_INIT(n, col_gpios, idx) -#ifdef CONFIG_ZMK_KSCAN_MATRIX_POLLING +#if !defined(CONFIG_ZMK_KSCAN_MATRIX_POLLING) static int kscan_gpio_config_interrupts(struct device **devices, const struct kscan_gpio_item_config *configs, size_t len, gpio_flags_t flags) { -- cgit v1.2.3 From 182a6dca1fc9b1d5e7b0d3828501d6be43ff70dd Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 29 Sep 2020 12:21:06 -0400 Subject: fix(bluetooth): Proper max paired/conns. * Proper max values for both split central, and non-split keyboards. --- app/Kconfig | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/Kconfig b/app/Kconfig index 6180565..ccd40da 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -132,16 +132,30 @@ endif endif -if ZMK_BLE && (!ZMK_SPLIT_BLE || ZMK_SPLIT_BLE_ROLE_CENTRAL) +if ZMK_BLE + +if ZMK_SPLIT_BLE && ZMK_SPLIT_BLE_ROLE_CENTRAL config BT_MAX_CONN default 6 +config BT_MAX_PAIRED + default 6 + +endif + +if !ZMK_SPLIT_BLE + +config BT_MAX_CONN + default 5 + config BT_MAX_PAIRED default 5 endif +endif + endmenu config ZMK_KSCAN_MOCK_DRIVER -- cgit v1.2.3 From a3d0c03726a0bc607d4daab7a90dda57d4ba6a6f Mon Sep 17 00:00:00 2001 From: David Barr Date: Wed, 30 Sep 2020 16:20:41 +0100 Subject: rename cradios to cradio --- app/.DS_Store | Bin 0 -> 8196 bytes app/boards/.DS_Store | Bin 0 -> 8196 bytes app/boards/shields/.DS_Store | Bin 0 -> 8196 bytes app/boards/shields/cradio/Kconfig.defconfig | 11 ++++ app/boards/shields/cradio/Kconfig.shield | 5 ++ app/boards/shields/cradio/cradio.dtsi | 63 +++++++++++++++++++++ app/boards/shields/cradio/cradio.keymap | 18 ++++++ app/boards/shields/cradio/cradio_left.conf | 2 + app/boards/shields/cradio/cradio_left.overlay | 11 ++++ app/boards/shields/cradio/cradio_right.conf | 2 + app/boards/shields/cradio/cradio_right.overlay | 14 +++++ app/boards/shields/cradio/default.keymap | 19 +++++++ app/boards/shields/cradios.dtsi | 67 ----------------------- app/boards/shields/cradios.keymap | 18 ------ app/boards/shields/cradios/Kconfig.defconfig | 14 ----- app/boards/shields/cradios/Kconfig.shield | 5 -- app/boards/shields/cradios/cradios.dtsi | 67 ----------------------- app/boards/shields/cradios/cradios.keymap | 18 ------ app/boards/shields/cradios/cradios_left.conf | 2 - app/boards/shields/cradios/cradios_left.overlay | 15 ----- app/boards/shields/cradios/cradios_right.conf | 2 - app/boards/shields/cradios/cradios_right.overlay | 17 ------ app/boards/shields/cradios/default.keymap | 19 ------- app/boards/shields/cradios_left.conf | 2 - app/boards/shields/cradios_left.overlay | 15 ----- app/boards/shields/cradios_right.conf | 2 - app/boards/shields/cradios_right.overlay | 17 ------ 27 files changed, 145 insertions(+), 280 deletions(-) create mode 100644 app/.DS_Store create mode 100644 app/boards/.DS_Store create mode 100644 app/boards/shields/.DS_Store create mode 100644 app/boards/shields/cradio/Kconfig.defconfig create mode 100644 app/boards/shields/cradio/Kconfig.shield create mode 100644 app/boards/shields/cradio/cradio.dtsi create mode 100644 app/boards/shields/cradio/cradio.keymap create mode 100644 app/boards/shields/cradio/cradio_left.conf create mode 100644 app/boards/shields/cradio/cradio_left.overlay create mode 100644 app/boards/shields/cradio/cradio_right.conf create mode 100644 app/boards/shields/cradio/cradio_right.overlay create mode 100644 app/boards/shields/cradio/default.keymap delete mode 100644 app/boards/shields/cradios.dtsi delete mode 100644 app/boards/shields/cradios.keymap delete mode 100644 app/boards/shields/cradios/Kconfig.defconfig delete mode 100644 app/boards/shields/cradios/Kconfig.shield delete mode 100644 app/boards/shields/cradios/cradios.dtsi delete mode 100644 app/boards/shields/cradios/cradios.keymap delete mode 100644 app/boards/shields/cradios/cradios_left.conf delete mode 100644 app/boards/shields/cradios/cradios_left.overlay delete mode 100644 app/boards/shields/cradios/cradios_right.conf delete mode 100644 app/boards/shields/cradios/cradios_right.overlay delete mode 100644 app/boards/shields/cradios/default.keymap delete mode 100644 app/boards/shields/cradios_left.conf delete mode 100644 app/boards/shields/cradios_left.overlay delete mode 100644 app/boards/shields/cradios_right.conf delete mode 100644 app/boards/shields/cradios_right.overlay (limited to 'app') diff --git a/app/.DS_Store b/app/.DS_Store new file mode 100644 index 0000000..7b9df97 Binary files /dev/null and b/app/.DS_Store differ diff --git a/app/boards/.DS_Store b/app/boards/.DS_Store new file mode 100644 index 0000000..f1a7fab Binary files /dev/null and b/app/boards/.DS_Store differ diff --git a/app/boards/shields/.DS_Store b/app/boards/shields/.DS_Store new file mode 100644 index 0000000..242a19d Binary files /dev/null and b/app/boards/shields/.DS_Store differ diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig new file mode 100644 index 0000000..ab38e25 --- /dev/null +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -0,0 +1,11 @@ +config ZMK_KEYBOARD_NAME + default "cradio" + +# Unable to use interrupts as the same pin number is used +# across A & B controllers, and STM32F303CCT6 can't enable +# interrutps for multiple controllers for the same "line" +# for the external interrupts. +config ZMK_KSCAN_GPIO_POLLING + default y + + diff --git a/app/boards/shields/cradio/Kconfig.shield b/app/boards/shields/cradio/Kconfig.shield new file mode 100644 index 0000000..0385d23 --- /dev/null +++ b/app/boards/shields/cradio/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 Pete Johanson +# SPDX-License-Identifier: MIT + +config SHIELD_CRADIO + def_bool $(shields_list_contains,cradio) diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi new file mode 100644 index 0000000..19225f9 --- /dev/null +++ b/app/boards/shields/cradio/cradio.dtsi @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ + #include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <34>; + rows = <1>; + map = < +RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) +RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) +RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) +RC(0,15) RC(0,16) RC(0,33) RC(0,32) +>; + + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-direct"; + label = "KSCAN"; + }; + + + + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; + + }; + + &kscan0 { + input-gpios + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + ; +}; + + diff --git a/app/boards/shields/cradio/cradio.keymap b/app/boards/shields/cradio/cradio.keymap new file mode 100644 index 0000000..c46468d --- /dev/null +++ b/app/boards/shields/cradio/cradio.keymap @@ -0,0 +1,18 @@ +#include +#include + + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 + >; + }; + }; +}; diff --git a/app/boards/shields/cradio/cradio_left.conf b/app/boards/shields/cradio/cradio_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/cradio/cradio_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradio/cradio_left.overlay b/app/boards/shields/cradio/cradio_left.overlay new file mode 100644 index 0000000..c660072 --- /dev/null +++ b/app/boards/shields/cradio/cradio_left.overlay @@ -0,0 +1,11 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradio.dtsi" + +&bt_unpair_combo { + + key-positions = <0 16>; +}; diff --git a/app/boards/shields/cradio/cradio_right.conf b/app/boards/shields/cradio/cradio_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/cradio/cradio_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay new file mode 100644 index 0000000..3469199 --- /dev/null +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT + */ +#include "cradio.dtsi" + +&default_transform { + col-offset = <17>; +}; + +&bt_unpair_combo { + key-positions = <21 32>; +}; diff --git a/app/boards/shields/cradio/default.keymap b/app/boards/shields/cradio/default.keymap new file mode 100644 index 0000000..0821005 --- /dev/null +++ b/app/boards/shields/cradio/default.keymap @@ -0,0 +1,19 @@ +#include +#include + + +/ { + keymap0: keymap { + compatible = "zmk,keymap"; + + default_layer { + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp DEL &kp RET &kp RET &kp SPC + + >; + }; + }; +}; diff --git a/app/boards/shields/cradios.dtsi b/app/boards/shields/cradios.dtsi deleted file mode 100644 index 68d1fc5..0000000 --- a/app/boards/shields/cradios.dtsi +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ - #include - -/ { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <34>; - rows = <1>; - map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) -RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) -RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) -RC(0,15) RC(0,16) RC(0,33) RC(0,32) ->; - - - }; - - kscan0: kscan { - compatible = "zmk,kscan-gpio-direct"; - label = "KSCAN"; - }; - - - - - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; - - - - }; - - - &kscan0 { - input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - ; -}; - - diff --git a/app/boards/shields/cradios.keymap b/app/boards/shields/cradios.keymap deleted file mode 100644 index c46468d..0000000 --- a/app/boards/shields/cradios.keymap +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { - 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 SCLN - &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 - >; - }; - }; -}; diff --git a/app/boards/shields/cradios/Kconfig.defconfig b/app/boards/shields/cradios/Kconfig.defconfig deleted file mode 100644 index 5b9ca9a..0000000 --- a/app/boards/shields/cradios/Kconfig.defconfig +++ /dev/null @@ -1,14 +0,0 @@ - - - -config ZMK_KEYBOARD_NAME - default "cradios" - -# Unable to use interrupts as the same pin number is used -# across A & B controllers, and STM32F303CCT6 can't enable -# interrutps for multiple controllers for the same "line" -# for the external interrupts. -config ZMK_KSCAN_GPIO_POLLING - default y - - diff --git a/app/boards/shields/cradios/Kconfig.shield b/app/boards/shields/cradios/Kconfig.shield deleted file mode 100644 index 844d433..0000000 --- a/app/boards/shields/cradios/Kconfig.shield +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2020 Pete Johanson -# SPDX-License-Identifier: MIT - -config SHIELD_CRADIOS - def_bool $(shields_list_contains,cradios) diff --git a/app/boards/shields/cradios/cradios.dtsi b/app/boards/shields/cradios/cradios.dtsi deleted file mode 100644 index 68d1fc5..0000000 --- a/app/boards/shields/cradios/cradios.dtsi +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ - #include - -/ { - chosen { - zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; - }; - - default_transform: keymap_transform_0 { - compatible = "zmk,matrix-transform"; - columns = <34>; - rows = <1>; - map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) -RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) -RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) -RC(0,15) RC(0,16) RC(0,33) RC(0,32) ->; - - - }; - - kscan0: kscan { - compatible = "zmk,kscan-gpio-direct"; - label = "KSCAN"; - }; - - - - - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; - - - - }; - - - &kscan0 { - input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 15 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 14 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 16 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 10 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 3 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_a 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 5 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> - ; -}; - - diff --git a/app/boards/shields/cradios/cradios.keymap b/app/boards/shields/cradios/cradios.keymap deleted file mode 100644 index c46468d..0000000 --- a/app/boards/shields/cradios/cradios.keymap +++ /dev/null @@ -1,18 +0,0 @@ -#include -#include - - -/ { - keymap { - compatible = "zmk,keymap"; - - default_layer { - 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 SCLN - &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 - >; - }; - }; -}; diff --git a/app/boards/shields/cradios/cradios_left.conf b/app/boards/shields/cradios/cradios_left.conf deleted file mode 100644 index 1e028a7..0000000 --- a/app/boards/shields/cradios/cradios_left.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradios/cradios_left.overlay b/app/boards/shields/cradios/cradios_left.overlay deleted file mode 100644 index b0bdc6f..0000000 --- a/app/boards/shields/cradios/cradios_left.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ -#include "cradios.dtsi" - - - - - - -&bt_unpair_combo { - key-positions = <0 16>; -}; diff --git a/app/boards/shields/cradios/cradios_right.conf b/app/boards/shields/cradios/cradios_right.conf deleted file mode 100644 index 990cf7c..0000000 --- a/app/boards/shields/cradios/cradios_right.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradios/cradios_right.overlay b/app/boards/shields/cradios/cradios_right.overlay deleted file mode 100644 index ef920ac..0000000 --- a/app/boards/shields/cradios/cradios_right.overlay +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ -#include "cradios.dtsi" - -&default_transform { - col-offset = <17>; -}; - - - - -&bt_unpair_combo { - key-positions = <21 32>; -}; diff --git a/app/boards/shields/cradios/default.keymap b/app/boards/shields/cradios/default.keymap deleted file mode 100644 index 0821005..0000000 --- a/app/boards/shields/cradios/default.keymap +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - - -/ { - keymap0: keymap { - compatible = "zmk,keymap"; - - default_layer { - 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 SCLN - &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp DEL &kp RET &kp RET &kp SPC - - >; - }; - }; -}; diff --git a/app/boards/shields/cradios_left.conf b/app/boards/shields/cradios_left.conf deleted file mode 100644 index 1e028a7..0000000 --- a/app/boards/shields/cradios_left.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradios_left.overlay b/app/boards/shields/cradios_left.overlay deleted file mode 100644 index b0bdc6f..0000000 --- a/app/boards/shields/cradios_left.overlay +++ /dev/null @@ -1,15 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ -#include "cradios.dtsi" - - - - - - -&bt_unpair_combo { - key-positions = <0 16>; -}; diff --git a/app/boards/shields/cradios_right.conf b/app/boards/shields/cradios_right.conf deleted file mode 100644 index 990cf7c..0000000 --- a/app/boards/shields/cradios_right.conf +++ /dev/null @@ -1,2 +0,0 @@ -CONFIG_ZMK_SPLIT=y -CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradios_right.overlay b/app/boards/shields/cradios_right.overlay deleted file mode 100644 index ef920ac..0000000 --- a/app/boards/shields/cradios_right.overlay +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Copyright (c) 2020 Pete Johanson - * - * SPDX-License-Identifier: MIT - */ -#include "cradios.dtsi" - -&default_transform { - col-offset = <17>; -}; - - - - -&bt_unpair_combo { - key-positions = <21 32>; -}; -- cgit v1.2.3 From 17bee0223aa90037896d3a83d08fe01db1cab97b Mon Sep 17 00:00:00 2001 From: David Barr Date: Wed, 30 Sep 2020 17:12:39 +0100 Subject: remove ds_store files --- app/.DS_Store | Bin 8196 -> 0 bytes app/boards/.DS_Store | Bin 8196 -> 0 bytes app/boards/shields/.DS_Store | Bin 8196 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 app/.DS_Store delete mode 100644 app/boards/.DS_Store delete mode 100644 app/boards/shields/.DS_Store (limited to 'app') diff --git a/app/.DS_Store b/app/.DS_Store deleted file mode 100644 index 7b9df97..0000000 Binary files a/app/.DS_Store and /dev/null differ diff --git a/app/boards/.DS_Store b/app/boards/.DS_Store deleted file mode 100644 index f1a7fab..0000000 Binary files a/app/boards/.DS_Store and /dev/null differ diff --git a/app/boards/shields/.DS_Store b/app/boards/shields/.DS_Store deleted file mode 100644 index 242a19d..0000000 Binary files a/app/boards/shields/.DS_Store and /dev/null differ -- cgit v1.2.3 From 16df1522c282343c3350402360db918a9a1b66e5 Mon Sep 17 00:00:00 2001 From: Mubeen Khan Date: Wed, 30 Sep 2020 21:35:51 -0500 Subject: Add TG4X rev 2.1 shield --- app/boards/shields/tg4x/Kconfig.defconfig | 9 +++++ app/boards/shields/tg4x/Kconfig.shield | 5 +++ app/boards/shields/tg4x/tg4x.keymap | 58 +++++++++++++++++++++++++++++++ app/boards/shields/tg4x/tg4x.overlay | 56 +++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 app/boards/shields/tg4x/Kconfig.defconfig create mode 100644 app/boards/shields/tg4x/Kconfig.shield create mode 100644 app/boards/shields/tg4x/tg4x.keymap create mode 100644 app/boards/shields/tg4x/tg4x.overlay (limited to 'app') diff --git a/app/boards/shields/tg4x/Kconfig.defconfig b/app/boards/shields/tg4x/Kconfig.defconfig new file mode 100644 index 0000000..ca9fa2c --- /dev/null +++ b/app/boards/shields/tg4x/Kconfig.defconfig @@ -0,0 +1,9 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +if SHIELD_TG4X + +config ZMK_KEYBOARD_NAME + default "TG4X" + +endif \ No newline at end of file diff --git a/app/boards/shields/tg4x/Kconfig.shield b/app/boards/shields/tg4x/Kconfig.shield new file mode 100644 index 0000000..7e98b71 --- /dev/null +++ b/app/boards/shields/tg4x/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_TG4X + def_bool $(shields_list_contains,tg4x) diff --git a/app/boards/shields/tg4x/tg4x.keymap b/app/boards/shields/tg4x/tg4x.keymap new file mode 100644 index 0000000..64e98bb --- /dev/null +++ b/app/boards/shields/tg4x/tg4x.keymap @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#define DEFAULT 0 +#define LOWER 1 +#define RAISE 2 + +/ { + behaviors { + hm: homerow_mods { + compatible = "zmk,behavior-hold-tap"; + label = "homerow mods"; + #binding-cells = <2>; + tapping_term_ms = <225>; + flavor = "tap-preferred"; + bindings = <&kp>, <&kp>; + }; + }; +}; + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { + bindings = < + &kp GRAV &kp Q &kp W &kp F &kp P &kp B &kp J &kp L &kp U &kp Y &kp SCLN &kp BKSP + &kp TAB &hm LGUI A &hm LALT R &hm LCTL S &hm LSFT T &kp G &kp M &hm RSFT N &hm RCTL E &hm RALT I &hm RGUI O &kp RET + &kp LSFT &kp Z &kp X &kp C &kp D &kp V &kp K &kp H &kp CMMA &kp DOT &kp FSLH &kp QUOT + &kp LCTL &kp LALT &kp LGUI < 1 BKSP < 2 SPC &kp LARW &kp DARW &kp UARW &kp RARW + >; + }; + lower { + bindings = < + &kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp PRSC + &kp DEL &trans &kp VOLU &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans + &trans &trans &kp VOLD &trans &trans &trans &trans &trans &trans &bt BT_PRV &bt BT_NXT &bt BT_CLR + &bootloader &reset &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 + >; + }; + + raise { + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp PRSC + &kp DEL &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH + &trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp TILD &kp HOME &kp PGUP &kp PGDN &kp END + &trans &trans &trans &trans &trans &trans &kp M_NEXT &kp M_VOLD &kp M_VOLU &kp M_PLAY + >; + }; + }; +}; \ No newline at end of file diff --git a/app/boards/shields/tg4x/tg4x.overlay b/app/boards/shields/tg4x/tg4x.overlay new file mode 100644 index 0000000..acab2e3 --- /dev/null +++ b/app/boards/shields/tg4x/tg4x.overlay @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2020 Pete Johanson, Richard Jones + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <7>; + rows = <8>; + map = < + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,5) + RC(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) RC(1,6) RC(5,0) RC(5,1) RC(5,2) RC(5,3) RC(5,4) + RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(6,0) RC(6,1) RC(6,2) RC(6,3) RC(6,4) + RC(3,0) RC(3,1) RC(3,2) RC(3,4) RC(3,5) RC(7,1) RC(7,2) RC(7,3) RC(7,4) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + diode-direction = "col2row"; + + col-gpios + = <&pro_micro_d 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 14 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; + + row-gpios + = <&pro_micro_a 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_a 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 2 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + +}; + -- cgit v1.2.3 From e993378b2a1705f97a5cca95d16810ab766f8d94 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 1 Oct 2020 11:24:57 -0400 Subject: chore: Fix some accidental formatting issues. --- app/drivers/zephyr/kscan_gpio_matrix.c | 69 ++++++++++++++++------------------ 1 file changed, 32 insertions(+), 37 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 5fa618b..62008e3 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -72,7 +72,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -100,17 +100,18 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ - } \ - static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ - return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ - kscan_gpio_input_configs_##n(dev), INST_INPUT_LEN(n), \ - GPIO_INT_DISABLE); \ - }), ()) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + ( \ + static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts( \ + kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), \ + INST_INPUT_LEN(n), GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ + } static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ + return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ + kscan_gpio_input_configs_##n(dev), \ + INST_INPUT_LEN(n), GPIO_INT_DISABLE); \ + }), \ + ()) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ @@ -133,8 +134,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (kscan_gpio_disable_interrupts_##n(dev);),()) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_disable_interrupts_##n(dev);), \ + ()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -152,8 +153,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ /*Re-enable interrupts so that they can be triggered again for future press/release*/ \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (kscan_gpio_enable_interrupts_##n(dev);), ()) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -201,29 +201,24 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { \ - return err; \ - } \ - return kscan_gpio_read_##n(dev);), \ - (struct kscan_gpio_data_##n *data = dev->driver_data; \ - k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); \ - return 0;)) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { return err; } return kscan_gpio_read_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); return 0;)) \ }; \ static int kscan_gpio_disable_##n(struct device *dev) { \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (return kscan_gpio_disable_interrupts_##n(dev);), \ - (struct kscan_gpio_data_##n *data = dev->driver_data; \ - k_timer_stop(&data->poll_timer); \ - return 0;)) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (return kscan_gpio_disable_interrupts_##n(dev);), \ + (struct kscan_gpio_data_##n *data = dev->driver_data; \ + k_timer_stop(&data->poll_timer); return 0;)) \ }; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ - (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ - struct kscan_gpio_data_##n *data = \ - CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ - k_work_submit(&data->work.work); \ - })) \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ + struct kscan_gpio_data_##n *data = \ + CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ + k_work_submit(&data->work.work); \ + })) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -268,7 +263,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ data->dev = dev; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);)) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ -- cgit v1.2.3 From 028dfae92e2b0900514182f096959b07a7204ab3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 1 Oct 2020 11:40:49 -0400 Subject: chore: Fix remaining formatting issues. --- app/drivers/zephyr/kscan_gpio_direct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index c3414fb..d6dab4d 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_0(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_1(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ -- cgit v1.2.3 From 307a8d09db78b95c858c41bd5549c721da7eb1f8 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 1 Oct 2020 17:18:01 -0400 Subject: feat(usb): Function to access latest USB status. * To be leveraged by upcoming power management work. --- app/include/zmk/usb_hid.h | 2 ++ app/src/usb_hid.c | 2 ++ 2 files changed, 4 insertions(+) (limited to 'app') diff --git a/app/include/zmk/usb_hid.h b/app/include/zmk/usb_hid.h index 7ee2629..83a4540 100644 --- a/app/include/zmk/usb_hid.h +++ b/app/include/zmk/usb_hid.h @@ -14,4 +14,6 @@ int zmk_usb_hid_init(); +enum usb_dc_status_code zmk_usb_hid_get_status(); + int zmk_usb_hid_send_report(u8_t *report, size_t len); diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c index 530ffea..64addae 100644 --- a/app/src/usb_hid.c +++ b/app/src/usb_hid.c @@ -28,6 +28,8 @@ static const struct hid_ops ops = { .int_in_ready = in_ready_cb, }; +enum usb_dc_status_code zmk_usb_hid_get_status() { return usb_status; } + int zmk_usb_hid_send_report(const u8_t *report, size_t len) { switch (usb_status) { case USB_DC_SUSPEND: -- cgit v1.2.3 From c68e3d3e42b9ff1722b2c2b9728f5d3b85784a45 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 1 Oct 2020 11:26:54 +0530 Subject: Add missing licensing header Fixes #205 --- app/include/dt-bindings/zmk/keys.h | 5 +++++ app/include/dt-bindings/zmk/kscan-mock.h | 6 ++++++ app/include/dt-bindings/zmk/matrix-transform.h | 5 +++++ app/include/dt-bindings/zmk/rgb.h | 5 +++++ app/include/zmk/split/bluetooth/service.h | 6 ++++++ app/include/zmk/split/bluetooth/uuid.h | 6 ++++++ 6 files changed, 33 insertions(+) (limited to 'app') diff --git a/app/include/dt-bindings/zmk/keys.h b/app/include/dt-bindings/zmk/keys.h index d3dd634..a3b2229 100644 --- a/app/include/dt-bindings/zmk/keys.h +++ b/app/include/dt-bindings/zmk/keys.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #pragma once diff --git a/app/include/dt-bindings/zmk/kscan-mock.h b/app/include/dt-bindings/zmk/kscan-mock.h index d481899..eff218b 100644 --- a/app/include/dt-bindings/zmk/kscan-mock.h +++ b/app/include/dt-bindings/zmk/kscan-mock.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #define ZMK_MOCK_IS_PRESS(v) ((v & (0x01 << 31)) != 0) diff --git a/app/include/dt-bindings/zmk/matrix-transform.h b/app/include/dt-bindings/zmk/matrix-transform.h index 4fd3e6c..2989cb6 100644 --- a/app/include/dt-bindings/zmk/matrix-transform.h +++ b/app/include/dt-bindings/zmk/matrix-transform.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #define KT_ROW(item) (item >> 8) #define KT_COL(item) (item & 0xFF) diff --git a/app/include/dt-bindings/zmk/rgb.h b/app/include/dt-bindings/zmk/rgb.h index c2efda8..eb72180 100644 --- a/app/include/dt-bindings/zmk/rgb.h +++ b/app/include/dt-bindings/zmk/rgb.h @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ #define RGB_TOG 0 #define RGB_HUI 1 diff --git a/app/include/zmk/split/bluetooth/service.h b/app/include/zmk/split/bluetooth/service.h index 954e0cd..c2be512 100644 --- a/app/include/zmk/split/bluetooth/service.h +++ b/app/include/zmk/split/bluetooth/service.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once int zmk_split_bt_position_pressed(u8_t position); diff --git a/app/include/zmk/split/bluetooth/uuid.h b/app/include/zmk/split/bluetooth/uuid.h index a8dfbf6..a31884d 100644 --- a/app/include/zmk/split/bluetooth/uuid.h +++ b/app/include/zmk/split/bluetooth/uuid.h @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #pragma once #include -- cgit v1.2.3 From 38a418a1d16707d721d85900c0c7c637cd1795a3 Mon Sep 17 00:00:00 2001 From: David Barr Date: Fri, 2 Oct 2020 14:16:59 +0100 Subject: updates as per PR changes (i hope) --- app/boards/shields/cradio/Kconfig.defconfig | 7 +++---- app/boards/shields/cradio/Kconfig.shield | 2 +- app/boards/shields/cradio/cradio.dtsi | 23 ++++++++++------------- app/boards/shields/cradio/cradio_left.conf | 3 +++ app/boards/shields/cradio/cradio_left.overlay | 7 +------ app/boards/shields/cradio/cradio_right.conf | 3 +++ app/boards/shields/cradio/cradio_right.overlay | 3 ++- 7 files changed, 23 insertions(+), 25 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index ab38e25..46799b9 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -1,10 +1,9 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + config ZMK_KEYBOARD_NAME default "cradio" -# Unable to use interrupts as the same pin number is used -# across A & B controllers, and STM32F303CCT6 can't enable -# interrutps for multiple controllers for the same "line" -# for the external interrupts. config ZMK_KSCAN_GPIO_POLLING default y diff --git a/app/boards/shields/cradio/Kconfig.shield b/app/boards/shields/cradio/Kconfig.shield index 0385d23..71a439e 100644 --- a/app/boards/shields/cradio/Kconfig.shield +++ b/app/boards/shields/cradio/Kconfig.shield @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Pete Johanson +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config SHIELD_CRADIO diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index 19225f9..582f58a 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -1,8 +1,9 @@ /* * Copyright (c) 2020 Pete Johanson * - * SPDX-License-Identifier: MIT + * Copyright (c) 2020 The ZMK Contributors */ + #include / { @@ -16,31 +17,27 @@ columns = <34>; rows = <1>; map = < -RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) -RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) -RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) -RC(0,15) RC(0,16) RC(0,33) RC(0,32) ->; + RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) + RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) + RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) + RC(0,15) RC(0,16) RC(0,33) RC(0,32) + >; - }; - kscan0: kscan { compatible = "zmk,kscan-gpio-direct"; label = "KSCAN"; }; - - - bt_unpair_combo: bt_unpair_combo { compatible = "zmk,bt-unpair-combo"; }; - }; + }; + }; &kscan0 { input-gpios - = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> + = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 1 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 2 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> diff --git a/app/boards/shields/cradio/cradio_left.conf b/app/boards/shields/cradio/cradio_left.conf index 1e028a7..405f04d 100644 --- a/app/boards/shields/cradio/cradio_left.conf +++ b/app/boards/shields/cradio/cradio_left.conf @@ -1,2 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/cradio/cradio_left.overlay b/app/boards/shields/cradio/cradio_left.overlay index c660072..6caf8e3 100644 --- a/app/boards/shields/cradio/cradio_left.overlay +++ b/app/boards/shields/cradio/cradio_left.overlay @@ -1,11 +1,6 @@ /* * Copyright (c) 2020 Pete Johanson * - * SPDX-License-Identifier: MIT + * Copyright (c) 2020 The ZMK Contributors */ -#include "cradio.dtsi" -&bt_unpair_combo { - - key-positions = <0 16>; -}; diff --git a/app/boards/shields/cradio/cradio_right.conf b/app/boards/shields/cradio/cradio_right.conf index 990cf7c..bd2c93b 100644 --- a/app/boards/shields/cradio/cradio_right.conf +++ b/app/boards/shields/cradio/cradio_right.conf @@ -1,2 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + CONFIG_ZMK_SPLIT=y CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay index 3469199..09efc53 100644 --- a/app/boards/shields/cradio/cradio_right.overlay +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -1,8 +1,9 @@ /* * Copyright (c) 2020 Pete Johanson * - * SPDX-License-Identifier: MIT + * Copyright (c) 2020 The ZMK Contributors */ + #include "cradio.dtsi" &default_transform { -- cgit v1.2.3 From 260044ae5e8dfc531ed98d08d0a3c9b9328e2ffe Mon Sep 17 00:00:00 2001 From: David Barr Date: Fri, 2 Oct 2020 14:17:35 +0100 Subject: Delete default.keymap --- app/boards/shields/cradio/default.keymap | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 app/boards/shields/cradio/default.keymap (limited to 'app') diff --git a/app/boards/shields/cradio/default.keymap b/app/boards/shields/cradio/default.keymap deleted file mode 100644 index 0821005..0000000 --- a/app/boards/shields/cradio/default.keymap +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include - - -/ { - keymap0: keymap { - compatible = "zmk,keymap"; - - default_layer { - 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 SCLN - &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp DEL &kp RET &kp RET &kp SPC - - >; - }; - }; -}; -- cgit v1.2.3 From f6f8abe05514c3588c4aa4a56897462c377bcab6 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sat, 26 Sep 2020 18:39:13 -0500 Subject: fix(ec11): allow more than one encoder Fixes "device.h:101:11: error: redefinition of '__device_ec11'" in firmware that has more than one encoder. --- app/drivers/zephyr/ec11.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/drivers/zephyr/ec11.c b/app/drivers/zephyr/ec11.c index a4e96c2..00d0090 100644 --- a/app/drivers/zephyr/ec11.c +++ b/app/drivers/zephyr/ec11.c @@ -142,7 +142,7 @@ int ec11_init(struct device *dev) { .b_flags = DT_INST_GPIO_FLAGS(n, b_gpios), \ COND_CODE_0(DT_INST_NODE_HAS_PROP(n, resolution), (1), (DT_INST_PROP(n, resolution))), \ }; \ - DEVICE_AND_API_INIT(ec11, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \ + DEVICE_AND_API_INIT(ec11_##n, DT_INST_LABEL(n), ec11_init, &ec11_data_##n, &ec11_cfg_##n, \ POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, &ec11_driver_api); DT_INST_FOREACH_STATUS_OKAY(EC11_INST) \ No newline at end of file -- cgit v1.2.3 From fc5915b2001c80df5ab2db72b04d86a083e27556 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sun, 4 Oct 2020 12:33:12 -0500 Subject: improvement(kscan): use ARRAY_SIZE macro --- app/src/kscan_composite.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'app') diff --git a/app/src/kscan_composite.c b/app/src/kscan_composite.c index 0249140..f8e8d60 100644 --- a/app/src/kscan_composite.c +++ b/app/src/kscan_composite.c @@ -38,8 +38,7 @@ struct kscan_composite_data { }; static int kscan_composite_enable_callback(struct device *dev) { - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_enable_callback(device_get_binding(cfg->label)); @@ -48,8 +47,7 @@ static int kscan_composite_enable_callback(struct device *dev) { } static int kscan_composite_disable_callback(struct device *dev) { - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_disable_callback(device_get_binding(cfg->label)); @@ -63,8 +61,7 @@ static void kscan_composite_child_callback(struct device *child_dev, u32_t row, struct device *dev = device_get_binding(DT_INST_LABEL(0)); struct kscan_composite_data *data = dev->driver_data; - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; if (device_get_binding(cfg->label) != child_dev) { @@ -82,8 +79,7 @@ static int kscan_composite_configure(struct device *dev, kscan_callback_t callba return -EINVAL; } - for (int i = 0; i < sizeof(kscan_composite_children) / sizeof(kscan_composite_children[0]); - i++) { + for (int i = 0; i < ARRAY_SIZE(kscan_composite_children); i++) { const struct kscan_composite_child_config *cfg = &kscan_composite_children[i]; kscan_config(device_get_binding(cfg->label), &kscan_composite_child_callback); -- cgit v1.2.3 From 4121b07f7f75b81cf1d533632fde858074b0fc03 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sun, 4 Oct 2020 14:03:55 -0500 Subject: fix(kscan): fix direct GPIO when using interrupts Fixed initializing interrupts for direct GPIO when CONFIG_ZMK_KSCAN_DIRECT_POLLING is not enabled. IS_ENABLED() is needed to map the possibly-undefined value to 0 or 1 so COND_CODE_0() and COND_CODE_1() work. --- app/drivers/zephyr/kscan_gpio_direct.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_direct.c b/app/drivers/zephyr/kscan_gpio_direct.c index d6dab4d..4818c99 100644 --- a/app/drivers/zephyr/kscan_gpio_direct.c +++ b/app/drivers/zephyr/kscan_gpio_direct.c @@ -173,7 +173,7 @@ static const struct kscan_driver_api gpio_driver_api = { #define INST_INPUT_LEN(n) DT_INST_PROP_LEN(n, input_gpios) #define GPIO_INST_INIT(n) \ - COND_CODE_0(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_0(IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (static struct kscan_gpio_irq_callback irq_callbacks_##n[INST_INPUT_LEN(n)];), ()) \ static struct kscan_gpio_data kscan_gpio_data_##n = { \ .inputs = {[INST_INPUT_LEN(n) - 1] = NULL}}; \ @@ -195,7 +195,7 @@ static const struct kscan_driver_api gpio_driver_api = { return err; \ } \ COND_CODE_0( \ - CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (irq_callbacks_##n[i].work = &data->work; \ irq_callbacks_##n[i].debounce_period = cfg->debounce_period; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ @@ -208,7 +208,7 @@ static const struct kscan_driver_api gpio_driver_api = { ()) \ } \ data->dev = dev; \ - COND_CODE_1(CONFIG_ZMK_KSCAN_DIRECT_POLLING, \ + COND_CODE_1(IS_ENABLED(CONFIG_ZMK_KSCAN_DIRECT_POLLING), \ (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ if (cfg->debounce_period > 0) { \ k_delayed_work_init(&data->work.delayed, kscan_gpio_work_handler); \ -- cgit v1.2.3 From bbf5a5905a973d6d23457d2e7bf15bf6bac234c3 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 4 Oct 2020 18:18:44 -0400 Subject: refactor(usb): Report USB status w/o HID output. --- app/CMakeLists.txt | 2 +- app/Kconfig | 6 +++- app/include/zmk/usb.h | 19 +++++++++++ app/include/zmk/usb_hid.h | 19 ----------- app/src/endpoints.c | 2 +- app/src/usb.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++ app/src/usb_hid.c | 79 ------------------------------------------- 7 files changed, 112 insertions(+), 101 deletions(-) create mode 100644 app/include/zmk/usb.h delete mode 100644 app/include/zmk/usb_hid.h create mode 100644 app/src/usb.c delete mode 100644 app/src/usb_hid.c (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3e0560b..5c77c54 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -54,7 +54,7 @@ target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL app PRIVATE src/split/ target_sources_ifdef(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL app PRIVATE src/split/bluetooth/central.c) target_sources_ifdef(CONFIG_ZMK_KSCAN_MOCK_DRIVER app PRIVATE src/kscan_mock.c) target_sources_ifdef(CONFIG_ZMK_KSCAN_COMPOSITE_DRIVER app PRIVATE src/kscan_composite.c) -target_sources_ifdef(CONFIG_ZMK_USB app PRIVATE src/usb_hid.c) +target_sources_ifdef(CONFIG_USB app PRIVATE src/usb.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/hog.c) target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/rgb_underglow.c) target_sources(app PRIVATE src/endpoints.c) diff --git a/app/Kconfig b/app/Kconfig index ccd40da..9398fce 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -21,12 +21,16 @@ menuconfig ZMK_USB select USB_DEVICE_STACK select USB_DEVICE_HID -if ZMK_USB +if USB config ZMK_USB_INIT_PRIORITY int "Init Priority" default 50 +endif + +if ZMK_USB + config USB_NUMOF_EP_WRITE_RETRIES default 10 diff --git a/app/include/zmk/usb.h b/app/include/zmk/usb.h new file mode 100644 index 0000000..452fd54 --- /dev/null +++ b/app/include/zmk/usb.h @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include + +#include +#include + +enum usb_dc_status_code zmk_usb_get_status(); + +#ifdef CONFIG_ZMK_USB +int zmk_usb_hid_send_report(u8_t *report, size_t len); +#endif /* CONFIG_ZMK_USB */ \ No newline at end of file diff --git a/app/include/zmk/usb_hid.h b/app/include/zmk/usb_hid.h deleted file mode 100644 index 83a4540..0000000 --- a/app/include/zmk/usb_hid.h +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2020 The ZMK Contributors - * - * SPDX-License-Identifier: MIT - */ - -#pragma once - -#include -#include - -#include -#include - -int zmk_usb_hid_init(); - -enum usb_dc_status_code zmk_usb_hid_get_status(); - -int zmk_usb_hid_send_report(u8_t *report, size_t len); diff --git a/app/src/endpoints.c b/app/src/endpoints.c index ae78587..79d294e 100644 --- a/app/src/endpoints.c +++ b/app/src/endpoints.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include diff --git a/app/src/usb.c b/app/src/usb.c new file mode 100644 index 0000000..434b3d4 --- /dev/null +++ b/app/src/usb.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include + +#include +#include +#include + +#include +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +static enum usb_dc_status_code usb_status = USB_DC_UNKNOWN; + +#ifdef CONFIG_ZMK_USB + +static struct device *hid_dev; + +static K_SEM_DEFINE(hid_sem, 1, 1); + +static void in_ready_cb(void) { k_sem_give(&hid_sem); } + +static const struct hid_ops ops = { + .int_in_ready = in_ready_cb, +}; + +int zmk_usb_hid_send_report(const u8_t *report, size_t len) { + switch (usb_status) { + case USB_DC_SUSPEND: + return usb_wakeup_request(); + case USB_DC_ERROR: + case USB_DC_RESET: + case USB_DC_DISCONNECTED: + case USB_DC_UNKNOWN: + return -ENODEV; + default: + k_sem_take(&hid_sem, K_MSEC(30)); + int err = hid_int_ep_write(hid_dev, report, len, NULL); + + if (err) { + k_sem_give(&hid_sem); + } + + return err; + } +} + +#endif /* CONFIG_ZMK_USB */ + +enum usb_dc_status_code zmk_usb_get_status() { return usb_status; } + +void usb_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; }; + +static int zmk_usb_init(struct device *_arg) { + int usb_enable_ret; + +#ifdef CONFIG_ZMK_USB + hid_dev = device_get_binding("HID_0"); + if (hid_dev == NULL) { + LOG_ERR("Unable to locate HID device"); + return -EINVAL; + } + + usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops); + + usb_hid_init(hid_dev); + +#endif /* CONFIG_ZMK_USB */ + + usb_enable_ret = usb_enable(usb_status_cb); + + if (usb_enable_ret != 0) { + LOG_ERR("Unable to enable USB"); + return -EINVAL; + } + + return 0; +} + +SYS_INIT(zmk_usb_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY); diff --git a/app/src/usb_hid.c b/app/src/usb_hid.c deleted file mode 100644 index 64addae..0000000 --- a/app/src/usb_hid.c +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2020 The ZMK Contributors - * - * SPDX-License-Identifier: MIT - */ - -#include -#include - -#include -#include -#include - -#include -#include - -LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); - -static enum usb_dc_status_code usb_status = USB_DC_UNKNOWN; - -static struct device *hid_dev; - -static K_SEM_DEFINE(hid_sem, 1, 1); - -static void in_ready_cb(void) { k_sem_give(&hid_sem); } - -static const struct hid_ops ops = { - .int_in_ready = in_ready_cb, -}; - -enum usb_dc_status_code zmk_usb_hid_get_status() { return usb_status; } - -int zmk_usb_hid_send_report(const u8_t *report, size_t len) { - switch (usb_status) { - case USB_DC_SUSPEND: - return usb_wakeup_request(); - case USB_DC_ERROR: - case USB_DC_RESET: - case USB_DC_DISCONNECTED: - case USB_DC_UNKNOWN: - return -ENODEV; - default: - k_sem_take(&hid_sem, K_MSEC(30)); - int err = hid_int_ep_write(hid_dev, report, len, NULL); - - if (err) { - k_sem_give(&hid_sem); - } - - return err; - } -} - -void usb_hid_status_cb(enum usb_dc_status_code status, const u8_t *params) { usb_status = status; }; - -static int zmk_usb_hid_init(struct device *_arg) { - int usb_enable_ret; - - hid_dev = device_get_binding("HID_0"); - if (hid_dev == NULL) { - LOG_ERR("Unable to locate HID device"); - return -EINVAL; - } - - usb_hid_register_device(hid_dev, zmk_hid_report_desc, sizeof(zmk_hid_report_desc), &ops); - - usb_hid_init(hid_dev); - - usb_enable_ret = usb_enable(usb_hid_status_cb); - - if (usb_enable_ret != 0) { - LOG_ERR("Unable to enable USB"); - return -EINVAL; - } - - return 0; -} - -SYS_INIT(zmk_usb_hid_init, APPLICATION, CONFIG_ZMK_USB_INIT_PRIORITY); -- cgit v1.2.3 From 9be566603e2eb248fbaa7af65cba42d5c06dbd33 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 6 Aug 2020 09:30:31 -0400 Subject: feat(kscan): Use PORT events for kscan matrix interrupts * Lower power usage compared to regular interrupts on nrf52. --- app/boards/arm/nice_nano/nice_nano.dts | 4 ++++ app/drivers/zephyr/kscan_gpio_matrix.c | 16 ++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 2e9556b..3ffb0ea 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -31,6 +31,10 @@ }; +&gpiote { + status = "okay"; +}; + &gpio0 { status = "okay"; }; diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index 62008e3..cd79324 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -64,6 +64,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_irq_callback_##n { \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) * work; \ struct gpio_callback callback; \ + struct device *dev; \ }; \ static struct kscan_gpio_irq_callback_##n irq_callbacks_##n[INST_INPUT_LEN(n)]; \ struct kscan_gpio_config_##n { \ @@ -105,7 +106,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ return kscan_gpio_config_interrupts( \ kscan_gpio_input_devices_##n(dev), kscan_gpio_input_configs_##n(dev), \ - INST_INPUT_LEN(n), GPIO_INT_DEBOUNCE | GPIO_INT_EDGE_BOTH); \ + INST_INPUT_LEN(n), GPIO_INT_LEVEL_ACTIVE); \ } static int kscan_gpio_disable_interrupts_##n(struct device *dev) { \ return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), \ @@ -113,10 +114,13 @@ static int kscan_gpio_config_interrupts(struct device **devices, }), \ ()) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ + int err; \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ struct device *in_dev = kscan_gpio_output_devices_##n(dev)[i]; \ const struct kscan_gpio_item_config *cfg = &kscan_gpio_output_configs_##n(dev)[i]; \ - gpio_pin_set(in_dev, cfg->pin, value); \ + if ((err = gpio_pin_set(in_dev, cfg->pin, value))) { \ + LOG_DBG("FAILED TO SET OUTPUT %d to %d", cfg->pin, err); \ + } \ } \ } \ static void kscan_gpio_set_matrix_state_##n( \ @@ -134,8 +138,6 @@ static int kscan_gpio_config_interrupts(struct device **devices, /* Disable our interrupts temporarily while we scan, to avoid */ \ /* re-entry while we iterate columns and set them active one by one */ \ /* to get pressed state for each matrix cell. */ \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_disable_interrupts_##n(dev);), \ - ()) \ kscan_gpio_set_output_state_##n(dev, 0); \ for (int o = 0; o < INST_OUTPUT_LEN(n); o++) { \ struct device *out_dev = kscan_gpio_output_devices_##n(dev)[o]; \ @@ -152,8 +154,6 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ /* Set all our outputs as active again. */ \ kscan_gpio_set_output_state_##n(dev, 1); \ - /*Re-enable interrupts so that they can be triggered again for future press/release*/ \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (kscan_gpio_enable_interrupts_##n(dev);), ()) \ for (int r = 0; r < INST_MATRIX_ROWS(n); r++) { \ for (int c = 0; c < INST_MATRIX_COLS(n); c++) { \ bool pressed = read_state[r][c]; \ @@ -172,6 +172,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, k_delayed_work_cancel(&data->work); \ k_delayed_work_submit(&data->work, K_MSEC(5)); \ })) \ + } else { \ + kscan_gpio_enable_interrupts_##n(dev); \ } \ return 0; \ } \ @@ -183,6 +185,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, gpio_port_pins_t pin) { \ struct kscan_gpio_irq_callback_##n *data = \ CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + kscan_gpio_disable_interrupts_##n(data->dev); \ COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ k_delayed_work_cancel(data->work); \ k_delayed_work_submit(data->work, \ @@ -238,6 +241,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, LOG_DBG("Configured pin %d on %s for input", in_cfg->pin, in_cfg->label); \ } \ irq_callbacks_##n[i].work = &data->work; \ + irq_callbacks_##n[i].dev = dev; \ gpio_init_callback(&irq_callbacks_##n[i].callback, \ kscan_gpio_irq_callback_handler_##n, BIT(in_cfg->pin)); \ err = gpio_add_callback(input_devices[i], &irq_callbacks_##n[i].callback); \ -- cgit v1.2.3 From c54decd1443a41bd68905256db6286d51324c8e4 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Thu, 1 Oct 2020 23:57:16 +0800 Subject: Added Makerdiary M.2 module --- app/boards/arm/nrf52840_m2/CMakeLists.txt | 13 ++++ app/boards/arm/nrf52840_m2/Kconfig | 10 +++ app/boards/arm/nrf52840_m2/Kconfig.board | 10 +++ app/boards/arm/nrf52840_m2/Kconfig.defconfig | 30 ++++++++ app/boards/arm/nrf52840_m2/board.cmake | 9 +++ app/boards/arm/nrf52840_m2/nrf52840_m2.dts | 97 ++++++++++++++++++++++++ app/boards/arm/nrf52840_m2/nrf52840_m2.yaml | 15 ++++ app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig | 23 ++++++ 8 files changed, 207 insertions(+) create mode 100644 app/boards/arm/nrf52840_m2/CMakeLists.txt create mode 100644 app/boards/arm/nrf52840_m2/Kconfig create mode 100644 app/boards/arm/nrf52840_m2/Kconfig.board create mode 100644 app/boards/arm/nrf52840_m2/Kconfig.defconfig create mode 100644 app/boards/arm/nrf52840_m2/board.cmake create mode 100644 app/boards/arm/nrf52840_m2/nrf52840_m2.dts create mode 100644 app/boards/arm/nrf52840_m2/nrf52840_m2.yaml create mode 100644 app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig (limited to 'app') diff --git a/app/boards/arm/nrf52840_m2/CMakeLists.txt b/app/boards/arm/nrf52840_m2/CMakeLists.txt new file mode 100644 index 0000000..84b2ab9 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/CMakeLists.txt @@ -0,0 +1,13 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +set_property(GLOBAL APPEND PROPERTY extra_post_build_commands + COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py + -c + -b 0x26000 + -f 0xADA52840 + -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2 + ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin +) diff --git a/app/boards/arm/nrf52840_m2/Kconfig b/app/boards/arm/nrf52840_m2/Kconfig new file mode 100644 index 0000000..faff492 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig @@ -0,0 +1,10 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +config BOARD_ENABLE_DCDC + bool "Enable DCDC mode" + select SOC_DCDC_NRF52X + default y + depends on BOARD_NRF52840_M2 diff --git a/app/boards/arm/nrf52840_m2/Kconfig.board b/app/boards/arm/nrf52840_m2/Kconfig.board new file mode 100644 index 0000000..6ade68c --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig.board @@ -0,0 +1,10 @@ +# Maker Diary nrf52840 M.2 board configuration +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +config BOARD_NRF52840_M2 + bool "nrf52480_m2" + depends on SOC_NRF52840_QIAA + diff --git a/app/boards/arm/nrf52840_m2/Kconfig.defconfig b/app/boards/arm/nrf52840_m2/Kconfig.defconfig new file mode 100644 index 0000000..98fcd08 --- /dev/null +++ b/app/boards/arm/nrf52840_m2/Kconfig.defconfig @@ -0,0 +1,30 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +if BOARD_NRF52840_M2 + +config BOARD + default "nrf52480_m2" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config BT_CTLR + default BT + +config ZMK_BLE + default y + +config ZMK_USB + default y + +endif # BOARD_NRF52840_M2 diff --git a/app/boards/arm/nrf52840_m2/board.cmake b/app/boards/arm/nrf52840_m2/board.cmake new file mode 100644 index 0000000..f521e2c --- /dev/null +++ b/app/boards/arm/nrf52840_m2/board.cmake @@ -0,0 +1,9 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") + +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.dts b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts new file mode 100644 index 0000000..fb5b0ff --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.dts @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * SPDX-License-Identifier: MIT + */ + +/dts-v1/; +#include + +/ { + model = "Makerdiary nRF52840 M.2 module"; + compatible = "makerdiary,nrf52840_m2"; + + chosen { + zephyr,code-partition = &code_partition; + //zephyr,console = &uart0; + //zephyr,bt-mon-uart = &uart0; + //zephyr,bt-c2h-uart = &uart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + }; + + leds { + compatible = "gpio-leds"; + red_led: led_0 { + gpios = <&gpio0 30 GPIO_ACTIVE_HIGH>; + label = "Red LED"; + }; + green_led: led_1 { + gpios = <&gpio0 29 GPIO_ACTIVE_HIGH>; + label = "Green LED"; + }; + blue_led: led_2 { + gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>; + label = "Blue LED"; + }; + }; + +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uart"; + status = "okay"; + current-speed = <115200>; + tx-pin = <16>; + rx-pin = <15>; + rts-pin = <14>; + cts-pin = <13>; +}; + +&usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; +}; + + +&flash0 { + /* + * For more information, see: + * http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + boot_partition: partition@0 { + label = "adafruit_boot"; + reg = <0x000000000 0x0000C000>; + }; + code_partition: partition@26000 { + label = "code_partition"; + reg = <0x00026000 0x000d2000>; + }; + + /* + * The flash starting at 0x000f8000 and ending at + * 0x000fffff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@f8000 { + label = "storage"; + reg = <0x000f8000 0x00008000>; + }; + }; +}; diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml b/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml new file mode 100644 index 0000000..0a999bb --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2.yaml @@ -0,0 +1,15 @@ +identifier: nrf52840_m2 +name: Makerdiary nRF52840 M.2 module +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - ble + - ieee802154 + - pwm + - watchdog diff --git a/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig new file mode 100644 index 0000000..e74438b --- /dev/null +++ b/app/boards/arm/nrf52840_m2/nrf52840_m2_defconfig @@ -0,0 +1,23 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_NRF52840_M2=y + +# Enable MPU +CONFIG_ARM_MPU=y + +# enable GPIO +CONFIG_GPIO=y + +CONFIG_USE_DT_CODE_PARTITION=y + +CONFIG_MPU_ALLOW_FLASH_WRITE=y +CONFIG_NVS=y +CONFIG_SETTINGS_NVS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y -- cgit v1.2.3 From 9d06c730ba8b70429ecb67d3ff502ed1fde584bd Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Fri, 2 Oct 2020 00:18:30 +0800 Subject: Added Makerdiary M60 keyboard --- app/boards/shields/m60/Kconfig.defconfig | 10 +++++ app/boards/shields/m60/Kconfig.shield | 5 +++ app/boards/shields/m60/m60.conf | 0 app/boards/shields/m60/m60.keymap | 26 +++++++++++++ app/boards/shields/m60/m60.overlay | 65 ++++++++++++++++++++++++++++++++ app/boards/shields/m60/readme.md | 15 ++++++++ 6 files changed, 121 insertions(+) create mode 100644 app/boards/shields/m60/Kconfig.defconfig create mode 100644 app/boards/shields/m60/Kconfig.shield create mode 100644 app/boards/shields/m60/m60.conf create mode 100644 app/boards/shields/m60/m60.keymap create mode 100644 app/boards/shields/m60/m60.overlay create mode 100644 app/boards/shields/m60/readme.md (limited to 'app') diff --git a/app/boards/shields/m60/Kconfig.defconfig b/app/boards/shields/m60/Kconfig.defconfig new file mode 100644 index 0000000..e358a58 --- /dev/null +++ b/app/boards/shields/m60/Kconfig.defconfig @@ -0,0 +1,10 @@ + +if SHIELD_M60 + +config ZMK_KEYBOARD_NAME + default "m60" + +config ZMK_KSCAN_MATRIX_POLLING + default y + +endif diff --git a/app/boards/shields/m60/Kconfig.shield b/app/boards/shields/m60/Kconfig.shield new file mode 100644 index 0000000..4ed58c4 --- /dev/null +++ b/app/boards/shields/m60/Kconfig.shield @@ -0,0 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT + +config SHIELD_M60 + def_bool $(shields_list_contains,m60) diff --git a/app/boards/shields/m60/m60.conf b/app/boards/shields/m60/m60.conf new file mode 100644 index 0000000..e69de29 diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap new file mode 100644 index 0000000..aa0fa75 --- /dev/null +++ b/app/boards/shields/m60/m60.keymap @@ -0,0 +1,26 @@ +#include +#include +#include + +/ { + keymap0: keymap { + compatible = "zmk,keymap"; + + default_layer { +// ------------------------------------------------------------------------------------------ +// | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" | +// | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | +// | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | +// | CTL | WIN | ALT | SPACE | ALT | MO(1) | WIN | CTRL | +// ------------------------------------------------------------------------------------------ + bindings = < + &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp MINUS &kp EQL &kp BKSP + &kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp LBKT &kp RBKT &kp BSLH + &kp CLCK &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SCLN &kp QUOT &kp RET + &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp RSFT + &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp RGUI &kp RCTL + >; + }; + }; +}; diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay new file mode 100644 index 0000000..c20d452 --- /dev/null +++ b/app/boards/shields/m60/m60.overlay @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&gpio0 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio1 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio1 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 12 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&gpio0 11 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + col-gpios + = <&gpio0 19 GPIO_ACTIVE_HIGH> + , <&gpio0 20 GPIO_ACTIVE_HIGH> + , <&gpio0 21 GPIO_ACTIVE_HIGH> + , <&gpio0 22 GPIO_ACTIVE_HIGH> + , <&gpio0 23 GPIO_ACTIVE_HIGH> + , <&gpio0 24 GPIO_ACTIVE_HIGH> + , <&gpio0 25 GPIO_ACTIVE_HIGH> + , <&gpio0 26 GPIO_ACTIVE_HIGH> + ; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <8>; + rows = <8>; +// | MX1 | MX2 | MX3 | MX4 | MX5 | MX6 | MX7 | MX8 | MX9 | MX10 | MX11 | MX12 | MX13 | MX14 | +// | MX15 | MX16 | MX17 | MX18 | MX19 | MX20 | MX21 | MX22 | MX23 | MX24 | MX25 | MX26 | MX27 | MX28 | +// | MX29 | MX30 | MX31 | MX32 | MX33 | MX34 | MX35 | MX36 | MX37 | MX38 | MX39 | MX40 | MX41 | +// | MX42 | MX43 | MX44 | MX45 | MX46 | MX47 | MX48 | MX49 | MX50 | MX51 | MX52 | MX53 | +// | MX54 | MX55 | MX56 | MX57 | MX58 | MX59 | MX60 | MX61 | + map = < +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(1,0) RC(1,1) RC(1,2) RC(1,3) RC(1,4) RC(1,5) +RC(3,3) RC(3,2) RC(3,1) RC(3,0) RC(2,7) RC(2,6) RC(2,5) RC(2,4) RC(2,3) RC(2,2) RC(2,1) RC(2,0) RC(1,7) RC(1,6) +RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(4,0) RC(4,1) RC(4,2) RC(4,3) RC(4,4) RC(4,5) RC(4,6) RC(4,7) RC(5,0) +RC(6,4) RC(6,3) RC(6,2) RC(6,1) RC(6,0) RC(5,7) RC(5,6) RC(5,5) RC(5,4) RC(5,3) RC(5,2) RC(5,1) +RC(6,5) RC(6,6) RC(6,7) RC(7,0) RC(7,1) RC(7,2) RC(7,3) RC(7,4) + >; + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + key-positions = <0 53>; + }; + +}; + diff --git a/app/boards/shields/m60/readme.md b/app/boards/shields/m60/readme.md new file mode 100644 index 0000000..7eaf226 --- /dev/null +++ b/app/boards/shields/m60/readme.md @@ -0,0 +1,15 @@ +# [Makerdiary M60](https://wiki.makerdiary.com/m60) + +A 60% ANSI keyboard designed and manufactured by Makerdiary. +http://makerdairy.com + +## Features + +- Per key RGB LED. +- Uses makerdiary M.2 nRF52840 module +- Matrix wiring + +## Hardware Notes + +https://wiki.makerdiary.com/m60/developer_guide/hardware/ + -- cgit v1.2.3 From e2299836bccf21bf56a4d34c5ed2f53a2fa21da2 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Sat, 3 Oct 2020 17:35:17 +0800 Subject: Update contributors in all keymap files --- app/boards/shields/clueboard_california/clueboard_california.keymap | 6 ++++++ app/boards/shields/corne/corne.keymap | 6 ++++++ app/boards/shields/iris/iris.keymap | 2 +- app/boards/shields/kyria/kyria.keymap | 6 ++++++ app/boards/shields/lily58/lily58.keymap | 6 ++++++ app/boards/shields/m60/Kconfig.defconfig | 4 ++++ app/boards/shields/m60/Kconfig.shield | 2 ++ app/boards/shields/m60/m60.keymap | 6 ++++++ app/boards/shields/m60/m60.overlay | 1 + app/boards/shields/romac/romac.keymap | 2 +- app/boards/shields/sofle/sofle.keymap | 6 ++++++ app/boards/shields/splitreus62/splitreus62.keymap | 3 ++- 12 files changed, 47 insertions(+), 3 deletions(-) (limited to 'app') diff --git a/app/boards/shields/clueboard_california/clueboard_california.keymap b/app/boards/shields/clueboard_california/clueboard_california.keymap index 7a84b11..44a0b07 100644 --- a/app/boards/shields/clueboard_california/clueboard_california.keymap +++ b/app/boards/shields/clueboard_california/clueboard_california.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/boards/shields/corne/corne.keymap b/app/boards/shields/corne/corne.keymap index 5f0f15f..64d4a00 100644 --- a/app/boards/shields/corne/corne.keymap +++ b/app/boards/shields/corne/corne.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/iris/iris.keymap b/app/boards/shields/iris/iris.keymap index 6042ad7..8b06b1b 100644 --- a/app/boards/shields/iris/iris.keymap +++ b/app/boards/shields/iris/iris.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Kurtis Lew + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/kyria/kyria.keymap b/app/boards/shields/kyria/kyria.keymap index f689ef6..ac0d13f 100644 --- a/app/boards/shields/kyria/kyria.keymap +++ b/app/boards/shields/kyria/kyria.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 61c19f8..997a124 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/m60/Kconfig.defconfig b/app/boards/shields/m60/Kconfig.defconfig index e358a58..56695b9 100644 --- a/app/boards/shields/m60/Kconfig.defconfig +++ b/app/boards/shields/m60/Kconfig.defconfig @@ -1,3 +1,7 @@ +# +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT +# if SHIELD_M60 diff --git a/app/boards/shields/m60/Kconfig.shield b/app/boards/shields/m60/Kconfig.shield index 4ed58c4..47a28e2 100644 --- a/app/boards/shields/m60/Kconfig.shield +++ b/app/boards/shields/m60/Kconfig.shield @@ -1,5 +1,7 @@ +# # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT +# config SHIELD_M60 def_bool $(shields_list_contains,m60) diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap index aa0fa75..16ad247 100644 --- a/app/boards/shields/m60/m60.keymap +++ b/app/boards/shields/m60/m60.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/m60/m60.overlay b/app/boards/shields/m60/m60.overlay index c20d452..babae2d 100644 --- a/app/boards/shields/m60/m60.overlay +++ b/app/boards/shields/m60/m60.overlay @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: MIT */ + #include / { diff --git a/app/boards/shields/romac/romac.keymap b/app/boards/shields/romac/romac.keymap index 97ea9c5..31e1ce8 100644 --- a/app/boards/shields/romac/romac.keymap +++ b/app/boards/shields/romac/romac.keymap @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Richard Jones + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/sofle/sofle.keymap b/app/boards/shields/sofle/sofle.keymap index 1cbe742..e2ebc1a 100644 --- a/app/boards/shields/sofle/sofle.keymap +++ b/app/boards/shields/sofle/sofle.keymap @@ -1,3 +1,9 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + #include #include #include diff --git a/app/boards/shields/splitreus62/splitreus62.keymap b/app/boards/shields/splitreus62/splitreus62.keymap index 920e61a..07dd2ad 100644 --- a/app/boards/shields/splitreus62/splitreus62.keymap +++ b/app/boards/shields/splitreus62/splitreus62.keymap @@ -1,9 +1,10 @@ /* - * Copyright (c) 2020 Derek Schmell + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ + #include #include -- cgit v1.2.3 From b8cb5f939a3c018af13de7727c15d7765ea1f1c1 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Sat, 3 Oct 2020 18:21:22 +0800 Subject: M60 keymap update and misc changes * Updated M60 keymap * Make nrfjproj as default runner * Remove the polling config --- app/boards/arm/nrf52840_m2/board.cmake | 2 +- app/boards/shields/m60/Kconfig.defconfig | 3 --- app/boards/shields/m60/m60.keymap | 12 +++++++++++- 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/boards/arm/nrf52840_m2/board.cmake b/app/boards/arm/nrf52840_m2/board.cmake index f521e2c..55b44e2 100644 --- a/app/boards/arm/nrf52840_m2/board.cmake +++ b/app/boards/arm/nrf52840_m2/board.cmake @@ -5,5 +5,5 @@ board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") -include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) diff --git a/app/boards/shields/m60/Kconfig.defconfig b/app/boards/shields/m60/Kconfig.defconfig index 56695b9..e31d5a5 100644 --- a/app/boards/shields/m60/Kconfig.defconfig +++ b/app/boards/shields/m60/Kconfig.defconfig @@ -8,7 +8,4 @@ if SHIELD_M60 config ZMK_KEYBOARD_NAME default "m60" -config ZMK_KSCAN_MATRIX_POLLING - default y - endif diff --git a/app/boards/shields/m60/m60.keymap b/app/boards/shields/m60/m60.keymap index 16ad247..cbe356c 100644 --- a/app/boards/shields/m60/m60.keymap +++ b/app/boards/shields/m60/m60.keymap @@ -15,7 +15,7 @@ default_layer { // ------------------------------------------------------------------------------------------ // | ESC | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | BKSP | -// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | "|" | +// | TAB | Q | W | E | R | T | Y | U | I | O | P | [ | ] | \ | // | CAPS | A | S | D | F | G | H | J | K | L | ; | ' | ENTER | // | SHIFT | Z | X | C | V | B | N | M | , | . | / | SHIFT | // | CTL | WIN | ALT | SPACE | ALT | MO(1) | WIN | CTRL | @@ -28,5 +28,15 @@ &kp LCTL &kp LGUI &kp LALT &kp SPC &kp RALT &mo 1 &kp RGUI &kp RCTL >; }; + + fn_layer { + bindings = < +&kp GRAV &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &bootloader +&trans &bt BT_CLR &none &none &none &none &none &none &none &none &none &none &none &reset +&trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &none &none &trans +&trans &none &none &none &none &none &none &none &none &none &none &trans +&trans &trans &trans &trans &trans &trans &trans &trans + >; + }; }; }; -- cgit v1.2.3 From ce59223efe9062ac1da77bae93a3578ce0463b66 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 5 Oct 2020 23:40:29 -0400 Subject: fix(shields): Typo in makerdiary URL. --- app/boards/shields/m60/readme.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/m60/readme.md b/app/boards/shields/m60/readme.md index 7eaf226..e801c78 100644 --- a/app/boards/shields/m60/readme.md +++ b/app/boards/shields/m60/readme.md @@ -1,7 +1,7 @@ # [Makerdiary M60](https://wiki.makerdiary.com/m60) A 60% ANSI keyboard designed and manufactured by Makerdiary. -http://makerdairy.com +http://makerdiary.com ## Features @@ -12,4 +12,3 @@ http://makerdairy.com ## Hardware Notes https://wiki.makerdiary.com/m60/developer_guide/hardware/ - -- cgit v1.2.3 From a7496ab06425cab7de5fc7164b4ce5a34dd7107b Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 2 Oct 2020 02:09:38 -0400 Subject: feat(power): Initial deep sleep work. * New ZMK_SLEEP Kconfig symbol to enable the functionality. * Switch to PORT events that allows wake from deep sleep. * Initial basic power management policy, with idle ms, and ignoring deep sleep if we detect a USB connection. --- app/CMakeLists.txt | 1 + app/Kconfig | 20 +++++++++- app/drivers/zephyr/kscan_gpio_matrix.c | 58 +++++++++++++++------------- app/include/dt-bindings/zmk/bt.h | 2 +- app/src/power.c | 69 ++++++++++++++++++++++++++++++++++ 5 files changed, 121 insertions(+), 29 deletions(-) create mode 100644 app/src/power.c (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 5c77c54..3e59d75 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -23,6 +23,7 @@ zephyr_linker_sources(RODATA include/linker/zmk-events.ld) # Add your source file to the "app" target. This must come after # find_package(Zephyr) which defines the target. target_include_directories(app PRIVATE include) +target_sources_ifdef(CONFIG_ZMK_SLEEP app PRIVATE src/power.c) target_sources(app PRIVATE src/kscan.c) target_sources(app PRIVATE src/matrix_transform.c) target_sources(app PRIVATE src/hid.c) diff --git a/app/Kconfig b/app/Kconfig index 9398fce..edf5867 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -76,6 +76,25 @@ endif endmenu +menuconfig ZMK_SLEEP + bool "Enable deep sleep support" + imply USB + +if ZMK_SLEEP + +config SYS_POWER_DEEP_SLEEP_STATES + default y + +choice SYS_PM_POLICY + default SYS_PM_POLICY_APP +endchoice + +config ZMK_IDLE_SLEEP_TIMEOUT + int "Milliseconds to wait to sleep when going idle" + default 900000 + +endif + config ZMK_DISPLAY bool "ZMK display support" default n @@ -112,7 +131,6 @@ config ZMK_SPLIT_BLE_ROLE_CENTRAL config ZMK_SPLIT_BLE_ROLE_PERIPHERAL bool "Peripheral" - select BT_KEYS_OVERWRITE_OLDEST if ZMK_SPLIT_BLE_ROLE_PERIPHERAL diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index cd79324..a0b22e4 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -73,7 +73,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, }; \ struct kscan_gpio_data_##n { \ kscan_callback_t callback; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), (struct k_timer poll_timer;)) \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (struct k_timer poll_timer;), ()) \ struct COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work), (k_delayed_work)) work; \ bool matrix_state[INST_MATRIX_ROWS(n)][INST_MATRIX_COLS(n)]; \ struct device *rows[INST_MATRIX_ROWS(n)]; \ @@ -101,7 +101,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, return ( \ COND_CODE_0(DT_ENUM_IDX(DT_DRV_INST(n), diode_direction), (cfg->rows), (cfg->cols))); \ } \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ ( \ static int kscan_gpio_enable_interrupts_##n(struct device *dev) { \ return kscan_gpio_config_interrupts( \ @@ -111,8 +111,7 @@ static int kscan_gpio_config_interrupts(struct device **devices, return kscan_gpio_config_interrupts(kscan_gpio_input_devices_##n(dev), \ kscan_gpio_input_configs_##n(dev), \ INST_INPUT_LEN(n), GPIO_INT_DISABLE); \ - }), \ - ()) \ + })) \ static void kscan_gpio_set_output_state_##n(struct device *dev, int value) { \ int err; \ for (int i = 0; i < INST_OUTPUT_LEN(n); i++) { \ @@ -173,7 +172,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, k_delayed_work_submit(&data->work, K_MSEC(5)); \ })) \ } else { \ - kscan_gpio_enable_interrupts_##n(dev); \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (kscan_gpio_enable_interrupts_##n(dev);)) \ } \ return 0; \ } \ @@ -181,17 +181,20 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ - gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - kscan_gpio_disable_interrupts_##n(data->dev); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit(data->work, \ - K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ - } \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (static void kscan_gpio_irq_callback_handler_##n( \ + struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + kscan_gpio_disable_interrupts_##n(data->dev); \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), \ + ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit( \ + data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + })) \ + \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ static int kscan_gpio_configure_##n(struct device *dev, kscan_callback_t callback) { \ @@ -204,24 +207,25 @@ static int kscan_gpio_config_interrupts(struct device **devices, return 0; \ }; \ static int kscan_gpio_enable_##n(struct device *dev) { \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (int err = kscan_gpio_enable_interrupts_##n(dev); \ - if (err) { return err; } return kscan_gpio_read_##n(dev);), \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (struct kscan_gpio_data_##n *data = dev->driver_data; \ - k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); return 0;)) \ + k_timer_start(&data->poll_timer, K_MSEC(10), K_MSEC(10)); return 0;), \ + (int err = kscan_gpio_enable_interrupts_##n(dev); \ + if (err) { return err; } return kscan_gpio_read_##n(dev);)) \ }; \ static int kscan_gpio_disable_##n(struct device *dev) { \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ - (return kscan_gpio_disable_interrupts_##n(dev);), \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (struct kscan_gpio_data_##n *data = dev->driver_data; \ - k_timer_stop(&data->poll_timer); return 0;)) \ + k_timer_stop(&data->poll_timer); return 0;), \ + (return kscan_gpio_disable_interrupts_##n(dev);)) \ }; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ (static void kscan_gpio_timer_handler(struct k_timer *timer) { \ struct kscan_gpio_data_##n *data = \ CONTAINER_OF(timer, struct kscan_gpio_data_##n, poll_timer); \ k_work_submit(&data->work.work); \ - })) \ + }), \ + ()) \ static int kscan_gpio_init_##n(struct device *dev) { \ struct kscan_gpio_data_##n *data = dev->driver_data; \ int err; \ @@ -267,8 +271,8 @@ static int kscan_gpio_config_interrupts(struct device **devices, } \ } \ data->dev = dev; \ - COND_CODE_0(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ - (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);)) \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, \ + (k_timer_init(&data->poll_timer, kscan_gpio_timer_handler, NULL);), ()) \ (COND_CODE_0(DT_INST_PROP(n, debounce_period), (k_work_init), (k_delayed_work_init)))( \ &data->work, kscan_gpio_work_handler_##n); \ return 0; \ diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index 05fd65c..a403d35 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -18,4 +18,4 @@ defines these aliases up front. #define BT_CLR BT_CLR_CMD 0 #define BT_NXT BT_NXT_CMD 0 #define BT_PRV BT_PRV_CMD 0 -#define BT_SEL BT_SEL_CMD \ No newline at end of file +#define BT_SEL BT_SEL_CMD diff --git a/app/src/power.c b/app/src/power.c new file mode 100644 index 0000000..73b3f12 --- /dev/null +++ b/app/src/power.c @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +#include + +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include +#include +#include +#include + +static u32_t power_last_uptime; + +#define MAX_IDLE_MS CONFIG_ZMK_IDLE_SLEEP_TIMEOUT + +bool is_usb_power_present() { +#ifdef CONFIG_USB + enum usb_dc_status_code usb_status = zmk_usb_get_status(); + switch (usb_status) { + case USB_DC_DISCONNECTED: + case USB_DC_UNKNOWN: + return false; + default: + return true; + } +#else + return false; +#endif /* CONFIG_USB */ +} + +enum power_states sys_pm_policy_next_state(s32_t ticks) { +#ifdef CONFIG_SYS_POWER_DEEP_SLEEP_STATES +#ifdef CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 + s32_t current = k_uptime_get(); + if (power_last_uptime > 0 && !is_usb_power_present() && + current - power_last_uptime > MAX_IDLE_MS) { + return SYS_POWER_STATE_DEEP_SLEEP_1; + } +#endif /* CONFIG_HAS_SYS_POWER_STATE_DEEP_SLEEP_1 */ +#endif /* CONFIG_SYS_POWER_DEEP_SLEEP_STATES */ + + return SYS_POWER_STATE_ACTIVE; +} + +int power_event_listener(const struct zmk_event_header *eh) { + power_last_uptime = k_uptime_get(); + + return 0; +} + +int power_init() { + power_last_uptime = k_uptime_get(); + + return 0; +} + +ZMK_LISTENER(power, power_event_listener); +ZMK_SUBSCRIPTION(power, position_state_changed); +ZMK_SUBSCRIPTION(power, sensor_event); + +SYS_INIT(power_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY); \ No newline at end of file -- cgit v1.2.3 From d5d8d79a76a9fbe65981d4f5455097e5258d1564 Mon Sep 17 00:00:00 2001 From: David Barr Date: Wed, 7 Oct 2020 16:23:59 +0100 Subject: Update cradio_right.overlay --- app/boards/shields/cradio/cradio_right.overlay | 4 ---- 1 file changed, 4 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay index 09efc53..232d7d4 100644 --- a/app/boards/shields/cradio/cradio_right.overlay +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -9,7 +9,3 @@ &default_transform { col-offset = <17>; }; - -&bt_unpair_combo { - key-positions = <21 32>; -}; -- cgit v1.2.3 From f3eaa7e4247321042618a732596f842e5bb104da Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Wed, 7 Oct 2020 20:40:04 -0700 Subject: working shield, need to improve default keymap --- app/boards/shields/microdox/Kconfig.defconfig | 58 ++++++++++++++++++ app/boards/shields/microdox/Kconfig.shield | 9 +++ .../shields/microdox/boards/nice_nano.overlay | 29 +++++++++ app/boards/shields/microdox/microdox.conf | 6 ++ app/boards/shields/microdox/microdox.dtsi | 71 ++++++++++++++++++++++ app/boards/shields/microdox/microdox.keymap | 57 +++++++++++++++++ app/boards/shields/microdox/microdox_left.conf | 2 + app/boards/shields/microdox/microdox_left.overlay | 22 +++++++ app/boards/shields/microdox/microdox_right.conf | 2 + app/boards/shields/microdox/microdox_right.overlay | 26 ++++++++ 10 files changed, 282 insertions(+) create mode 100644 app/boards/shields/microdox/Kconfig.defconfig create mode 100644 app/boards/shields/microdox/Kconfig.shield create mode 100644 app/boards/shields/microdox/boards/nice_nano.overlay create mode 100644 app/boards/shields/microdox/microdox.conf create mode 100644 app/boards/shields/microdox/microdox.dtsi create mode 100644 app/boards/shields/microdox/microdox.keymap create mode 100644 app/boards/shields/microdox/microdox_left.conf create mode 100644 app/boards/shields/microdox/microdox_left.overlay create mode 100644 app/boards/shields/microdox/microdox_right.conf create mode 100644 app/boards/shields/microdox/microdox_right.overlay (limited to 'app') diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig new file mode 100644 index 0000000..218443f --- /dev/null +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -0,0 +1,58 @@ + +if SHIELD_MICRODOX_LEFT + +config ZMK_KEYBOARD_NAME + default "Microdox Left" + +endif + + +if SHIELD_MICRODOX_RIGHT + +config ZMK_KEYBOARD_NAME + default "Microdox Right" + +endif + +if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT + +config ZMK_SPLIT + default y + +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 + default 128 + +config LVGL_VER_RES + 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 diff --git a/app/boards/shields/microdox/Kconfig.shield b/app/boards/shields/microdox/Kconfig.shield new file mode 100644 index 0000000..7d7148d --- /dev/null +++ b/app/boards/shields/microdox/Kconfig.shield @@ -0,0 +1,9 @@ +# Copyright (c) 2020 Pete Johanson +# Copyright (c) 2020 Kellen Carey +# SPDX-License-Identifier: MIT + +config SHIELD_MICRODOX_LEFT + def_bool $(shields_list_contains,microdox_left) + +config SHIELD_MICRODOX_RIGHT + def_bool $(shields_list_contains,microdox_right) diff --git a/app/boards/shields/microdox/boards/nice_nano.overlay b/app/boards/shields/microdox/boards/nice_nano.overlay new file mode 100644 index 0000000..c7c3eb8 --- /dev/null +++ b/app/boards/shields/microdox/boards/nice_nano.overlay @@ -0,0 +1,29 @@ +&spi1 { + compatible = "nordic,nrf-spi"; + /* Cannot be used together with i2c0. */ + status = "okay"; + mosi-pin = <6>; + // Unused pins, needed for SPI definition, but not used by the ws2812 driver itself. + sck-pin = <5>; + miso-pin = <7>; + + led_strip: ws2812@0 { + compatible = "worldsemi,ws2812-spi"; + label = "SK6812mini"; + + /* SPI */ + reg = <0>; /* ignored, but necessary for SPI bindings */ + spi-max-frequency = <4000000>; + + /* WS2812 */ + chain-length = <6>; /* There are per-key RGB, but the first 6 are underglow */ + spi-one-frame = <0x70>; + spi-zero-frame = <0x40>; + }; +}; + +/ { + chosen { + zmk,underglow = &led_strip; + }; +}; diff --git a/app/boards/shields/microdox/microdox.conf b/app/boards/shields/microdox/microdox.conf new file mode 100644 index 0000000..b79385b --- /dev/null +++ b/app/boards/shields/microdox/microdox.conf @@ -0,0 +1,6 @@ +# Uncomment the following lines to enable the Corne RGB Underglow +# ZMK_RGB_UNDERGLOW=y +# CONFIG_WS2812_STRIP=y + +# Uncomment the following line to enable the Corne OLED Display +# CONFIG_ZMK_DISPLAY=y diff --git a/app/boards/shields/microdox/microdox.dtsi b/app/boards/shields/microdox/microdox.dtsi new file mode 100644 index 0000000..bf7950d --- /dev/null +++ b/app/boards/shields/microdox/microdox.dtsi @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Kellen Carey + * + * SPDX-License-Identifier: MIT + */ + +#include + +/ { + chosen { + zmk,kscan = &kscan0; + zmk,matrix_transform = &default_transform; + }; + + default_transform: keymap_transform_0 { + compatible = "zmk,matrix-transform"; + columns = <10>; + rows = <4>; +// | SW1 | SW2 | SW3 | SW4 | SW5 | | SW5 | SW4 | SW3 | SW2 | SW1 | +// | SW6 | SW7 | SW8 | SW9 | SW10 | | SW10 | SW9 | SW8 | SW7 | SW6 | +// | SW11 | SW12 | SW13 | SW14 | SW15 | | SW15 | SW14 | SW13 | SW12 | SW11 | +// | SW16 | SW17 | SW18 | | SW18 | SW17 | SW16 | + map = < +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(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(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) + RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) + >; + }; + + kscan0: kscan { + compatible = "zmk,kscan-gpio-matrix"; + label = "KSCAN"; + + diode-direction = "col2row"; + row-gpios + = <&pro_micro_d 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 10 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + , <&pro_micro_d 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)> + ; + + }; + + bt_unpair_combo: bt_unpair_combo { + compatible = "zmk,bt-unpair-combo"; + }; + + // TODO: per-key RGB node(s)? +}; + +&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/microdox/microdox.keymap b/app/boards/shields/microdox/microdox.keymap new file mode 100644 index 0000000..fa43a63 --- /dev/null +++ b/app/boards/shields/microdox/microdox.keymap @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#include +#include +#include + +/ { + keymap { + compatible = "zmk,keymap"; + + default_layer { +// ----------------------------------------------------------------------------------------- +// | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP | +// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | +// | SHFT | Z | X | C | V | B | | N | M | , | . | / | SHFT | +// | GUI | LWR | SPC | | ENT | RSE | ALT | + 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 SCLN + &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH + &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp RALT + >; + }; + lower_layer { +// ----------------------------------------------------------------------------------------- +// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | +// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | +// | SHFT | | | | | | | | | | | | | +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 + &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &trans + &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans + &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT + >; + }; + + raise_layer { +// ----------------------------------------------------------------------------------------- +// | ESC | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | +// | CTRL | | | | | | | - | = | { | } | "|" | ` | +// | SHFT | | | | | | | _ | + | [ | ] | \ | ~ | // TODO: Fix this row when &mkp is committed +// | GUI | | SPC | | ENT | | ALT | + bindings = < + &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN + &trans &trans &trans &trans &trans &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans &trans &kp BSLH + &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT + >; + }; + }; +}; + diff --git a/app/boards/shields/microdox/microdox_left.conf b/app/boards/shields/microdox/microdox_left.conf new file mode 100644 index 0000000..1e028a7 --- /dev/null +++ b/app/boards/shields/microdox/microdox_left.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL=y diff --git a/app/boards/shields/microdox/microdox_left.overlay b/app/boards/shields/microdox/microdox_left.overlay new file mode 100644 index 0000000..0a3f823 --- /dev/null +++ b/app/boards/shields/microdox/microdox_left.overlay @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Kellen Carey + * + * SPDX-License-Identifier: MIT + */ + +#include "microdox.dtsi" + +&kscan0 { + col-gpios + = <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <0 38>; +}; diff --git a/app/boards/shields/microdox/microdox_right.conf b/app/boards/shields/microdox/microdox_right.conf new file mode 100644 index 0000000..990cf7c --- /dev/null +++ b/app/boards/shields/microdox/microdox_right.conf @@ -0,0 +1,2 @@ +CONFIG_ZMK_SPLIT=y +CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL=y diff --git a/app/boards/shields/microdox/microdox_right.overlay b/app/boards/shields/microdox/microdox_right.overlay new file mode 100644 index 0000000..2638a39 --- /dev/null +++ b/app/boards/shields/microdox/microdox_right.overlay @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 Kellen Carey + * + * SPDX-License-Identifier: MIT + */ + +#include "microdox.dtsi" + +&default_transform { + col-offset = <5>; +}; + +&kscan0 { + col-gpios + = <&pro_micro_d 15 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 0 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 1 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 2 GPIO_ACTIVE_HIGH> + , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> + ; +}; + +&bt_unpair_combo { + key-positions = <9 35>; +}; -- cgit v1.2.3 From ca29c40206031f95525c29750650013efc0e56f1 Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Wed, 7 Oct 2020 21:22:08 -0700 Subject: clean up keymap --- app/boards/shields/microdox/microdox.keymap | 52 ++++++++++++++++++----------- 1 file changed, 33 insertions(+), 19 deletions(-) (limited to 'app') diff --git a/app/boards/shields/microdox/microdox.keymap b/app/boards/shields/microdox/microdox.keymap index fa43a63..916141c 100644 --- a/app/boards/shields/microdox/microdox.keymap +++ b/app/boards/shields/microdox/microdox.keymap @@ -14,37 +14,37 @@ default_layer { // ----------------------------------------------------------------------------------------- -// | TAB | Q | W | E | R | T | | Y | U | I | O | P | BKSP | -// | CTRL | A | S | D | F | G | | H | J | K | L | ; | ' | -// | SHFT | Z | X | C | V | B | | N | M | , | . | / | SHFT | -// | GUI | LWR | SPC | | ENT | RSE | ALT | +// | 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 | , | . | / | +// | GUI | NAV | SHFT | | SPC | SYM | ALT | 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 SCLN &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp LGUI &mo 1 &kp SPC &kp RET &mo 2 &kp RALT + &kp LGUI &mo 1 &kp LSFT &kp SPC &mo 2 &kp RALT >; }; - lower_layer { + nav_layer { // ----------------------------------------------------------------------------------------- -// | ESC | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | BKSP | -// | BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | LFT | DWN | UP | RGT | | | -// | SHFT | | | | | | | | | | | | | -// | GUI | | SPC | | ENT | | ALT | +// | | | ESC | ~ | | | TAB | HOME | UP | END | DEL | +// | | GUI | ALT | CTRL | NUM | | / | LEFT | DOWN | RGT | BKSP | +// | | | | | | | \ | ENT | | | | +// | | | | | | | | bindings = < - &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 - &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp LARW &kp DARW &kp UARW &kp RARW &trans - &trans &trans &trans &trans &trans &trans &trans &trans &trans &trans - &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT + &trans &trans &kp ESC &kp TILD &trans &kp TAB &kp HOME &kp UARW &kp END &kp DEL + &trans &kp GUI &kp RALT &kp LCTL &mo 3 &kp FSLH &kp LARW &kp DARW &kp RARW &kp BKSP + &trans &trans &trans &trans &trans &kp BSLH &kp RET &trans &trans &trans + &trans &trans &trans &trans &trans &trans >; }; - raise_layer { + sym_layer { // ----------------------------------------------------------------------------------------- -// | ESC | ! | @ | # | $ | % | | ^ | & | * | ( | ) | BKSP | -// | CTRL | | | | | | | - | = | { | } | "|" | ` | -// | SHFT | | | | | | | _ | + | [ | ] | \ | ~ | // TODO: Fix this row when &mkp is committed -// | GUI | | SPC | | ENT | | ALT | +// | ! | @ | # | $ | % | | ^ | & | * | ( | ) | +// | | | | | | | - | = | { | } | "|" | +// | | | | | | | _ | + | [ | ] | \ | +// | GUI | | SPC | | ENT | | ALT | bindings = < &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &trans &trans &trans &trans &trans &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp PIPE @@ -52,6 +52,20 @@ &kp LGUI &trans &kp SPC &kp RET &trans &kp RALT >; }; + + num_layer { +// ----------------------------------------------------------------------------------------- +// | | | | | | | A | 7 | 8 | 9 | D | +// | | | | | | | B | 4 | 5 | 6 | E | +// | | | | | | | C | 1 | 2 | 3 | F | +// | | | | | 0 | . | | + bindings = < + &trans &trans &trans &trans &trans &kp A &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp D + &trans &trans &trans &trans &trans &kp B &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp E + &trans &trans &trans &trans &trans &kp C &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp F + &trans &trans &trans &kp NUM_0 &kp DOT &trans + >; + }; }; }; -- cgit v1.2.3 From 426b25892f2fd6c569b9d0b983fd7fbaff6c9d93 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:09:35 +0100 Subject: rename gpio to direct polling --- app/boards/shields/cradio/Kconfig.defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 46799b9..43509a4 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -4,7 +4,7 @@ config ZMK_KEYBOARD_NAME default "cradio" -config ZMK_KSCAN_GPIO_POLLING +config ZMK_KSCAN_DIRECT_POLLING default y -- cgit v1.2.3 From 7d582b6b8e16cf64cadf27dacba050dfb88d543a Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:11:01 +0100 Subject: remove dupe copyright --- app/boards/shields/cradio/cradio_left.overlay | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio_left.overlay b/app/boards/shields/cradio/cradio_left.overlay index 6caf8e3..61fc3bd 100644 --- a/app/boards/shields/cradio/cradio_left.overlay +++ b/app/boards/shields/cradio/cradio_left.overlay @@ -1,6 +1,4 @@ /* - * Copyright (c) 2020 Pete Johanson - * * Copyright (c) 2020 The ZMK Contributors */ -- cgit v1.2.3 From 95b94009a9b3b9b953220ab48f0276fc5a083499 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:11:40 +0100 Subject: remove dupe copyright --- app/boards/shields/cradio/cradio_right.overlay | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay index 232d7d4..1c06006 100644 --- a/app/boards/shields/cradio/cradio_right.overlay +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -1,6 +1,4 @@ /* - * Copyright (c) 2020 Pete Johanson - * * Copyright (c) 2020 The ZMK Contributors */ -- cgit v1.2.3 From 24e73f68610a9a4a1497c6e7737b615d6181836b Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:12:04 +0100 Subject: Update cradio.dtsi --- app/boards/shields/cradio/cradio.dtsi | 2 -- 1 file changed, 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index 582f58a..d32d2ed 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -1,6 +1,4 @@ /* - * Copyright (c) 2020 Pete Johanson - * * Copyright (c) 2020 The ZMK Contributors */ -- cgit v1.2.3 From a3cdab9e9f9940a854ec68e60622443ae376183e Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:14:46 +0100 Subject: update header --- app/boards/shields/cradio/cradio.keymap | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio.keymap b/app/boards/shields/cradio/cradio.keymap index c46468d..1d11cfd 100644 --- a/app/boards/shields/cradio/cradio.keymap +++ b/app/boards/shields/cradio/cradio.keymap @@ -1,3 +1,10 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + + #include #include -- cgit v1.2.3 From 55c1f51b3147490d994d846907e9fd99039e4e8b Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:16:08 +0100 Subject: update header --- app/boards/shields/cradio/cradio_right.overlay | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay index 1c06006..fea59c2 100644 --- a/app/boards/shields/cradio/cradio_right.overlay +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -1,5 +1,7 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT */ #include "cradio.dtsi" -- cgit v1.2.3 From eeac54e9a4f24e5a455cbc52ba0930a10d2bcfc9 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:16:28 +0100 Subject: Update cradio_left.overlay --- app/boards/shields/cradio/cradio_left.overlay | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio_left.overlay b/app/boards/shields/cradio/cradio_left.overlay index 61fc3bd..cac9575 100644 --- a/app/boards/shields/cradio/cradio_left.overlay +++ b/app/boards/shields/cradio/cradio_left.overlay @@ -1,4 +1,5 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT */ - -- cgit v1.2.3 From a629aa0b42caf6a86152ef5eedc6160b90200627 Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:17:53 +0100 Subject: Update Kconfig.defconfig --- app/boards/shields/cradio/Kconfig.defconfig | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 43509a4..1043c7e 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -1,8 +1,20 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT +if SHIELD_CRADIO_LEFT + config ZMK_KEYBOARD_NAME - default "cradio" + default "Cradio Left" + +endif + + +if SHIELD_CRADIO_RIGHT + +config ZMK_KEYBOARD_NAME + default "Cradio Right" + +endif config ZMK_KSCAN_DIRECT_POLLING default y -- cgit v1.2.3 From ad77df59897ae973824377373665a4fdc6542d3c Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:20:22 +0100 Subject: capital C --- app/boards/shields/cradio/Kconfig.defconfig | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 1043c7e..5f8bb80 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -1,20 +1,8 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT -if SHIELD_CRADIO_LEFT - config ZMK_KEYBOARD_NAME - default "Cradio Left" - -endif - - -if SHIELD_CRADIO_RIGHT - -config ZMK_KEYBOARD_NAME - default "Cradio Right" - -endif + default "Cradio" config ZMK_KSCAN_DIRECT_POLLING default y -- cgit v1.2.3 From 2b09174ec1a171e043018cbe28e47d86025ce1de Mon Sep 17 00:00:00 2001 From: David Barr Date: Thu, 8 Oct 2020 11:22:34 +0100 Subject: update header again based on corne --- app/boards/shields/cradio/cradio.dtsi | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index d32d2ed..ab22e92 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -1,5 +1,7 @@ /* - * Copyright (c) 2020 The ZMK Contributors + * Copyright (c) 2020 Pete Johanson + * + * SPDX-License-Identifier: MIT */ #include -- cgit v1.2.3 From 01b0bad7a246ac9aef7aa170895dab5ae4790525 Mon Sep 17 00:00:00 2001 From: David Barr Date: Fri, 9 Oct 2020 17:05:09 +0100 Subject: update headers, spruce up keymap, streamline dtsi. --- app/boards/shields/cradio/Kconfig.defconfig | 2 +- app/boards/shields/cradio/cradio.dtsi | 23 ++++++-------------- app/boards/shields/cradio/cradio.keymap | 30 ++++++++++++++++++++------ app/boards/shields/cradio/cradio_left.overlay | 4 +++- app/boards/shields/cradio/cradio_right.overlay | 2 +- 5 files changed, 36 insertions(+), 25 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 5f8bb80..43509a4 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -2,7 +2,7 @@ # SPDX-License-Identifier: MIT config ZMK_KEYBOARD_NAME - default "Cradio" + default "cradio" config ZMK_KSCAN_DIRECT_POLLING default y diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index ab22e92..1f2603c 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -9,9 +9,9 @@ / { chosen { zmk,kscan = &kscan0; - zmk,matrix_transform = &default_transform; + //zmk,matrix_transform = &default_transform; }; - + default_transform: keymap_transform_0 { compatible = "zmk,matrix-transform"; columns = <34>; @@ -19,23 +19,13 @@ map = < RC(0,0) RC(0,1) RC(0,2) RC(0,3) RC(0,4) RC(0,21) RC(0,20) RC(0,19) RC(0,18) RC(0,17) RC(0,5) RC(0,6) RC(0,7) RC(0,8) RC(0,9) RC(0,26) RC(0,25) RC(0,24) RC(0,23) RC(0,22) - RC(0,10)RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) + RC(0,10) RC(0,11) RC(0,12) RC(0,13) RC(0,14) RC(0,31) RC(0,30) RC(0,29) RC(0,28) RC(0,27) RC(0,15) RC(0,16) RC(0,33) RC(0,32) >; kscan0: kscan { compatible = "zmk,kscan-gpio-direct"; label = "KSCAN"; - }; - - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; - - }; - }; - - &kscan0 { input-gpios = <&pro_micro_d 7 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_a 0 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> @@ -55,6 +45,7 @@ , <&pro_micro_d 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> , <&pro_micro_d 9 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)> ; -}; - - + }; + }; + }; + diff --git a/app/boards/shields/cradio/cradio.keymap b/app/boards/shields/cradio/cradio.keymap index 1d11cfd..487f6dc 100644 --- a/app/boards/shields/cradio/cradio.keymap +++ b/app/boards/shields/cradio/cradio.keymap @@ -3,23 +3,41 @@ * * SPDX-License-Identifier: MIT */ - - + #include #include +#include / { keymap { compatible = "zmk,keymap"; - - default_layer { + + default_layer { 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 SCLN &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH - &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 - >; + &mo 1 &kp LCTL &kp SPC &mo 2 + >; }; + upper_layer { + bindings = < + &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 + &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &kp H &kp J &kp K &kp L &kp SCLN + &kp LSFT &trans &trans &trans &trans &trans &trans &trans &trans &trans + &mo 1 &kp LCTL &kp SPC &mo 2 + >; + }; + + lower_layer { + bindings = < + &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN + &trans &trans &trans &trans &trans &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans &kp BSLH &kp TILD + &mo 1 &kp LCTL &kp SPC &mo 2 + >; + }; + }; }; diff --git a/app/boards/shields/cradio/cradio_left.overlay b/app/boards/shields/cradio/cradio_left.overlay index cac9575..6a3704a 100644 --- a/app/boards/shields/cradio/cradio_left.overlay +++ b/app/boards/shields/cradio/cradio_left.overlay @@ -1,5 +1,7 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ + +#include "cradio.dtsi" diff --git a/app/boards/shields/cradio/cradio_right.overlay b/app/boards/shields/cradio/cradio_right.overlay index fea59c2..01aa1ab 100644 --- a/app/boards/shields/cradio/cradio_right.overlay +++ b/app/boards/shields/cradio/cradio_right.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 0b125c028c65ff4a5e326760a7d0ac0f8941899c Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Fri, 9 Oct 2020 11:48:06 -0700 Subject: address pr comments --- app/boards/shields/microdox/Kconfig.defconfig | 2 ++ app/boards/shields/microdox/Kconfig.shield | 3 +-- app/boards/shields/microdox/boards/nice_nano.overlay | 5 +++++ app/boards/shields/microdox/microdox.dtsi | 7 +------ app/boards/shields/microdox/microdox.keymap | 16 +++++++++------- app/boards/shields/microdox/microdox_left.overlay | 4 ---- app/boards/shields/microdox/microdox_right.overlay | 4 ---- 7 files changed, 18 insertions(+), 23 deletions(-) (limited to 'app') diff --git a/app/boards/shields/microdox/Kconfig.defconfig b/app/boards/shields/microdox/Kconfig.defconfig index 218443f..4840ece 100644 --- a/app/boards/shields/microdox/Kconfig.defconfig +++ b/app/boards/shields/microdox/Kconfig.defconfig @@ -1,3 +1,5 @@ +# Copyright (c) 2020 The ZMK Contributors +# SPDX-License-Identifier: MIT if SHIELD_MICRODOX_LEFT diff --git a/app/boards/shields/microdox/Kconfig.shield b/app/boards/shields/microdox/Kconfig.shield index 7d7148d..ac79eab 100644 --- a/app/boards/shields/microdox/Kconfig.shield +++ b/app/boards/shields/microdox/Kconfig.shield @@ -1,5 +1,4 @@ -# Copyright (c) 2020 Pete Johanson -# Copyright (c) 2020 Kellen Carey +# Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT config SHIELD_MICRODOX_LEFT diff --git a/app/boards/shields/microdox/boards/nice_nano.overlay b/app/boards/shields/microdox/boards/nice_nano.overlay index c7c3eb8..58cd861 100644 --- a/app/boards/shields/microdox/boards/nice_nano.overlay +++ b/app/boards/shields/microdox/boards/nice_nano.overlay @@ -1,3 +1,8 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ &spi1 { compatible = "nordic,nrf-spi"; /* Cannot be used together with i2c0. */ diff --git a/app/boards/shields/microdox/microdox.dtsi b/app/boards/shields/microdox/microdox.dtsi index bf7950d..55c67dd 100644 --- a/app/boards/shields/microdox/microdox.dtsi +++ b/app/boards/shields/microdox/microdox.dtsi @@ -1,6 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson - * Copyright (c) 2020 Kellen Carey + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ @@ -43,10 +42,6 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(2,5) RC(2,6) RC(2,7) RC(2,8) RC(2,9) }; - bt_unpair_combo: bt_unpair_combo { - compatible = "zmk,bt-unpair-combo"; - }; - // TODO: per-key RGB node(s)? }; diff --git a/app/boards/shields/microdox/microdox.keymap b/app/boards/shields/microdox/microdox.keymap index 916141c..5747771 100644 --- a/app/boards/shields/microdox/microdox.keymap +++ b/app/boards/shields/microdox/microdox.keymap @@ -27,15 +27,15 @@ }; nav_layer { // ----------------------------------------------------------------------------------------- -// | | | ESC | ~ | | | TAB | HOME | UP | END | DEL | -// | | GUI | ALT | CTRL | NUM | | / | LEFT | DOWN | RGT | BKSP | -// | | | | | | | \ | ENT | | | | +// |BTCLR| | ESC | ~ | | | TAB | HOME | UP | END | DEL | +// | BT1 | GUI | ALT | CTRL | NUM | | / | LEFT | DOWN | RGT | BKSP | +// | BT2 | | | | | | \ | ENT | | | | // | | | | | | | | bindings = < - &trans &trans &kp ESC &kp TILD &trans &kp TAB &kp HOME &kp UARW &kp END &kp DEL - &trans &kp GUI &kp RALT &kp LCTL &mo 3 &kp FSLH &kp LARW &kp DARW &kp RARW &kp BKSP - &trans &trans &trans &trans &trans &kp BSLH &kp RET &trans &trans &trans - &trans &trans &trans &trans &trans &trans + &bt BT_CLR &trans &kp ESC &kp TILD &trans &kp TAB &kp HOME &kp UARW &kp END &kp DEL + &bt BT_SEL 0 &kp GUI &kp RALT &kp LCTL &mo 3 &kp FSLH &kp LARW &kp DARW &kp RARW &kp BKSP + &bt BT_SEL 1 &trans &trans &trans &trans &kp BSLH &kp RET &trans &trans &trans + &trans &trans &trans &trans &trans &trans >; }; @@ -53,6 +53,8 @@ >; }; +// This layer is unreachable until "tri layer state" is sorted out. +// Leaving it here for completeness. num_layer { // ----------------------------------------------------------------------------------------- // | | | | | | | A | 7 | 8 | 9 | D | diff --git a/app/boards/shields/microdox/microdox_left.overlay b/app/boards/shields/microdox/microdox_left.overlay index 0a3f823..07dc0d2 100644 --- a/app/boards/shields/microdox/microdox_left.overlay +++ b/app/boards/shields/microdox/microdox_left.overlay @@ -16,7 +16,3 @@ , <&pro_micro_d 15 GPIO_ACTIVE_HIGH> ; }; - -&bt_unpair_combo { - key-positions = <0 38>; -}; diff --git a/app/boards/shields/microdox/microdox_right.overlay b/app/boards/shields/microdox/microdox_right.overlay index 2638a39..a0d8601 100644 --- a/app/boards/shields/microdox/microdox_right.overlay +++ b/app/boards/shields/microdox/microdox_right.overlay @@ -20,7 +20,3 @@ , <&pro_micro_a 3 GPIO_ACTIVE_HIGH> ; }; - -&bt_unpair_combo { - key-positions = <9 35>; -}; -- cgit v1.2.3 From a695d0d3596817834f7465e029d0205fc9235499 Mon Sep 17 00:00:00 2001 From: Kellen Carey Date: Fri, 9 Oct 2020 12:18:57 -0700 Subject: oops --- app/boards/shields/microdox/microdox_left.overlay | 3 +-- app/boards/shields/microdox/microdox_right.overlay | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/boards/shields/microdox/microdox_left.overlay b/app/boards/shields/microdox/microdox_left.overlay index 07dc0d2..4d0378e 100644 --- a/app/boards/shields/microdox/microdox_left.overlay +++ b/app/boards/shields/microdox/microdox_left.overlay @@ -1,6 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson - * Copyright (c) 2020 Kellen Carey + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/boards/shields/microdox/microdox_right.overlay b/app/boards/shields/microdox/microdox_right.overlay index a0d8601..c5622b2 100644 --- a/app/boards/shields/microdox/microdox_right.overlay +++ b/app/boards/shields/microdox/microdox_right.overlay @@ -1,6 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson - * Copyright (c) 2020 Kellen Carey + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 4d81b10ba7047a4dbd63cfe33ac879ecf437e108 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Tue, 6 Oct 2020 15:52:21 +0800 Subject: Added driver to control the external power output This PR adds support to control the external power output from controllers like nice!nano, nRFMicro etc I have implemented based on my understanding of Pete suggestion on this feature. Testing done: Tested by enabling and disabling the ext_power from application and verified Verified the application does not crash with boards that does not have ext_power support Note: I did not test this in nice!nano since I don't have the boards. Will get help from others once the behavior PR is up Next Steps: Create a behavior PR to control enable/disable ext_power --- app/CMakeLists.txt | 1 + app/Kconfig | 4 + app/boards/arm/nice_nano/nice_nano.dts | 5 + app/boards/arm/nrfmicro/nrfmicro_11.dts | 5 + app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts | 5 + app/boards/arm/nrfmicro/nrfmicro_13.dts | 5 + app/boards/arm/nrfmicro/pinmux.c | 11 --- .../zmk,behavior-sensor-rotate-key-press.yaml | 2 +- app/dts/bindings/zmk,ext-power-generic.yaml | 20 ++++ app/dts/bindings/zmk,keymap-sensors.yaml | 5 + app/include/drivers/ext_power.h | 104 +++++++++++++++++++++ app/src/ext_power_generic.c | 91 ++++++++++++++++++ app/src/main.c | 9 ++ 13 files changed, 255 insertions(+), 12 deletions(-) create mode 100644 app/dts/bindings/zmk,ext-power-generic.yaml create mode 100644 app/include/drivers/ext_power.h create mode 100644 app/src/ext_power_generic.c (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 3e59d75..31d28f5 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -31,6 +31,7 @@ target_sources(app PRIVATE src/sensors.c) target_sources_ifdef(CONFIG_ZMK_DISPLAY app PRIVATE src/display.c) target_sources(app PRIVATE src/event_manager.c) target_sources_ifdef(CONFIG_ZMK_BLE app PRIVATE src/ble_unpair_combo.c) +target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/ext_power_generic.c) target_sources(app PRIVATE src/events/position_state_changed.c) target_sources(app PRIVATE src/events/keycode_state_changed.c) target_sources(app PRIVATE src/events/modifiers_state_changed.c) diff --git a/app/Kconfig b/app/Kconfig index edf5867..fca4912 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -95,6 +95,10 @@ config ZMK_IDLE_SLEEP_TIMEOUT endif +config ZMK_EXT_POWER + bool "Enable support to control external power output" + default y + config ZMK_DISPLAY bool "ZMK display support" default n diff --git a/app/boards/arm/nice_nano/nice_nano.dts b/app/boards/arm/nice_nano/nice_nano.dts index 3ffb0ea..0538b1d 100644 --- a/app/boards/arm/nice_nano/nice_nano.dts +++ b/app/boards/arm/nice_nano/nice_nano.dts @@ -29,6 +29,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + }; }; &gpiote { diff --git a/app/boards/arm/nrfmicro/nrfmicro_11.dts b/app/boards/arm/nrfmicro/nrfmicro_11.dts index 95bd8ad..87c650e 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts index 85693a8..ea15b81 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_11_flipped.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_HIGH>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/nrfmicro_13.dts b/app/boards/arm/nrfmicro/nrfmicro_13.dts index 95bd8ad..ef43946 100644 --- a/app/boards/arm/nrfmicro/nrfmicro_13.dts +++ b/app/boards/arm/nrfmicro/nrfmicro_13.dts @@ -26,6 +26,11 @@ }; }; + ext-power { + compatible = "zmk,ext-power-generic"; + label = "EXT_POWER"; + control-gpios = <&gpio1 9 GPIO_ACTIVE_LOW>; + }; }; &gpio0 { diff --git a/app/boards/arm/nrfmicro/pinmux.c b/app/boards/arm/nrfmicro/pinmux.c index 4e330b6..30117d0 100644 --- a/app/boards/arm/nrfmicro/pinmux.c +++ b/app/boards/arm/nrfmicro/pinmux.c @@ -14,25 +14,14 @@ static int pinmux_nrfmicro_init(struct device *port) { ARG_UNUSED(port); - struct device *p1 = device_get_binding("GPIO_1"); - #if CONFIG_BOARD_NRFMICRO_13 struct device *p0 = device_get_binding("GPIO_0"); - // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 0); - #if CONFIG_BOARD_NRFMICRO_CHARGER gpio_pin_configure(p0, 5, GPIO_OUTPUT); gpio_pin_set(p0, 5, 0); #else gpio_pin_configure(p0, 5, GPIO_INPUT); #endif - -#else - // enable EXT_VCC (use 0 for nRFMicro 1.3, use 1 for nRFMicro 1.1) - gpio_pin_configure(p1, 9, GPIO_OUTPUT); - gpio_pin_set(p1, 9, 1); #endif return 0; } diff --git a/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml b/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml index bbf3537..6b33910 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-sensor-rotate-key-press.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2020, Pete Johanson +# Copyright (c) 2020, The ZMK Contributors # SPDX-License-Identifier: MIT description: Sensor rotate key press/release behavior diff --git a/app/dts/bindings/zmk,ext-power-generic.yaml b/app/dts/bindings/zmk,ext-power-generic.yaml new file mode 100644 index 0000000..5a38a09 --- /dev/null +++ b/app/dts/bindings/zmk,ext-power-generic.yaml @@ -0,0 +1,20 @@ +# +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +description: | + Generic driver for controlling the external power output + by toggling the control-gpio pin status + (Only in supported hardware) + +compatible: "zmk,ext-power-generic" + +properties: + control-gpios: + type: phandle-array + required: true + label: + type: string + required: true + diff --git a/app/dts/bindings/zmk,keymap-sensors.yaml b/app/dts/bindings/zmk,keymap-sensors.yaml index c56361d..86ae5c2 100644 --- a/app/dts/bindings/zmk,keymap-sensors.yaml +++ b/app/dts/bindings/zmk,keymap-sensors.yaml @@ -1,3 +1,8 @@ +# +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT +# + description: | Allows defining the collection of sensors bound in the keymap layers diff --git a/app/include/drivers/ext_power.h b/app/include/drivers/ext_power.h new file mode 100644 index 0000000..6c1923e --- /dev/null +++ b/app/include/drivers/ext_power.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#pragma once + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @cond INTERNAL_HIDDEN + * + * Behavior driver API definition and system call entry points. + * + * (Internal use only.) + */ + +typedef int (*ext_power_enable_t)(struct device *dev); +typedef int (*ext_power_disable_t)(struct device *dev); +typedef int (*ext_power_get_t)(struct device *dev); + +__subsystem struct ext_power_api { + ext_power_enable_t enable; + ext_power_disable_t disable; + ext_power_get_t get; +}; +/** + * @endcond + */ + +/** + * @brief Enable the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If successful. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_enable(struct device *dev); + +static inline int z_impl_ext_power_enable(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->enable == NULL) { + return -ENOTSUP; + } + + return api->enable(dev); +} + +/** + * @brief Disable the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If successful. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_disable(struct device *dev); + +static inline int z_impl_ext_power_disable(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->disable == NULL) { + return -ENOTSUP; + } + + return api->disable(dev); +} + +/** + * @brief Get the current status of the external power output + * @param dev Pointer to the device structure for the driver instance. + * + * @retval 0 If ext power is disabled. + * @retval 1 if ext power is enabled. + * @retval Negative errno code if failure. + */ +__syscall int ext_power_get(struct device *dev); + +static inline int z_impl_ext_power_get(struct device *dev) { + const struct ext_power_api *api = (const struct ext_power_api *)dev->driver_api; + + if (api->get == NULL) { + return -ENOTSUP; + } + + return api->get(dev); +} + +#ifdef __cplusplus +} +#endif + +/** + * @} + */ + +#include diff --git a/app/src/ext_power_generic.c b/app/src/ext_power_generic.c new file mode 100644 index 0000000..4817030 --- /dev/null +++ b/app/src/ext_power_generic.c @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_ext_power_generic + +#include +#include +#include +#include + +#if DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +struct ext_power_generic_config { + const char *label; + const u8_t pin; + const u8_t flags; +}; + +struct ext_power_generic_data { + struct device *gpio; + bool status; +}; + +static int ext_power_generic_enable(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + if (gpio_pin_set(data->gpio, config->pin, 1)) { + LOG_WRN("Failed to set ext-power control pin"); + return -EIO; + } + data->status = true; + return 0; +} + +static int ext_power_generic_disable(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + if (gpio_pin_set(data->gpio, config->pin, 0)) { + LOG_WRN("Failed to clear ext-power control pin"); + return -EIO; + } + data->status = false; + return 0; +} + +static int ext_power_generic_get(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + return data->status; +} + +static int ext_power_generic_init(struct device *dev) { + struct ext_power_generic_data *data = dev->driver_data; + const struct ext_power_generic_config *config = dev->config_info; + + data->gpio = device_get_binding(config->label); + if (data->gpio == NULL) { + LOG_ERR("Failed to get ext-power control device"); + return -EINVAL; + } + + if (gpio_pin_configure(data->gpio, config->pin, config->flags | GPIO_OUTPUT)) { + LOG_ERR("Failed to configure ext-power control pin"); + return -EIO; + } + + return 0; +} + +static const struct ext_power_generic_config config = { + .label = DT_INST_GPIO_LABEL(0, control_gpios), + .pin = DT_INST_GPIO_PIN(0, control_gpios), + .flags = DT_INST_GPIO_FLAGS(0, control_gpios)}; + +static struct ext_power_generic_data data = {.status = false}; + +static const struct ext_power_api api = {.enable = ext_power_generic_enable, + .disable = ext_power_generic_disable, + .get = ext_power_generic_get}; + +DEVICE_AND_API_INIT(ext_power_generic, DT_INST_LABEL(0), ext_power_generic_init, &data, &config, + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &api); + +#endif /* DT_HAS_COMPAT_STATUS_OKAY(DT_DRV_COMPAT) */ diff --git a/app/src/main.c b/app/src/main.c index dca923e..0551356 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -15,16 +15,25 @@ LOG_MODULE_REGISTER(zmk, CONFIG_ZMK_LOG_LEVEL); #include #include #include +#include #define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) void main(void) { + struct device *ext_power; LOG_INF("Welcome to ZMK!\n"); if (zmk_kscan_init(ZMK_KSCAN_DEV) != 0) { return; } + // Enable the external VCC output + ext_power = device_get_binding("EXT_POWER"); + if (ext_power != NULL) { + const struct ext_power_api *ext_power_api = ext_power->driver_api; + ext_power_api->enable(ext_power); + } + #ifdef CONFIG_ZMK_DISPLAY zmk_display_init(); -- cgit v1.2.3 From d38740cebf3be17a7d55fc51f5f06752182f96d8 Mon Sep 17 00:00:00 2001 From: Okke Formsma Date: Sat, 10 Oct 2020 23:32:53 +0200 Subject: Add timestamps to position and behavior events (#147) * Add timestamps to position events and behaviors. - Take original event timestamps into consideration so nested tap-holds have proper timing. - Add position and timestamp to keycode state changed event so the one-shot behavior can properly identify other keypresses and timings. - Add timestamp to position events received from peripheral * reduce number of arguments to behaviors --- app/include/drivers/behavior.h | 44 ++++---- app/include/zmk/behavior.h | 6 ++ app/include/zmk/events/keycode-state-changed.h | 1 - app/include/zmk/events/position-state-changed.h | 1 + app/include/zmk/keymap.h | 2 +- app/src/behaviors/behavior_bt.c | 18 ++-- app/src/behaviors/behavior_hold_tap.c | 114 +++++++++++++-------- app/src/behaviors/behavior_key_press.c | 19 ++-- app/src/behaviors/behavior_momentary_layer.c | 17 +-- app/src/behaviors/behavior_none.c | 10 +- app/src/behaviors/behavior_reset.c | 7 +- app/src/behaviors/behavior_rgb_underglow.c | 6 +- .../behaviors/behavior_sensor_rotate_key_press.c | 11 +- app/src/behaviors/behavior_toggle_layer.c | 15 +-- app/src/behaviors/behavior_transparent.c | 10 +- app/src/keymap.c | 22 ++-- app/src/kscan.c | 1 + app/src/split/bluetooth/central.c | 1 + .../hold-tap/balanced/many-nested/events.patterns | 4 + .../balanced/many-nested/keycode_events.snapshot | 20 ++++ .../balanced/many-nested/native_posix.keymap | 41 ++++++++ 21 files changed, 248 insertions(+), 122 deletions(-) create mode 100644 app/tests/hold-tap/balanced/many-nested/events.patterns create mode 100644 app/tests/hold-tap/balanced/many-nested/keycode_events.snapshot create mode 100644 app/tests/hold-tap/balanced/many-nested/native_posix.keymap (limited to 'app') diff --git a/app/include/drivers/behavior.h b/app/include/drivers/behavior.h index 45b8bea..cf259b1 100644 --- a/app/include/drivers/behavior.h +++ b/app/include/drivers/behavior.h @@ -10,6 +10,7 @@ #include #include #include +#include /** * @cond INTERNAL_HIDDEN @@ -19,10 +20,10 @@ * (Internal use only.) */ -typedef int (*behavior_keymap_binding_callback_t)(struct device *dev, u32_t position, u32_t param1, - u32_t param2); -typedef int (*behavior_sensor_keymap_binding_callback_t)(struct device *dev, struct device *sensor, - u32_t param1, u32_t param2); +typedef int (*behavior_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event); +typedef int (*behavior_sensor_keymap_binding_callback_t)(struct zmk_behavior_binding *binding, + struct device *sensor); __subsystem struct behavior_driver_api { behavior_keymap_binding_callback_t binding_pressed; @@ -42,18 +43,19 @@ __subsystem struct behavior_driver_api { * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_keymap_binding_pressed(struct device *dev, u32_t position, u32_t param1, - u32_t param2); +__syscall int behavior_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event); -static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32_t position, - u32_t param1, u32_t param2) { +static inline int z_impl_behavior_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; if (api->binding_pressed == NULL) { return -ENOTSUP; } - return api->binding_pressed(dev, position, param1, param2); + return api->binding_pressed(binding, event); } /** @@ -64,18 +66,19 @@ static inline int z_impl_behavior_keymap_binding_pressed(struct device *dev, u32 * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_keymap_binding_released(struct device *dev, u32_t position, u32_t param1, - u32_t param2); +__syscall int behavior_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event); -static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u32_t position, - u32_t param1, u32_t param2) { +static inline int z_impl_behavior_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; if (api->binding_released == NULL) { return -ENOTSUP; } - return api->binding_released(dev, position, param1, param2); + return api->binding_released(binding, event); } /** @@ -88,19 +91,20 @@ static inline int z_impl_behavior_keymap_binding_released(struct device *dev, u3 * @retval 0 If successful. * @retval Negative errno code if failure. */ -__syscall int behavior_sensor_keymap_binding_triggered(struct device *dev, struct device *sensor, - u32_t param1, u32_t param2); +__syscall int behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, + struct device *sensor); -static inline int z_impl_behavior_sensor_keymap_binding_triggered(struct device *dev, - struct device *sensor, - u32_t param1, u32_t param2) { +static inline int +z_impl_behavior_sensor_keymap_binding_triggered(struct zmk_behavior_binding *binding, + struct device *sensor) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_driver_api *api = (const struct behavior_driver_api *)dev->driver_api; if (api->sensor_binding_triggered == NULL) { return -ENOTSUP; } - return api->sensor_binding_triggered(dev, sensor, param1, param2); + return api->sensor_binding_triggered(binding, sensor); } /** diff --git a/app/include/zmk/behavior.h b/app/include/zmk/behavior.h index 6f5815f..428ae24 100644 --- a/app/include/zmk/behavior.h +++ b/app/include/zmk/behavior.h @@ -10,4 +10,10 @@ struct zmk_behavior_binding { char *behavior_dev; u32_t param1; u32_t param2; +}; + +struct zmk_behavior_binding_event { + int layer; + u32_t position; + s64_t timestamp; }; \ No newline at end of file diff --git a/app/include/zmk/events/keycode-state-changed.h b/app/include/zmk/events/keycode-state-changed.h index 4c00654..1e2c24e 100644 --- a/app/include/zmk/events/keycode-state-changed.h +++ b/app/include/zmk/events/keycode-state-changed.h @@ -24,6 +24,5 @@ inline struct keycode_state_changed *create_keycode_state_changed(u8_t usage_pag ev->usage_page = usage_page; ev->keycode = keycode; ev->state = state; - return ev; } \ No newline at end of file diff --git a/app/include/zmk/events/position-state-changed.h b/app/include/zmk/events/position-state-changed.h index f88080d..e4cbbbe 100644 --- a/app/include/zmk/events/position-state-changed.h +++ b/app/include/zmk/events/position-state-changed.h @@ -13,6 +13,7 @@ struct position_state_changed { struct zmk_event_header header; u32_t position; bool state; + s64_t timestamp; }; ZMK_EVENT_DECLARE(position_state_changed); \ No newline at end of file diff --git a/app/include/zmk/keymap.h b/app/include/zmk/keymap.h index 6192587..b8f4969 100644 --- a/app/include/zmk/keymap.h +++ b/app/include/zmk/keymap.h @@ -11,4 +11,4 @@ int zmk_keymap_layer_activate(u8_t layer); int zmk_keymap_layer_deactivate(u8_t layer); int zmk_keymap_layer_toggle(u8_t layer); -int zmk_keymap_position_state_changed(u32_t position, bool pressed); +int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp); diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 09fadba..922c157 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -8,18 +8,18 @@ #include #include - #include - #include - #include +#include + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); #include -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) { - switch (command) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + switch (binding->param1) { case BT_CLR_CMD: return zmk_ble_clear_bonds(); case BT_NXT_CMD: @@ -27,9 +27,9 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c case BT_PRV_CMD: return zmk_ble_prof_prev(); case BT_SEL_CMD: - return zmk_ble_prof_select(arg); + return zmk_ble_prof_select(binding->param2); default: - LOG_ERR("Unknown BT command: %d", command); + LOG_ERR("Unknown BT command: %d", binding->param1); } return -ENOTSUP; @@ -37,8 +37,8 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c static int behavior_bt_init(struct device *dev) { return 0; }; -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, - u32_t arg) { +static int on_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 0; } diff --git a/app/src/behaviors/behavior_hold_tap.c b/app/src/behaviors/behavior_hold_tap.c index 8f307a6..8b3620e 100644 --- a/app/src/behaviors/behavior_hold_tap.c +++ b/app/src/behaviors/behavior_hold_tap.c @@ -10,7 +10,6 @@ #include #include #include - #include #include #include @@ -18,6 +17,7 @@ #include #include #include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -40,10 +40,8 @@ struct behavior_hold_tap_behaviors { struct zmk_behavior_binding hold; }; -typedef k_timeout_t (*timer_func)(); - struct behavior_hold_tap_config { - timer_func tapping_term_ms; + int tapping_term_ms; struct behavior_hold_tap_behaviors *behaviors; enum flavor flavor; }; @@ -51,8 +49,10 @@ struct behavior_hold_tap_config { // this data is specific for each hold-tap struct active_hold_tap { s32_t position; + // todo: move these params into the config->behaviors->tap and u32_t param_hold; u32_t param_tap; + s64_t timestamp; bool is_decided; bool is_hold; const struct behavior_hold_tap_config *config; @@ -164,6 +164,7 @@ static struct active_hold_tap *find_hold_tap(u32_t position) { } static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, u32_t param_tap, + s64_t timestamp, const struct behavior_hold_tap_config *config) { for (int i = 0; i < ZMK_BHV_HOLD_TAP_MAX_HELD; i++) { if (active_hold_taps[i].position != ZMK_BHV_HOLD_TAP_POSITION_NOT_USED) { @@ -175,6 +176,7 @@ static struct active_hold_tap *store_hold_tap(u32_t position, u32_t param_hold, active_hold_taps[i].config = config; active_hold_taps[i].param_hold = param_hold; active_hold_taps[i].param_tap = param_tap; + active_hold_taps[i].timestamp = timestamp; return &active_hold_taps[i]; } return NULL; @@ -253,7 +255,7 @@ static inline char *flavor_str(enum flavor flavor) { return "UNKNOWN FLAVOR"; } -static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event) { +static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_moment event_type) { if (hold_tap->is_decided) { return; } @@ -265,11 +267,11 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome switch (hold_tap->config->flavor) { case ZMK_BHV_HOLD_TAP_FLAVOR_HOLD_PREFERRED: - decide_hold_preferred(hold_tap, event); + decide_hold_preferred(hold_tap, event_type); case ZMK_BHV_HOLD_TAP_FLAVOR_BALANCED: - decide_balanced(hold_tap, event); + decide_balanced(hold_tap, event_type); case ZMK_BHV_HOLD_TAP_FLAVOR_TAP_PREFERRED: - decide_tap_preferred(hold_tap, event); + decide_tap_preferred(hold_tap, event_type); } if (!hold_tap->is_decided) { @@ -277,26 +279,31 @@ static void decide_hold_tap(struct active_hold_tap *hold_tap, enum decision_mome } LOG_DBG("%d decided %s (%s event %d)", hold_tap->position, hold_tap->is_hold ? "hold" : "tap", - flavor_str(hold_tap->config->flavor), event); + flavor_str(hold_tap->config->flavor), event_type); undecided_hold_tap = NULL; - struct zmk_behavior_binding *behavior; + struct zmk_behavior_binding_event event = { + .position = hold_tap->position, + .timestamp = hold_tap->timestamp, + }; + + struct zmk_behavior_binding binding; if (hold_tap->is_hold) { - behavior = &hold_tap->config->behaviors->hold; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_hold, - 0); + binding.behavior_dev = hold_tap->config->behaviors->hold.behavior_dev; + binding.param1 = hold_tap->param_hold; + binding.param2 = 0; } else { - behavior = &hold_tap->config->behaviors->tap; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_pressed(behavior_device, hold_tap->position, hold_tap->param_tap, - 0); + binding.behavior_dev = hold_tap->config->behaviors->tap.behavior_dev; + binding.param1 = hold_tap->param_tap; + binding.param2 = 0; } + behavior_keymap_binding_pressed(&binding, event); release_captured_events(); } -static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t param_hold, - u32_t param_tap) { +static int on_hold_tap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_hold_tap_config *cfg = dev->config_info; if (undecided_hold_tap != NULL) { @@ -305,54 +312,69 @@ static int on_hold_tap_binding_pressed(struct device *dev, u32_t position, u32_t return 0; } - struct active_hold_tap *hold_tap = store_hold_tap(position, param_hold, param_tap, cfg); + struct active_hold_tap *hold_tap = + store_hold_tap(event.position, binding->param1, binding->param2, event.timestamp, cfg); if (hold_tap == NULL) { LOG_ERR("unable to store hold-tap info, did you press more than %d hold-taps?", ZMK_BHV_HOLD_TAP_MAX_HELD); return 0; } - LOG_DBG("%d new undecided hold_tap", position); + LOG_DBG("%d new undecided hold_tap", event.position); undecided_hold_tap = hold_tap; - k_delayed_work_submit(&hold_tap->work, cfg->tapping_term_ms()); - // todo: once we get timing info for keypresses, start the timer relative to the original - // keypress don't forget to simulate a timer-event before the event after that time was handled. + // if this behavior was queued we have to adjust the timer to only + // wait for the remaining time. + s32_t tapping_term_ms_left = (hold_tap->timestamp + cfg->tapping_term_ms) - k_uptime_get(); + if (tapping_term_ms_left > 0) { + k_delayed_work_submit(&hold_tap->work, K_MSEC(tapping_term_ms_left)); + } return 0; } -static int on_hold_tap_binding_released(struct device *dev, u32_t position, u32_t _, u32_t __) { - struct active_hold_tap *hold_tap = find_hold_tap(position); - +static int on_hold_tap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct active_hold_tap *hold_tap = find_hold_tap(event.position); if (hold_tap == NULL) { LOG_ERR("ACTIVE_HOLD_TAP_CLEANED_UP_TOO_EARLY"); return 0; } + // If these events were queued, the timer event may be queued too late or not at all. + // We insert a timer event before the TH_KEY_UP event to verify. int work_cancel_result = k_delayed_work_cancel(&hold_tap->work); + if (event.timestamp > (hold_tap->timestamp + hold_tap->config->tapping_term_ms)) { + decide_hold_tap(hold_tap, HT_TIMER_EVENT); + } + decide_hold_tap(hold_tap, HT_KEY_UP); - struct zmk_behavior_binding *behavior; + // todo: set up the binding and data items inside of the active_hold_tap struct + struct zmk_behavior_binding_event sub_behavior_data = { + .position = hold_tap->position, + .timestamp = hold_tap->timestamp, + }; + + struct zmk_behavior_binding sub_behavior_binding; if (hold_tap->is_hold) { - behavior = &hold_tap->config->behaviors->hold; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_hold, - 0); + sub_behavior_binding.behavior_dev = hold_tap->config->behaviors->hold.behavior_dev; + sub_behavior_binding.param1 = hold_tap->param_hold; + sub_behavior_binding.param2 = 0; } else { - behavior = &hold_tap->config->behaviors->tap; - struct device *behavior_device = device_get_binding(behavior->behavior_dev); - behavior_keymap_binding_released(behavior_device, hold_tap->position, hold_tap->param_tap, - 0); + sub_behavior_binding.behavior_dev = hold_tap->config->behaviors->tap.behavior_dev; + sub_behavior_binding.param1 = hold_tap->param_tap; + sub_behavior_binding.param2 = 0; } + behavior_keymap_binding_released(&sub_behavior_binding, sub_behavior_data); if (work_cancel_result == -EINPROGRESS) { // let the timer handler clean up // if we'd clear now, the timer may call back for an uninitialized active_hold_tap. - LOG_DBG("%d hold-tap timer work in event queue", position); + LOG_DBG("%d hold-tap timer work in event queue", event.position); hold_tap->work_is_cancelled = true; } else { - LOG_DBG("%d cleaning up hold-tap", position); + LOG_DBG("%d cleaning up hold-tap", event.position); clear_hold_tap(hold_tap); } @@ -382,6 +404,14 @@ static int position_state_changed_listener(const struct zmk_event_header *eh) { } } + // If these events were queued, the timer event may be queued too late or not at all. + // We make a timer decision before the other key events are handled if the timer would + // have run out. + if (ev->timestamp > + (undecided_hold_tap->timestamp + undecided_hold_tap->config->tapping_term_ms)) { + decide_hold_tap(undecided_hold_tap, HT_TIMER_EVENT); + } + if (!ev->state && find_captured_keydown_event(ev->position) == NULL) { // no keydown event has been captured, let it bubble. // we'll catch modifiers later in modifier_state_changed_listener @@ -463,6 +493,7 @@ static int behavior_hold_tap_init(struct device *dev) { struct behavior_hold_tap_data {}; static struct behavior_hold_tap_data behavior_hold_tap_data; +/* todo: get rid of unused param1 and param2. */ #define _TRANSFORM_ENTRY(idx, node) \ { \ .behavior_dev = DT_LABEL(DT_INST_PHANDLE_BY_IDX(node, bindings, idx)), \ @@ -473,14 +504,11 @@ static struct behavior_hold_tap_data behavior_hold_tap_data; }, #define KP_INST(n) \ - static k_timeout_t behavior_hold_tap_config_##n##_gettime() { \ - return K_MSEC(DT_INST_PROP(n, tapping_term_ms)); \ - } \ static struct behavior_hold_tap_behaviors behavior_hold_tap_behaviors_##n = { \ .hold = _TRANSFORM_ENTRY(0, n).tap = _TRANSFORM_ENTRY(1, n)}; \ static struct behavior_hold_tap_config behavior_hold_tap_config_##n = { \ .behaviors = &behavior_hold_tap_behaviors_##n, \ - .tapping_term_ms = &behavior_hold_tap_config_##n##_gettime, \ + .tapping_term_ms = DT_INST_PROP(n, tapping_term_ms), \ .flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \ }; \ DEVICE_AND_API_INIT(behavior_hold_tap_##n, DT_INST_LABEL(n), behavior_hold_tap_init, \ diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index bbfbe36..d691e9f 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -12,6 +12,7 @@ #include #include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -22,18 +23,24 @@ struct behavior_key_press_data {}; static int behavior_key_press_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t keycode, u32_t _) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_key_press_config *cfg = dev->config_info; - LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); + LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", event.position, cfg->usage_page, + binding->param1); - return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, true)); + return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, binding->param1, true)); } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t keycode, u32_t _) { +static int on_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_key_press_config *cfg = dev->config_info; - LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", position, cfg->usage_page, keycode); + LOG_DBG("position %d usage_page 0x%02X keycode 0x%02X", event.position, cfg->usage_page, + binding->param1); - return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, keycode, false)); + return ZMK_EVENT_RAISE(create_keycode_state_changed(cfg->usage_page, binding->param1, false)); } static const struct behavior_driver_api behavior_key_press_driver_api = { diff --git a/app/src/behaviors/behavior_momentary_layer.c b/app/src/behaviors/behavior_momentary_layer.c index 80b7165..b1fb14b 100644 --- a/app/src/behaviors/behavior_momentary_layer.c +++ b/app/src/behaviors/behavior_momentary_layer.c @@ -11,6 +11,7 @@ #include #include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -19,16 +20,16 @@ struct behavior_mo_data {}; static int behavior_mo_init(struct device *dev) { return 0; }; -static int mo_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) { - LOG_DBG("position %d layer %d", position, layer); - - return zmk_keymap_layer_activate(layer); +static int mo_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); + return zmk_keymap_layer_activate(binding->param1); } -static int mo_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) { - LOG_DBG("position %d layer %d", position, layer); - - return zmk_keymap_layer_deactivate(layer); +static int mo_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); + return zmk_keymap_layer_deactivate(binding->param1); } static const struct behavior_driver_api behavior_mo_driver_api = { diff --git a/app/src/behaviors/behavior_none.c b/app/src/behaviors/behavior_none.c index b548e6f..96ea9d5 100644 --- a/app/src/behaviors/behavior_none.c +++ b/app/src/behaviors/behavior_none.c @@ -11,6 +11,8 @@ #include #include +#include + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_none_config {}; @@ -18,13 +20,13 @@ struct behavior_none_data {}; static int behavior_none_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, - u32_t _param2) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 0; } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, - u32_t _param2) { +static int on_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 0; } diff --git a/app/src/behaviors/behavior_reset.c b/app/src/behaviors/behavior_reset.c index 90de20b..d1233a5 100644 --- a/app/src/behaviors/behavior_reset.c +++ b/app/src/behaviors/behavior_reset.c @@ -11,6 +11,8 @@ #include #include +#include + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_reset_config { @@ -19,8 +21,9 @@ struct behavior_reset_config { static int behavior_reset_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, - u32_t _param2) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_reset_config *cfg = dev->config_info; // TODO: Correct magic code for going into DFU? diff --git a/app/src/behaviors/behavior_rgb_underglow.c b/app/src/behaviors/behavior_rgb_underglow.c index 621eab5..2ee6716 100644 --- a/app/src/behaviors/behavior_rgb_underglow.c +++ b/app/src/behaviors/behavior_rgb_underglow.c @@ -12,13 +12,15 @@ #include #include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static int behavior_rgb_underglow_init(struct device *dev) { return 0; } -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t action, u32_t _) { - switch (action) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + switch (binding->param1) { case RGB_TOG: return zmk_rgb_underglow_toggle(); case RGB_HUI: diff --git a/app/src/behaviors/behavior_sensor_rotate_key_press.c b/app/src/behaviors/behavior_sensor_rotate_key_press.c index 1a0bf03..71c4376 100644 --- a/app/src/behaviors/behavior_sensor_rotate_key_press.c +++ b/app/src/behaviors/behavior_sensor_rotate_key_press.c @@ -23,15 +23,16 @@ struct behavior_sensor_rotate_key_press_data {}; static int behavior_sensor_rotate_key_press_init(struct device *dev) { return 0; }; -static int on_sensor_binding_triggered(struct device *dev, struct device *sensor, - u32_t increment_keycode, u32_t decrement_keycode) { +static int on_sensor_binding_triggered(struct zmk_behavior_binding *binding, + struct device *sensor) { + struct device *dev = device_get_binding(binding->behavior_dev); const struct behavior_sensor_rotate_key_press_config *cfg = dev->config_info; struct sensor_value value; int err; u32_t keycode; struct keycode_state_changed *ev; LOG_DBG("usage_page 0x%02X inc keycode 0x%02X dec keycode 0x%02X", cfg->usage_page, - increment_keycode, decrement_keycode); + binding->param1, binding->param2); err = sensor_channel_get(sensor, SENSOR_CHAN_ROTATION, &value); @@ -42,10 +43,10 @@ static int on_sensor_binding_triggered(struct device *dev, struct device *sensor switch (value.val1) { case 1: - keycode = increment_keycode; + keycode = binding->param1; break; case -1: - keycode = decrement_keycode; + keycode = binding->param2; break; default: return -ENOTSUP; diff --git a/app/src/behaviors/behavior_toggle_layer.c b/app/src/behaviors/behavior_toggle_layer.c index 2819451..b3c6961 100644 --- a/app/src/behaviors/behavior_toggle_layer.c +++ b/app/src/behaviors/behavior_toggle_layer.c @@ -11,6 +11,7 @@ #include #include +#include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); @@ -19,15 +20,15 @@ struct behavior_tog_data {}; static int behavior_tog_init(struct device *dev) { return 0; }; -static int tog_keymap_binding_pressed(struct device *dev, u32_t position, u32_t layer, u32_t _) { - LOG_DBG("position %d layer %d", position, layer); - - return zmk_keymap_layer_toggle(layer); +static int tog_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); + return zmk_keymap_layer_toggle(binding->param1); } -static int tog_keymap_binding_released(struct device *dev, u32_t position, u32_t layer, u32_t _) { - LOG_DBG("position %d layer %d", position, layer); - +static int tog_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { + LOG_DBG("position %d layer %d", event.position, binding->param1); return 0; } diff --git a/app/src/behaviors/behavior_transparent.c b/app/src/behaviors/behavior_transparent.c index f7852f3..cede369 100644 --- a/app/src/behaviors/behavior_transparent.c +++ b/app/src/behaviors/behavior_transparent.c @@ -11,6 +11,8 @@ #include #include +#include + LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); struct behavior_transparent_config {}; @@ -18,13 +20,13 @@ struct behavior_transparent_data {}; static int behavior_transparent_init(struct device *dev) { return 0; }; -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t _param1, - u32_t _param2) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 1; } -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t _param1, - u32_t _param2) { +static int on_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 1; } diff --git a/app/src/keymap.c b/app/src/keymap.c index a87ce04..74fe60d 100644 --- a/app/src/keymap.c +++ b/app/src/keymap.c @@ -104,9 +104,14 @@ bool is_active_layer(u8_t layer, u32_t layer_state) { return (layer_state & BIT(layer)) == BIT(layer) || layer == zmk_keymap_layer_default; } -int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed) { +int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed, s64_t timestamp) { struct zmk_behavior_binding *binding = &zmk_keymap[layer][position]; struct device *behavior; + struct zmk_behavior_binding_event event = { + .layer = layer, + .position = position, + .timestamp = timestamp, + }; LOG_DBG("layer: %d position: %d, binding name: %s", layer, position, log_strdup(binding->behavior_dev)); @@ -119,20 +124,18 @@ int zmk_keymap_apply_position_state(int layer, u32_t position, bool pressed) { } if (pressed) { - return behavior_keymap_binding_pressed(behavior, position, binding->param1, - binding->param2); + return behavior_keymap_binding_pressed(binding, event); } else { - return behavior_keymap_binding_released(behavior, position, binding->param1, - binding->param2); + return behavior_keymap_binding_released(binding, event); } } -int zmk_keymap_position_state_changed(u32_t position, bool pressed) { +int zmk_keymap_position_state_changed(u32_t position, bool pressed, s64_t timestamp) { for (int layer = ZMK_KEYMAP_LAYERS_LEN - 1; layer >= zmk_keymap_layer_default; layer--) { u32_t layer_state = pressed ? zmk_keymap_layer_state : zmk_keymap_active_behavior_layer[position]; if (is_active_layer(layer, layer_state)) { - int ret = zmk_keymap_apply_position_state(layer, position, pressed); + int ret = zmk_keymap_apply_position_state(layer, position, pressed, timestamp); zmk_keymap_active_behavior_layer[position] = zmk_keymap_layer_state; @@ -171,8 +174,7 @@ int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor) { continue; } - ret = behavior_sensor_keymap_binding_triggered(behavior, sensor, binding->param1, - binding->param2); + ret = behavior_sensor_keymap_binding_triggered(binding, sensor); if (ret > 0) { LOG_DBG("behavior processing to continue to next layer"); @@ -194,7 +196,7 @@ int zmk_keymap_sensor_triggered(u8_t sensor_number, struct device *sensor) { int keymap_listener(const struct zmk_event_header *eh) { if (is_position_state_changed(eh)) { const struct position_state_changed *ev = cast_position_state_changed(eh); - return zmk_keymap_position_state_changed(ev->position, ev->state); + return zmk_keymap_position_state_changed(ev->position, ev->state, ev->timestamp); #if ZMK_KEYMAP_HAS_SENSORS } else if (is_sensor_event(eh)) { const struct sensor_event *ev = cast_sensor_event(eh); diff --git a/app/src/kscan.c b/app/src/kscan.c index 0046f5c..8575e70 100644 --- a/app/src/kscan.c +++ b/app/src/kscan.c @@ -52,6 +52,7 @@ void zmk_kscan_process_msgq(struct k_work *item) { pos_ev = new_position_state_changed(); pos_ev->state = pressed; pos_ev->position = position; + pos_ev->timestamp = k_uptime_get(); ZMK_EVENT_RAISE(pos_ev); } } diff --git a/app/src/split/bluetooth/central.c b/app/src/split/bluetooth/central.c index cb1b68b..ed52ba0 100644 --- a/app/src/split/bluetooth/central.c +++ b/app/src/split/bluetooth/central.c @@ -60,6 +60,7 @@ static u8_t split_central_notify_func(struct bt_conn *conn, struct bt_gatt_subsc struct position_state_changed *pos_ev = new_position_state_changed(); pos_ev->position = position; pos_ev->state = pressed; + pos_ev->timestamp = k_uptime_get(); LOG_DBG("Trigger key position state change for %d", position); ZMK_EVENT_RAISE(pos_ev); diff --git a/app/tests/hold-tap/balanced/many-nested/events.patterns b/app/tests/hold-tap/balanced/many-nested/events.patterns new file mode 100644 index 0000000..fdf2b15 --- /dev/null +++ b/app/tests/hold-tap/balanced/many-nested/events.patterns @@ -0,0 +1,4 @@ +s/.*hid_listener_keycode/kp/p +s/.*mo_keymap_binding/mo/p +s/.*on_hold_tap_binding/ht_binding/p +s/.*decide_hold_tap/ht_decide/p \ No newline at end of file diff --git a/app/tests/hold-tap/balanced/many-nested/keycode_events.snapshot b/app/tests/hold-tap/balanced/many-nested/keycode_events.snapshot new file mode 100644 index 0000000..806896f --- /dev/null +++ b/app/tests/hold-tap/balanced/many-nested/keycode_events.snapshot @@ -0,0 +1,20 @@ +ht_binding_pressed: 0 new undecided hold_tap +ht_decide: 0 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe1 +ht_binding_pressed: 1 new undecided hold_tap +ht_decide: 1 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe0 +ht_binding_pressed: 2 new undecided hold_tap +ht_binding_released: 0 cleaning up hold-tap +ht_decide: 2 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe3 +ht_binding_pressed: 3 new undecided hold_tap +ht_binding_released: 1 cleaning up hold-tap +ht_decide: 3 decided hold (balanced event 3) +kp_pressed: usage_page 0x07 keycode 0xe2 +kp_released: usage_page 0x07 keycode 0xe1 +kp_released: usage_page 0x07 keycode 0xe0 +kp_released: usage_page 0x07 keycode 0xe3 +ht_binding_released: 2 cleaning up hold-tap +kp_released: usage_page 0x07 keycode 0xe2 +ht_binding_released: 3 cleaning up hold-tap diff --git a/app/tests/hold-tap/balanced/many-nested/native_posix.keymap b/app/tests/hold-tap/balanced/many-nested/native_posix.keymap new file mode 100644 index 0000000..3cb04c3 --- /dev/null +++ b/app/tests/hold-tap/balanced/many-nested/native_posix.keymap @@ -0,0 +1,41 @@ +#include +#include +#include + +/ { + behaviors { + ht_bal: behavior_hold_tap_balanced { + compatible = "zmk,behavior-hold-tap"; + label = "HOLD_TAP_BALANCED"; + #binding-cells = <2>; + flavor = "balanced"; + tapping_term_ms = <300>; + bindings = <&kp>, <&kp>; + }; + }; + + keymap { + compatible = "zmk,keymap"; + label ="Default keymap"; + + default_layer { + bindings = < + &ht_bal LSFT F &ht_bal LCTL J + &ht_bal LGUI H &ht_bal LALT L + >; + }; + }; +}; + +&kscan { + events = < + ZMK_MOCK_PRESS(0,0,100) + ZMK_MOCK_PRESS(0,1,100) + ZMK_MOCK_PRESS(1,0,100) + ZMK_MOCK_PRESS(1,1,100) + ZMK_MOCK_RELEASE(0,0,100) + ZMK_MOCK_RELEASE(0,1,100) + ZMK_MOCK_RELEASE(1,0,100) + ZMK_MOCK_RELEASE(1,1,100) + >; +}; -- cgit v1.2.3 From 7fc7a351170fb2017cb40e8de79b4535a936a6f6 Mon Sep 17 00:00:00 2001 From: Mubeen Khan Date: Sat, 10 Oct 2020 16:51:17 -0500 Subject: Revised keymap to Qwerty --- app/boards/shields/tg4x/tg4x.keymap | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'app') diff --git a/app/boards/shields/tg4x/tg4x.keymap b/app/boards/shields/tg4x/tg4x.keymap index 64e98bb..bee5c87 100644 --- a/app/boards/shields/tg4x/tg4x.keymap +++ b/app/boards/shields/tg4x/tg4x.keymap @@ -31,27 +31,27 @@ default_layer { bindings = < - &kp GRAV &kp Q &kp W &kp F &kp P &kp B &kp J &kp L &kp U &kp Y &kp SCLN &kp BKSP - &kp TAB &hm LGUI A &hm LALT R &hm LCTL S &hm LSFT T &kp G &kp M &hm RSFT N &hm RCTL E &hm RALT I &hm RGUI O &kp RET - &kp LSFT &kp Z &kp X &kp C &kp D &kp V &kp K &kp H &kp CMMA &kp DOT &kp FSLH &kp QUOT - &kp LCTL &kp LALT &kp LGUI < 1 BKSP < 2 SPC &kp LARW &kp DARW &kp UARW &kp RARW + &kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BKSP + &kp TAB &hm LGUI A &hm LALT S &hm LCTL D &hm LSFT F &kp G &kp H &hm RSFT J &hm RCTL K &hm RALT L &hm RGUI SCLN &kp RET + &kp LSFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp CMMA &kp DOT &kp FSLH &kp QUOT + &kp LCTL &kp LALT &kp LGUI < 1 BKSP < 2 SPC &kp LARW &kp DARW &kp UARW &kp RARW >; }; lower { bindings = < - &kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp PRSC - &kp DEL &trans &kp VOLU &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans - &trans &trans &kp VOLD &trans &trans &trans &trans &trans &trans &bt BT_PRV &bt BT_NXT &bt BT_CLR - &bootloader &reset &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 + &kp GRAV &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp PRSC + &kp DEL &trans &kp VOLU &trans &trans &trans &trans &kp LARW &kp DARW &kp UARW &kp RARW &trans + &trans &trans &kp VOLD &trans &trans &trans &trans &trans &trans &bt BT_PRV &bt BT_NXT &bt BT_CLR + &bootloader &reset &trans &trans &trans &trans &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 >; }; raise { bindings = < - &kp ESC &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp PRSC - &kp DEL &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH - &trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp TILD &kp HOME &kp PGUP &kp PGDN &kp END - &trans &trans &trans &trans &trans &trans &kp M_NEXT &kp M_VOLD &kp M_VOLU &kp M_PLAY + &kp GRAV &kp NUM_1 &kp NUM_2 &kp NUM_3 &kp NUM_4 &kp NUM_5 &kp NUM_6 &kp NUM_7 &kp NUM_8 &kp NUM_9 &kp NUM_0 &kp PRSC + &kp DEL &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp MINUS &kp EQL &kp LBKT &kp RBKT &kp BSLH + &trans &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp TILD &kp HOME &kp PGUP &kp PGDN &kp END + &trans &trans &trans &trans &trans &trans &kp M_NEXT &kp M_VOLD &kp M_VOLU &kp M_PLAY >; }; }; -- cgit v1.2.3 From 78cb6c8b2115b5eebeddc03d7d8ecff6ba2574a7 Mon Sep 17 00:00:00 2001 From: Nuxiom <61762260+nuxiom@users.noreply.github.com> Date: Sun, 11 Oct 2020 16:57:26 +1100 Subject: Fix kscan_gpio_irq_callback_handler_##n conditional macro --- app/drivers/zephyr/kscan_gpio_matrix.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index a0b22e4..ea07ee8 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -181,19 +181,19 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ - (static void kscan_gpio_irq_callback_handler_##n( \ - struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ - struct kscan_gpio_irq_callback_##n *data = \ - CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ - kscan_gpio_disable_interrupts_##n(data->dev); \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(data->work); }), ({ \ - k_delayed_work_cancel(data->work); \ - k_delayed_work_submit( \ - data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ - })) \ - })) \ + static void kscan_gpio_irq_callback_handler_##n( \ + struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + struct kscan_gpio_irq_callback_##n *data = \ + CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ + COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ + (kscan_gpio_disable_interrupts_##n(data->dev);)) \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), \ + ({ k_work_submit(data->work); }), ({ \ + k_delayed_work_cancel(data->work); \ + k_delayed_work_submit( \ + data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + })) \ + } \ \ static struct kscan_gpio_data_##n kscan_gpio_data_##n = { \ .rows = {[INST_MATRIX_ROWS(n) - 1] = NULL}, .cols = {[INST_MATRIX_COLS(n) - 1] = NULL}}; \ -- cgit v1.2.3 From 1c0c02e09773413752e5f166a30178073c570349 Mon Sep 17 00:00:00 2001 From: Nuxiom <61762260+nuxiom@users.noreply.github.com> Date: Sun, 11 Oct 2020 17:51:06 +1100 Subject: Reformatted according to clang-format lint --- app/drivers/zephyr/kscan_gpio_matrix.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'app') diff --git a/app/drivers/zephyr/kscan_gpio_matrix.c b/app/drivers/zephyr/kscan_gpio_matrix.c index ea07ee8..ec4fb39 100644 --- a/app/drivers/zephyr/kscan_gpio_matrix.c +++ b/app/drivers/zephyr/kscan_gpio_matrix.c @@ -181,17 +181,16 @@ static int kscan_gpio_config_interrupts(struct device **devices, struct kscan_gpio_data_##n *data = CONTAINER_OF(work, struct kscan_gpio_data_##n, work); \ kscan_gpio_read_##n(data->dev); \ } \ - static void kscan_gpio_irq_callback_handler_##n( \ - struct device *dev, struct gpio_callback *cb, gpio_port_pins_t pin) { \ + static void kscan_gpio_irq_callback_handler_##n(struct device *dev, struct gpio_callback *cb, \ + gpio_port_pins_t pin) { \ struct kscan_gpio_irq_callback_##n *data = \ CONTAINER_OF(cb, struct kscan_gpio_irq_callback_##n, callback); \ COND_CODE_1(CONFIG_ZMK_KSCAN_MATRIX_POLLING, (), \ (kscan_gpio_disable_interrupts_##n(data->dev);)) \ - COND_CODE_0(DT_INST_PROP(n, debounce_period), \ - ({ k_work_submit(data->work); }), ({ \ + COND_CODE_0(DT_INST_PROP(n, debounce_period), ({ k_work_submit(data->work); }), ({ \ k_delayed_work_cancel(data->work); \ - k_delayed_work_submit( \ - data->work, K_MSEC(DT_INST_PROP(n, debounce_period))); \ + k_delayed_work_submit(data->work, \ + K_MSEC(DT_INST_PROP(n, debounce_period))); \ })) \ } \ \ -- cgit v1.2.3 From 7798c974f697afb43d13cf8692802caf87210b02 Mon Sep 17 00:00:00 2001 From: Joel Spadin Date: Sun, 11 Oct 2020 14:58:24 -0500 Subject: fix: don't leak bt_conn refs bt_conn_lookup_addr_le() gives us a new reference that must be released with bt_conn_unref() --- app/src/hog.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/src/hog.c b/app/src/hog.c index 11349ac..bcd652d 100644 --- a/app/src/hog.c +++ b/app/src/hog.c @@ -164,8 +164,10 @@ int zmk_hog_send_keypad_report(struct zmk_hid_keypad_report_body *report) { LOG_DBG("Sending to NULL? %s", conn == NULL ? "yes" : "no"); - return bt_gatt_notify(conn, &hog_svc.attrs[5], report, - sizeof(struct zmk_hid_keypad_report_body)); + int err = + bt_gatt_notify(conn, &hog_svc.attrs[5], report, sizeof(struct zmk_hid_keypad_report_body)); + bt_conn_unref(conn); + return err; }; int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { @@ -174,6 +176,8 @@ int zmk_hog_send_consumer_report(struct zmk_hid_consumer_report_body *report) { return -ENOTCONN; } - return bt_gatt_notify(conn, &hog_svc.attrs[10], report, - sizeof(struct zmk_hid_consumer_report_body)); + int err = bt_gatt_notify(conn, &hog_svc.attrs[10], report, + sizeof(struct zmk_hid_consumer_report_body)); + bt_conn_unref(conn); + return err; }; -- cgit v1.2.3 From b5e1c8a7addc186d0bd542082482157ffb2d1f5a Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Sat, 10 Oct 2020 09:29:07 +0800 Subject: New behavior for ext power control --- app/CMakeLists.txt | 1 + app/boards/shields/lily58/lily58.keymap | 11 +++-- app/dts/behaviors.dtsi | 3 +- app/dts/behaviors/ext_power.dtsi | 9 ++++ .../bindings/behaviors/zmk,behavior-ext-power.yaml | 10 ++++ app/include/dt-bindings/zmk/ext_power.h | 16 +++++++ app/src/behaviors/behavior_ext_power.c | 54 ++++++++++++++++++++++ 7 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 app/dts/behaviors/ext_power.dtsi create mode 100644 app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml create mode 100644 app/include/dt-bindings/zmk/ext_power.h create mode 100644 app/src/behaviors/behavior_ext_power.c (limited to 'app') diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 31d28f5..39509ed 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -46,6 +46,7 @@ if (NOT CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) target_sources(app PRIVATE src/behaviors/behavior_transparent.c) target_sources(app PRIVATE src/behaviors/behavior_none.c) target_sources(app PRIVATE src/behaviors/behavior_sensor_rotate_key_press.c) + target_sources_ifdef(CONFIG_ZMK_EXT_POWER app PRIVATE src/behaviors/behavior_ext_power.c) target_sources(app PRIVATE src/keymap.c) endif() target_sources_ifdef(CONFIG_ZMK_RGB_UNDERGLOW app PRIVATE src/behaviors/behavior_rgb_underglow.c) diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 997a124..90dec23 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -7,6 +7,7 @@ #include #include #include +#include / { keymap { @@ -38,11 +39,11 @@ // | | | | | | | | | | | _ | + | { | } | "|" | // | | | | | | | | | | bindings = < -&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans -&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 -&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD -&trans &trans &trans &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE - &trans &trans &trans &trans &trans &trans &trans &trans +&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans +&kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 +&kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD +&trans &ext_power EP_ON &ext_power EP_OFF &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE + &trans &trans &trans &trans &trans &trans &trans &trans >; sensor-bindings = <&inc_dec_cp M_VOLU M_VOLD>; diff --git a/app/dts/behaviors.dtsi b/app/dts/behaviors.dtsi index 202202b..36c918c 100644 --- a/app/dts/behaviors.dtsi +++ b/app/dts/behaviors.dtsi @@ -8,4 +8,5 @@ #include #include #include -#include \ No newline at end of file +#include +#include diff --git a/app/dts/behaviors/ext_power.dtsi b/app/dts/behaviors/ext_power.dtsi new file mode 100644 index 0000000..c4d8714 --- /dev/null +++ b/app/dts/behaviors/ext_power.dtsi @@ -0,0 +1,9 @@ +/ { + behaviors { + ext_power: behavior_ext_power { + compatible = "zmk,behavior-ext-power"; + label = "EXT_POWER_BEHAVIOR"; + #binding-cells = <2>; + }; + }; +}; diff --git a/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml b/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml new file mode 100644 index 0000000..b9abd92 --- /dev/null +++ b/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml @@ -0,0 +1,10 @@ +# +# Copyright (c) 2020, The ZMK Contributors +# SPDX-License-Identifier: MIT +# + +description: External power control Behavior + +compatible: "zmk,behavior-ext-power" + +include: two_param.yaml diff --git a/app/include/dt-bindings/zmk/ext_power.h b/app/include/dt-bindings/zmk/ext_power.h new file mode 100644 index 0000000..a72b657 --- /dev/null +++ b/app/include/dt-bindings/zmk/ext_power.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define EXT_POWER_OFF_CMD 0 +#define EXT_POWER_ON_CMD 1 + +/* + * Note: Some future commands might include additional parameters, so we + * defines these aliases up front. + */ + +#define EP_ON EXT_POWER_ON_CMD 0 +#define EP_OFF EXT_POWER_OFF_CMD 0 diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c new file mode 100644 index 0000000..2bd93ee --- /dev/null +++ b/app/src/behaviors/behavior_ext_power.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2020 The ZMK Contributors + * + * SPDX-License-Identifier: MIT + */ + +#define DT_DRV_COMPAT zmk_behavior_ext_power + +#include +#include +#include + +#include + +#include +LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); + +#include + +static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) { + const struct device *ext_power = device_get_binding("EXT_POWER"); + if (ext_power == NULL) { + LOG_ERR("Unable to retrieve ext_power device: %d", command); + return -EIO; + } + const struct ext_power_api *ext_power_api = ext_power->driver_api; + + switch (command) { + case EXT_POWER_OFF_CMD: + return ext_power_api->disable(ext_power); + case EXT_POWER_ON_CMD: + return ext_power_api->enable(ext_power); + default: + LOG_ERR("Unknown ext_power command: %d", command); + } + + return -ENOTSUP; +} + +static int behavior_ext_power_init(struct device *dev) { return 0; }; + +static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, + u32_t arg) { + return 0; +} + +static const struct behavior_driver_api behavior_ext_power_driver_api = { + .binding_pressed = on_keymap_binding_pressed, + .binding_released = on_keymap_binding_released, +}; + +DEVICE_AND_API_INIT(behavior_ext_power, DT_INST_LABEL(0), behavior_ext_power_init, NULL, NULL, + APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, + &behavior_ext_power_driver_api); -- cgit v1.2.3 From 5d1c083959967b6f55ce7cff3c83442bc71d23cb Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Mon, 12 Oct 2020 00:30:51 +0800 Subject: Added toggle and removed a param --- app/include/dt-bindings/zmk/ext_power.h | 11 ++++------- app/src/behaviors/behavior_ext_power.c | 5 +++++ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'app') diff --git a/app/include/dt-bindings/zmk/ext_power.h b/app/include/dt-bindings/zmk/ext_power.h index a72b657..2a3e846 100644 --- a/app/include/dt-bindings/zmk/ext_power.h +++ b/app/include/dt-bindings/zmk/ext_power.h @@ -6,11 +6,8 @@ #define EXT_POWER_OFF_CMD 0 #define EXT_POWER_ON_CMD 1 +#define EXT_POWER_TOGGLE_CMD 2 -/* - * Note: Some future commands might include additional parameters, so we - * defines these aliases up front. - */ - -#define EP_ON EXT_POWER_ON_CMD 0 -#define EP_OFF EXT_POWER_OFF_CMD 0 +#define EP_ON EXT_POWER_ON_CMD +#define EP_OFF EXT_POWER_OFF_CMD +#define EP_TOG EXT_POWER_TOGGLE_CMD diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index 2bd93ee..7f06e1d 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -30,6 +30,11 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c return ext_power_api->disable(ext_power); case EXT_POWER_ON_CMD: return ext_power_api->enable(ext_power); + case EXT_POWER_TOGGLE_CMD: + if(ext_power_api->get(ext_power) > 0) + return ext_power_api->disable(ext_power); + else + return ext_power_api->enable(ext_power); default: LOG_ERR("Unknown ext_power command: %d", command); } -- cgit v1.2.3 From 4adcb396ff01bf4a8ab98799139ed3f3339d207c Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Mon, 12 Oct 2020 23:50:54 +0800 Subject: Rebased and fixed nasty code --- app/boards/shields/lily58/lily58.keymap | 2 +- app/src/behaviors/behavior_ext_power.c | 32 ++++++++++++++------------------ app/src/behaviors/behavior_key_press.c | 2 +- 3 files changed, 16 insertions(+), 20 deletions(-) (limited to 'app') diff --git a/app/boards/shields/lily58/lily58.keymap b/app/boards/shields/lily58/lily58.keymap index 90dec23..d44b3fe 100644 --- a/app/boards/shields/lily58/lily58.keymap +++ b/app/boards/shields/lily58/lily58.keymap @@ -42,7 +42,7 @@ &bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &trans &trans &trans &trans &trans &trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11 &kp F12 &kp GRAV &kp BANG &kp ATSN &kp HASH &kp CURU &kp PRCT &kp CRRT &kp AMPS &kp KMLT &kp LPRN &kp RPRN &kp TILD -&trans &ext_power EP_ON &ext_power EP_OFF &trans &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE +&trans &ext_power EP_ON &ext_power EP_OFF &ext_power EP_TOG &trans &trans &trans &trans &trans &kp MINUS &kp KPLS &kp LCUR &kp RCUR &kp PIPE &trans &trans &trans &trans &trans &trans &trans &trans >; diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index 7f06e1d..e8190c1 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -9,32 +9,29 @@ #include #include #include - -#include +#include #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); -#include - -static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t command, u32_t arg) { +static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { const struct device *ext_power = device_get_binding("EXT_POWER"); if (ext_power == NULL) { LOG_ERR("Unable to retrieve ext_power device: %d", command); return -EIO; } - const struct ext_power_api *ext_power_api = ext_power->driver_api; - switch (command) { + switch (binding->param1) { case EXT_POWER_OFF_CMD: - return ext_power_api->disable(ext_power); + return ext_power_disable(ext_power); case EXT_POWER_ON_CMD: - return ext_power_api->enable(ext_power); + return ext_power_enable(ext_power); case EXT_POWER_TOGGLE_CMD: - if(ext_power_api->get(ext_power) > 0) - return ext_power_api->disable(ext_power); + if (ext_power_get(ext_power) > 0) + return ext_power_disable(ext_power); else - return ext_power_api->enable(ext_power); + return ext_power_enable(ext_power); default: LOG_ERR("Unknown ext_power command: %d", command); } @@ -42,18 +39,17 @@ static int on_keymap_binding_pressed(struct device *dev, u32_t position, u32_t c return -ENOTSUP; } -static int behavior_ext_power_init(struct device *dev) { return 0; }; - -static int on_keymap_binding_released(struct device *dev, u32_t position, u32_t command, - u32_t arg) { +static int on_keymap_binding_released(struct zmk_behavior_binding *binding, + struct zmk_behavior_binding_event event) { return 0; } +static int behavior_ext_power_init(struct device *dev) { return 0; }; + static const struct behavior_driver_api behavior_ext_power_driver_api = { .binding_pressed = on_keymap_binding_pressed, .binding_released = on_keymap_binding_released, }; DEVICE_AND_API_INIT(behavior_ext_power, DT_INST_LABEL(0), behavior_ext_power_init, NULL, NULL, - APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, - &behavior_ext_power_driver_api); + APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY, &behavior_ext_power_driver_api); diff --git a/app/src/behaviors/behavior_key_press.c b/app/src/behaviors/behavior_key_press.c index d691e9f..923b098 100644 --- a/app/src/behaviors/behavior_key_press.c +++ b/app/src/behaviors/behavior_key_press.c @@ -54,4 +54,4 @@ static const struct behavior_driver_api behavior_key_press_driver_api = { &behavior_key_press_data_##n, &behavior_key_press_config_##n, APPLICATION, \ CONFIG_KERNEL_INIT_PRIORITY_DEFAULT, &behavior_key_press_driver_api); -DT_INST_FOREACH_STATUS_OKAY(KP_INST) \ No newline at end of file +DT_INST_FOREACH_STATUS_OKAY(KP_INST) -- cgit v1.2.3 From 2e649b7fd4113ff2f0e6ffdfa1ac6ede5feaebf6 Mon Sep 17 00:00:00 2001 From: Mega Mind <68985133+megamind4089@users.noreply.github.com> Date: Tue, 13 Oct 2020 00:09:57 +0800 Subject: Fix compilation errors and minor tweaks --- app/dts/behaviors/ext_power.dtsi | 2 +- app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml | 2 +- app/src/behaviors/behavior_ext_power.c | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/dts/behaviors/ext_power.dtsi b/app/dts/behaviors/ext_power.dtsi index c4d8714..92f0035 100644 --- a/app/dts/behaviors/ext_power.dtsi +++ b/app/dts/behaviors/ext_power.dtsi @@ -3,7 +3,7 @@ ext_power: behavior_ext_power { compatible = "zmk,behavior-ext-power"; label = "EXT_POWER_BEHAVIOR"; - #binding-cells = <2>; + #binding-cells = <1>; }; }; }; diff --git a/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml b/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml index b9abd92..d86c6f9 100644 --- a/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml +++ b/app/dts/bindings/behaviors/zmk,behavior-ext-power.yaml @@ -7,4 +7,4 @@ description: External power control Behavior compatible: "zmk,behavior-ext-power" -include: two_param.yaml +include: one_param.yaml diff --git a/app/src/behaviors/behavior_ext_power.c b/app/src/behaviors/behavior_ext_power.c index e8190c1..825f983 100644 --- a/app/src/behaviors/behavior_ext_power.c +++ b/app/src/behaviors/behavior_ext_power.c @@ -11,14 +11,16 @@ #include #include +#include + #include LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL); static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, struct zmk_behavior_binding_event event) { - const struct device *ext_power = device_get_binding("EXT_POWER"); + struct device *ext_power = device_get_binding("EXT_POWER"); if (ext_power == NULL) { - LOG_ERR("Unable to retrieve ext_power device: %d", command); + LOG_ERR("Unable to retrieve ext_power device: %d", binding->param1); return -EIO; } @@ -33,7 +35,7 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding, else return ext_power_enable(ext_power); default: - LOG_ERR("Unknown ext_power command: %d", command); + LOG_ERR("Unknown ext_power command: %d", binding->param1); } return -ENOTSUP; -- cgit v1.2.3 From 6d9aa4f5ea033d08e6db8c368242e80e205b6f1a Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 12 Oct 2020 13:03:10 -0400 Subject: fix: Updated copyright headers to single author file. --- app/include/dt-bindings/zmk/bt.h | 2 +- app/include/zmk/ble/profile.h | 2 +- app/include/zmk/events/ble-active-profile-changed.h | 2 +- app/src/behaviors/behavior_bt.c | 2 +- app/src/events/ble_active_profile_changed.c | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) (limited to 'app') diff --git a/app/include/dt-bindings/zmk/bt.h b/app/include/dt-bindings/zmk/bt.h index a403d35..8ca1060 100644 --- a/app/include/dt-bindings/zmk/bt.h +++ b/app/include/dt-bindings/zmk/bt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/ble/profile.h b/app/include/zmk/ble/profile.h index 9a79c6d..1df2743 100644 --- a/app/include/zmk/ble/profile.h +++ b/app/include/zmk/ble/profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/include/zmk/events/ble-active-profile-changed.h b/app/include/zmk/events/ble-active-profile-changed.h index 66f40c7..1e3a198 100644 --- a/app/include/zmk/events/ble-active-profile-changed.h +++ b/app/include/zmk/events/ble-active-profile-changed.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/behaviors/behavior_bt.c b/app/src/behaviors/behavior_bt.c index 922c157..066c437 100644 --- a/app/src/behaviors/behavior_bt.c +++ b/app/src/behaviors/behavior_bt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ diff --git a/app/src/events/ble_active_profile_changed.c b/app/src/events/ble_active_profile_changed.c index a270a14..06988e2 100644 --- a/app/src/events/ble_active_profile_changed.c +++ b/app/src/events/ble_active_profile_changed.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Peter Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From eee8eb6e776c81192e81f685bd24a3795467ec91 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Mon, 12 Oct 2020 13:04:24 -0400 Subject: fix: Single author file copyright header fix. --- app/boards/shields/tg4x/tg4x.overlay | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/boards/shields/tg4x/tg4x.overlay b/app/boards/shields/tg4x/tg4x.overlay index acab2e3..10ce524 100644 --- a/app/boards/shields/tg4x/tg4x.overlay +++ b/app/boards/shields/tg4x/tg4x.overlay @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson, Richard Jones + * Copyright (c) 2020 The ZMK Contrbutors * * SPDX-License-Identifier: MIT */ -- cgit v1.2.3 From 59e8c58051298175bc1c77593f1b24d9394aa848 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 13 Oct 2020 00:11:08 -0400 Subject: fix: Copyright header for cradio.dtsi --- app/boards/shields/cradio/cradio.dtsi | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/cradio.dtsi b/app/boards/shields/cradio/cradio.dtsi index 1f2603c..43f9049 100644 --- a/app/boards/shields/cradio/cradio.dtsi +++ b/app/boards/shields/cradio/cradio.dtsi @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Pete Johanson + * Copyright (c) 2020 The ZMK Contributors * * SPDX-License-Identifier: MIT */ @@ -48,4 +48,3 @@ }; }; }; - -- cgit v1.2.3 From 3186a553a5d18f24fc6fbac2987cf8054afadcbb Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Tue, 13 Oct 2020 21:00:54 -0400 Subject: fix(shields): Add default qaz.conf file. --- app/boards/shields/qaz/qaz.conf | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 app/boards/shields/qaz/qaz.conf (limited to 'app') diff --git a/app/boards/shields/qaz/qaz.conf b/app/boards/shields/qaz/qaz.conf new file mode 100644 index 0000000..e69de29 -- cgit v1.2.3 From 204d1300ba6b13041e9a69cc297c06ac189f1f0d Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 15 Oct 2020 00:00:37 -0400 Subject: fix(ble): Only advertise when needed.* Once we have a peer connected to for the active profile, don't continue advertising. --- app/src/ble.c | 135 +++++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 111 insertions(+), 24 deletions(-) (limited to 'app') diff --git a/app/src/ble.c b/app/src/ble.c index 49e2b3b..8cc42bc 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -45,6 +45,18 @@ static u8_t passkey_digit = 0; #define PROFILE_COUNT CONFIG_BT_MAX_PAIRED #endif +enum advertising_type { + ZMK_ADV_NONE, + ZMK_ADV_DIR, + ZMK_ADV_CONN, +} advertising_status; + +#define CURR_ADV(adv) (adv << 4) + +#define ZMK_ADV_CONN_NAME \ + BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | BT_LE_ADV_OPT_USE_NAME, \ + BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, NULL) + static struct zmk_ble_profile profiles[PROFILE_COUNT]; static u8_t active_profile; @@ -92,29 +104,97 @@ void set_profile_address(u8_t index, const bt_addr_le_t *addr) { raise_profile_changed_event(); } -int zmk_ble_adv_pause() { - int err = bt_le_adv_stop(); - if (err) { - LOG_ERR("Failed to stop advertising (err %d)", err); - return err; +bool active_profile_is_connected() { + struct bt_conn *conn; + bt_addr_le_t *addr = zmk_ble_active_profile_addr(); + if (!bt_addr_le_cmp(addr, BT_ADDR_LE_ANY)) { + return false; + } else if ((conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr)) == NULL) { + return false; } - return 0; -}; + bt_conn_unref(conn); -int zmk_ble_adv_resume() { - LOG_DBG("active_profile %d, directed? %s", active_profile, - active_profile_is_open() ? "no" : "yes"); + return true; +} - int err = bt_le_adv_start(BT_LE_ADV_CONN_NAME, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); - if (err) { - LOG_ERR("Advertising failed to start (err %d)", err); - return err; +#define CHECKED_ADV_STOP() \ + err = bt_le_adv_stop(); \ + advertising_status = ZMK_ADV_NONE; \ + if (err) { \ + LOG_ERR("Failed to stop advertising (err %d)", err); \ + return err; \ + } + +#define CHECKED_DIR_ADV() \ + addr = zmk_ble_active_profile_addr(); \ + conn = bt_conn_lookup_addr_le(BT_ID_DEFAULT, addr); \ + if (conn != NULL) { /* TODO: Check status of connection */ \ + LOG_DBG("Skipping advertising, profile host is already connected"); \ + bt_conn_unref(conn); \ + return 0; \ + } \ + err = bt_le_adv_start(BT_LE_ADV_CONN_DIR_LOW_DUTY(addr), zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), \ + NULL, 0); \ + if (err) { \ + LOG_ERR("Advertising failed to start (err %d)", err); \ + return err; \ + } \ + advertising_status = ZMK_ADV_DIR; + +#define CHECKED_OPEN_ADV() \ + err = bt_le_adv_start(ZMK_ADV_CONN_NAME, zmk_ble_ad, ARRAY_SIZE(zmk_ble_ad), NULL, 0); \ + if (err) { \ + LOG_ERR("Advertising failed to start (err %d)", err); \ + return err; \ + } \ + advertising_status = ZMK_ADV_CONN; + +int update_advertising() { + int err = 0; + bt_addr_le_t *addr; + struct bt_conn *conn; + enum advertising_type desired_adv = ZMK_ADV_NONE; + + if (active_profile_is_open() || !active_profile_is_connected()) { + desired_adv = ZMK_ADV_CONN; + } else if (!active_profile_is_connected()) { + desired_adv = ZMK_ADV_CONN; + // Need to fix directed advertising for privacy centrals. See + // https://github.com/zephyrproject-rtos/zephyr/pull/14984 char + // addr_str[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(zmk_ble_active_profile_addr(), addr_str, + // sizeof(addr_str)); + + // LOG_DBG("Directed advertising to %s", log_strdup(addr_str)); + // desired_adv = ZMK_ADV_DIR; + } + LOG_DBG("advertising from %d to %d", advertising_status, desired_adv); + + switch (desired_adv + CURR_ADV(advertising_status)) { + case ZMK_ADV_DIR + CURR_ADV(ZMK_ADV_DIR): + case ZMK_ADV_DIR + CURR_ADV(ZMK_ADV_CONN): + CHECKED_ADV_STOP(); + CHECKED_DIR_ADV(); + break; + case ZMK_ADV_DIR + CURR_ADV(ZMK_ADV_NONE): + CHECKED_DIR_ADV(); + break; + case ZMK_ADV_CONN + CURR_ADV(ZMK_ADV_DIR): + CHECKED_ADV_STOP(); + CHECKED_OPEN_ADV(); + break; + case ZMK_ADV_CONN + CURR_ADV(ZMK_ADV_NONE): + CHECKED_OPEN_ADV(); + break; } return 0; }; +static void update_advertising_callback(struct k_work *work) { update_advertising(); } + +K_WORK_DEFINE(update_advertising_work, update_advertising_callback); + int zmk_ble_clear_bonds() { LOG_DBG(""); @@ -124,6 +204,8 @@ int zmk_ble_clear_bonds() { set_profile_address(active_profile, BT_ADDR_LE_ANY); } + update_advertising(); + return 0; }; @@ -134,9 +216,13 @@ int zmk_ble_prof_select(u8_t index) { } active_profile = index; - return settings_save_one("ble/active_profile", &active_profile, sizeof(active_profile)); + settings_save_one("ble/active_profile", &active_profile, sizeof(active_profile)); + + update_advertising(); raise_profile_changed_event(); + + return 0; }; int zmk_ble_prof_next() { @@ -234,8 +320,11 @@ static void connected(struct bt_conn *conn, u8_t err) { char addr[BT_ADDR_LE_STR_LEN]; bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr)); + advertising_status = ZMK_ADV_NONE; + if (err) { LOG_WRN("Failed to connect to %s (%u)", log_strdup(addr), err); + update_advertising(); return; } @@ -250,6 +339,8 @@ static void connected(struct bt_conn *conn, u8_t err) { if (bt_conn_set_security(conn, BT_SECURITY_L2)) { LOG_ERR("Failed to set security"); } + + update_advertising(); } static void disconnected(struct bt_conn *conn, u8_t reason) { @@ -259,14 +350,9 @@ static void disconnected(struct bt_conn *conn, u8_t reason) { LOG_DBG("Disconnected from %s (reason 0x%02x)", log_strdup(addr), reason); -#if IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_CENTRAL) - // if (bt_addr_le_cmp(&peripheral_addr, BT_ADDR_LE_ANY) && bt_addr_le_cmp(&peripheral_addr, - // bt_conn_get_dst(conn))) { - // zmk_ble_adv_resume(); - // } -#else - // zmk_ble_adv_resume(); -#endif + // We need to do this in a work callback, otherwise the advertising update will still see the + // connection for a profile as active, and not start advertising yet. + k_work_submit(&update_advertising_work); } static void security_changed(struct bt_conn *conn, bt_security_t level, enum bt_security_err err) { @@ -361,6 +447,7 @@ static void auth_pairing_complete(struct bt_conn *conn, bool bonded) { #endif /* !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) */ set_profile_address(active_profile, dst); + update_advertising(); }; static struct bt_conn_auth_cb zmk_ble_auth_cb_display = { @@ -383,7 +470,7 @@ static void zmk_ble_ready(int err) { return; } - zmk_ble_adv_resume(); + update_advertising(); } static int zmk_ble_init(struct device *_arg) { -- cgit v1.2.3 From e468677c4ea5f382a8e48793eda87ecd3d07a4dd Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Thu, 15 Oct 2020 20:29:00 -0400 Subject: fix(shields): Proper cradio Kconfig setup. --- app/boards/shields/cradio/Kconfig.defconfig | 17 +++++++++++++++-- app/boards/shields/cradio/Kconfig.shield | 7 +++++-- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'app') diff --git a/app/boards/shields/cradio/Kconfig.defconfig b/app/boards/shields/cradio/Kconfig.defconfig index 43509a4..4d200c9 100644 --- a/app/boards/shields/cradio/Kconfig.defconfig +++ b/app/boards/shields/cradio/Kconfig.defconfig @@ -1,10 +1,23 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT +if SHIELD_CRADIO_LEFT + +config ZMK_KEYBOARD_NAME + default "cradio left" + +endif + +if SHIELD_CRADIO_RIGHT + config ZMK_KEYBOARD_NAME - default "cradio" + default "cradio right" + +endif + +if SHIELD_CRADIO_RIGHT || SHIELD_CRADIO_LEFT config ZMK_KSCAN_DIRECT_POLLING default y - +endif diff --git a/app/boards/shields/cradio/Kconfig.shield b/app/boards/shields/cradio/Kconfig.shield index 71a439e..bb5f073 100644 --- a/app/boards/shields/cradio/Kconfig.shield +++ b/app/boards/shields/cradio/Kconfig.shield @@ -1,5 +1,8 @@ # Copyright (c) 2020 The ZMK Contributors # SPDX-License-Identifier: MIT -config SHIELD_CRADIO - def_bool $(shields_list_contains,cradio) +config SHIELD_CRADIO_LEFT + def_bool $(shields_list_contains,cradio_left) + +config SHIELD_CRADIO_RIGHT + def_bool $(shields_list_contains,cradio_right) -- cgit v1.2.3 From 818f0a1f91020f3315ae09f70ddda6f8362fab98 Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 16 Oct 2020 00:48:53 -0400 Subject: fix(bluetooth): Advertise name + appearance. * Properly put device name and GAP appearance in advertising packets, for proper display in macOS, Android, etc. * Closes #124 --- app/src/ble.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app') diff --git a/app/src/ble.c b/app/src/ble.c index 8cc42bc..ddc92e9 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -54,13 +54,18 @@ enum advertising_type { #define CURR_ADV(adv) (adv << 4) #define ZMK_ADV_CONN_NAME \ - BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME | BT_LE_ADV_OPT_USE_NAME, \ - BT_GAP_ADV_FAST_INT_MIN_2, BT_GAP_ADV_FAST_INT_MAX_2, NULL) + BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE | BT_LE_ADV_OPT_ONE_TIME, BT_GAP_ADV_FAST_INT_MIN_2, \ + BT_GAP_ADV_FAST_INT_MAX_2, NULL) static struct zmk_ble_profile profiles[PROFILE_COUNT]; static u8_t active_profile; +#define DEVICE_NAME CONFIG_BT_DEVICE_NAME +#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) + static const struct bt_data zmk_ble_ad[] = { + BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), + BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03), BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, #if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) -- cgit v1.2.3 From b07475b7d475a592ad974bb36a5580b1c863344f Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 16 Oct 2020 00:56:05 -0400 Subject: fix(bluetooth): Stop adv on connected profile. --- app/src/ble.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'app') diff --git a/app/src/ble.c b/app/src/ble.c index ddc92e9..1b25ca2 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -176,6 +176,10 @@ int update_advertising() { LOG_DBG("advertising from %d to %d", advertising_status, desired_adv); switch (desired_adv + CURR_ADV(advertising_status)) { + case ZMK_ADV_NONE + CURR_ADV(ZMK_ADV_DIR): + case ZMK_ADV_NONE + CURR_ADV(ZMK_ADV_CONN): + CHECKED_ADV_STOP(); + break; case ZMK_ADV_DIR + CURR_ADV(ZMK_ADV_DIR): case ZMK_ADV_DIR + CURR_ADV(ZMK_ADV_CONN): CHECKED_ADV_STOP(); -- cgit v1.2.3 From 9d512eaef01d92b930054d6528279944afe221ce Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Fri, 16 Oct 2020 09:49:28 -0400 Subject: fix(bluetooth): Add adv data in non-peripherals. --- app/src/ble.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'app') diff --git a/app/src/ble.c b/app/src/ble.c index 1b25ca2..9090582 100644 --- a/app/src/ble.c +++ b/app/src/ble.c @@ -64,8 +64,10 @@ static u8_t active_profile; #define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1) static const struct bt_data zmk_ble_ad[] = { +#if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN), BT_DATA_BYTES(BT_DATA_GAP_APPEARANCE, 0xC1, 0x03), +#endif BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)), BT_DATA_BYTES(BT_DATA_UUID16_SOME, #if !IS_ENABLED(CONFIG_ZMK_SPLIT_BLE_ROLE_PERIPHERAL) -- cgit v1.2.3 From 36d3d01a22a46cdc4f1ebcabe27666dec4afface Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Sun, 18 Oct 2020 13:24:37 -0400 Subject: feat(usb): Add proper USB product ID. * Use openmoko product ID from: https://github.com/openmoko/openmoko-usb-oui/pull/15 --- app/Kconfig | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'app') diff --git a/app/Kconfig b/app/Kconfig index fca4912..4cd01eb 100644 --- a/app/Kconfig +++ b/app/Kconfig @@ -9,6 +9,15 @@ config USB_DEVICE_PRODUCT config BT_DEVICE_NAME default ZMK_KEYBOARD_NAME +config USB_DEVICE_VID + default 0x1D50 + +config USB_DEVICE_PID + default 0x615E + +config USB_DEVICE_MANUFACTURER + default "ZMK Project" + config ZMK_KSCAN_EVENT_QUEUE_SIZE int "Size of the event queue for KSCAN events to buffer events" default 4 -- cgit v1.2.3