Merge branch 'main' into settings-reset-bootloader

This commit is contained in:
ReFil 2023-10-19 15:15:40 +01:00
commit ff35335565
177 changed files with 2958 additions and 584 deletions

View file

@ -97,7 +97,27 @@ jobs:
run: west build -s zmk/app -b "${{ matrix.board }}" -- -DZMK_CONFIG="${GITHUB_WORKSPACE}/${{ inputs.config_path }}" ${{ env.extra_cmake_args }} ${{ matrix.cmake-args }}
- name: ${{ env.display_name }} Kconfig file
run: grep -v -e "^#" -e "^$" build/zephyr/.config | sort
run: |
if [ -f build/zephyr/.config ]
then
grep -v -e "^#" -e "^$" build/zephyr/.config | sort
else
echo "No Kconfig output"
fi
if: ${{ !cancelled() }}
- name: ${{ env.display_name }} Devicetree file
run: |
if [ -f build/zephyr/zephyr.dts ]
then
cat build/zephyr/zephyr.dts
elif [ -f build/zephyr/zephyr.dts.pre ]
then
cat -s build/zephyr/zephyr.dts.pre
else
echo "No Devicetree output"
fi
if: ${{ !cancelled() }}
- name: Rename artifacts
shell: sh -x {0}

View file

@ -59,7 +59,7 @@ if ((NOT CONFIG_ZMK_SPLIT) OR CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
target_sources(app PRIVATE src/behavior_queue.c)
target_sources(app PRIVATE src/conditional_layer.c)
target_sources(app PRIVATE src/endpoints.c)
target_sources(app PRIVATE src/events/endpoint_selection_changed.c)
target_sources(app PRIVATE src/events/endpoint_changed.c)
target_sources(app PRIVATE src/hid_listener.c)
target_sources(app PRIVATE src/keymap.c)
target_sources(app PRIVATE src/events/layer_state_changed.c)

View file

@ -14,9 +14,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/display.h>
#include "output_status.h"
#include <zmk/event_manager.h>
#include <zmk/events/usb_conn_state_changed.h>
#include <zmk/events/ble_active_profile_changed.h>
#include <zmk/events/endpoint_selection_changed.h>
#include <zmk/events/endpoint_changed.h>
#include <zmk/usb.h>
#include <zmk/ble.h>
#include <zmk/endpoints.h>
@ -39,31 +38,29 @@ LV_IMG_DECLARE(USB_connected);
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
struct output_status_state {
enum zmk_endpoint selected_endpoint;
struct zmk_endpoint_instance selected_endpoint;
bool active_profile_connected;
bool active_profile_bonded;
uint8_t active_profile_index;
};
static struct output_status_state get_state(const zmk_event_t *_eh) {
return (struct output_status_state){.selected_endpoint = zmk_endpoints_selected(),
.active_profile_connected =
zmk_ble_active_profile_is_connected(),
.active_profile_bonded = !zmk_ble_active_profile_is_open(),
.active_profile_index = zmk_ble_active_profile_index()};
;
return (struct output_status_state){
.selected_endpoint = zmk_endpoints_selected(),
.active_profile_connected = zmk_ble_active_profile_is_connected(),
.active_profile_bonded = !zmk_ble_active_profile_is_open(),
};
}
static void set_status_symbol(lv_obj_t *icon, struct output_status_state state) {
switch (state.selected_endpoint) {
case ZMK_ENDPOINT_USB:
switch (state.selected_endpoint.transport) {
case ZMK_TRANSPORT_USB:
lv_img_set_src(icon, &USB_connected);
break;
case ZMK_ENDPOINT_BLE:
case ZMK_TRANSPORT_BLE:
if (state.active_profile_bonded) {
if (state.active_profile_connected) {
// sprintf(text, LV_SYMBOL_BLUETOOTH "%i " LV_SYMBOL_OK, active_profile_index);
switch (state.active_profile_index) {
switch (state.selected_endpoint.ble.profile_index) {
case 0:
lv_img_set_src(icon, &bluetooth_connected_1);
break;
@ -84,7 +81,7 @@ static void set_status_symbol(lv_obj_t *icon, struct output_status_state state)
lv_img_set_src(icon, &bluetooth_disconnected_right);
}
} else {
switch (state.active_profile_index) {
switch (state.selected_endpoint.ble.profile_index) {
case 0:
lv_img_set_src(icon, &bluetooth_advertising_1);
break;
@ -113,11 +110,9 @@ static void output_status_update_cb(struct output_status_state state) {
ZMK_DISPLAY_WIDGET_LISTENER(widget_output_status, struct output_status_state,
output_status_update_cb, get_state)
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_selection_changed);
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
ZMK_SUBSCRIPTION(widget_output_status, zmk_usb_conn_state_changed);
#endif
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_changed);
// We don't get an endpoint changed event when the active profile connects/disconnects
// but there wasn't another endpoint to switch from/to, so update on BLE events too.
#if defined(CONFIG_ZMK_BLE)
ZMK_SUBSCRIPTION(widget_output_status, zmk_ble_active_profile_changed);
#endif

View file

@ -18,7 +18,7 @@
flavor = "tap-preferred";
tapping-term-ms = <220>;
quick-tap-ms = <150>;
global-quick-tap;
require-prior-idle-ms = <100>;
bindings = <&kp>, <&kp>;
};
};

View file

@ -48,7 +48,8 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(3,4) RC(3,5) RC(2,5) RC(2,6) RC(2,7)
label = "LEFT_ENCODER";
a-gpios = <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
steps = <120>;
status = "disabled";
steps = <60>;
};
right_encoder: right_encoder {
@ -56,7 +57,8 @@ RC(2,0) RC(2,1) RC(2,2) RC(2,3) RC(2,4) RC(3,4) RC(3,5) RC(2,5) RC(2,6) RC(2,7)
label = "RIGHT_ENCODER";
a-gpios = <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
steps = <120>;
status = "disabled";
steps = <60>;
};
sensors {

View file

@ -1,7 +1,7 @@
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_MICRODOX_LEFT
if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_V2_LEFT
config ZMK_KEYBOARD_NAME
default "Microdox"
@ -11,7 +11,7 @@ config ZMK_SPLIT_ROLE_CENTRAL
endif
if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT
if SHIELD_MICRODOX_LEFT || SHIELD_MICRODOX_RIGHT || SHIELD_MICRODOX_V2_LEFT || SHIELD_MICRODOX_V2_RIGHT
config ZMK_SPLIT
default y

View file

@ -6,3 +6,9 @@ config SHIELD_MICRODOX_LEFT
config SHIELD_MICRODOX_RIGHT
def_bool $(shields_list_contains,microdox_right)
config SHIELD_MICRODOX_V2_LEFT
def_bool $(shields_list_contains,microdox_v2_left)
config SHIELD_MICRODOX_V2_RIGHT
def_bool $(shields_list_contains,microdox_v2_right)

View file

@ -0,0 +1,8 @@
# Microdox
Microdox is a 36 key split keyboard by Boardsource.
Two variants are defined for this shield V1 and V2. The layout is exactly the same between the
two. Per [help documentation](https://www.boardsource.xyz/help/6129be4a9c85c6050be190d2), if you
purchased your PCB before April 2022, use `microdox_left`/`microdox_right`. Otherwise, use
`microdox_v2_left`/`microdox_v2_right`.

View file

@ -4,35 +4,12 @@
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>
#include "microdox_common.dtsi"
/ {
chosen {
zephyr,display = &oled;
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 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
@ -40,26 +17,5 @@ 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)
, <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
// 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>;
com-sequential;
prechargep = <0x22>;
};
};

View file

@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>
/ {
chosen {
zephyr,display = &oled;
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)
>;
};
// 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>;
com-sequential;
prechargep = <0x22>;
};
};

View file

@ -0,0 +1,6 @@
# Uncomment the following lines to enable the Microdox RGB Underglow
# CONFIG_ZMK_RGB_UNDERGLOW=y
# CONFIG_WS2812_STRIP=y
# Uncomment the following line to enable the Microdox OLED Display
# CONFIG_ZMK_DISPLAY=y

View file

@ -0,0 +1,15 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include "microdox_common.dtsi"
/ {
kscan0: kscan {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
};
};

View file

@ -0,0 +1,13 @@
file_format: "1"
id: microdox_v2
name: Microdox V2
type: shield
url: https://boardsource.xyz/store/5f2e7e4a2902de7151494f92
requires: [pro_micro]
exposes: [i2c_oled]
features:
- keys
- display
siblings:
- microdox_v2_left
- microdox_v2_right

View file

@ -0,0 +1,23 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include "microdox_v2.dtsi"
&kscan0 {
col-gpios
= <&pro_micro 4 GPIO_ACTIVE_HIGH>
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
, <&pro_micro 14 GPIO_ACTIVE_HIGH>
, <&pro_micro 18 GPIO_ACTIVE_HIGH>
, <&pro_micro 19 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 0 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 15 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};

View file

@ -0,0 +1,32 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include "microdox.dtsi"
&default_transform {
col-offset = <5>;
};
&oled {
segment-remap;
com-invdir;
};
&kscan0 {
col-gpios
= <&pro_micro 14 GPIO_ACTIVE_HIGH>
, <&pro_micro 5 GPIO_ACTIVE_HIGH>
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
, <&pro_micro 15 GPIO_ACTIVE_HIGH>
, <&pro_micro 21 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 18 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};

View file

@ -31,7 +31,7 @@ struct peripheral_status_state {
bool connected;
};
static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state state) {
static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], const struct status_state *state) {
lv_obj_t *canvas = lv_obj_get_child(widget, 0);
lv_draw_label_dsc_t label_dsc;
@ -47,7 +47,7 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state st
// Draw output status
lv_canvas_draw_text(canvas, 0, 0, CANVAS_SIZE, &label_dsc,
state.connected ? LV_SYMBOL_WIFI : LV_SYMBOL_CLOSE);
state->connected ? LV_SYMBOL_WIFI : LV_SYMBOL_CLOSE);
// Rotate canvas
rotate_canvas(canvas, cbuf);
@ -61,7 +61,7 @@ static void set_battery_status(struct zmk_widget_status *widget,
widget->state.battery = state.level;
draw_top(widget->obj, widget->cbuf, widget->state);
draw_top(widget->obj, widget->cbuf, &widget->state);
}
static void battery_status_update_cb(struct battery_status_state state) {
@ -94,7 +94,7 @@ static void set_connection_status(struct zmk_widget_status *widget,
struct peripheral_status_state state) {
widget->state.connected = state.connected;
draw_top(widget->obj, widget->cbuf, widget->state);
draw_top(widget->obj, widget->cbuf, &widget->state);
}
static void output_status_update_cb(struct peripheral_status_state state) {

View file

@ -17,7 +17,7 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/event_manager.h>
#include <zmk/events/battery_state_changed.h>
#include <zmk/events/ble_active_profile_changed.h>
#include <zmk/events/endpoint_selection_changed.h>
#include <zmk/events/endpoint_changed.h>
#include <zmk/events/wpm_state_changed.h>
#include <zmk/events/layer_state_changed.h>
#include <zmk/usb.h>
@ -29,10 +29,10 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
struct output_status_state {
enum zmk_endpoint selected_endpoint;
struct zmk_endpoint_instance selected_endpoint;
int active_profile_index;
bool active_profile_connected;
bool active_profile_bonded;
uint8_t active_profile_index;
};
struct layer_status_state {
@ -44,7 +44,7 @@ struct wpm_status_state {
uint8_t wpm;
};
static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state state) {
static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], const struct status_state *state) {
lv_obj_t *canvas = lv_obj_get_child(widget, 0);
lv_draw_label_dsc_t label_dsc;
@ -67,13 +67,13 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state st
// Draw output status
char output_text[10] = {};
switch (state.selected_endpoint) {
case ZMK_ENDPOINT_USB:
switch (state->selected_endpoint.transport) {
case ZMK_TRANSPORT_USB:
strcat(output_text, LV_SYMBOL_USB);
break;
case ZMK_ENDPOINT_BLE:
if (state.active_profile_bonded) {
if (state.active_profile_connected) {
case ZMK_TRANSPORT_BLE:
if (state->active_profile_bonded) {
if (state->active_profile_connected) {
strcat(output_text, LV_SYMBOL_WIFI);
} else {
strcat(output_text, LV_SYMBOL_CLOSE);
@ -91,18 +91,18 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state st
lv_canvas_draw_rect(canvas, 1, 22, 66, 40, &rect_black_dsc);
char wpm_text[6] = {};
snprintf(wpm_text, sizeof(wpm_text), "%d", state.wpm[9]);
snprintf(wpm_text, sizeof(wpm_text), "%d", state->wpm[9]);
lv_canvas_draw_text(canvas, 42, 52, 24, &label_dsc_wpm, wpm_text);
int max = 0;
int min = 256;
for (int i = 0; i < 10; i++) {
if (state.wpm[i] > max) {
max = state.wpm[i];
if (state->wpm[i] > max) {
max = state->wpm[i];
}
if (state.wpm[i] < min) {
min = state.wpm[i];
if (state->wpm[i] < min) {
min = state->wpm[i];
}
}
@ -114,7 +114,7 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state st
lv_point_t points[10];
for (int i = 0; i < 10; i++) {
points[i].x = 2 + i * 7;
points[i].y = 60 - (state.wpm[i] - min) * 36 / range;
points[i].y = 60 - (state->wpm[i] - min) * 36 / range;
}
lv_canvas_draw_line(canvas, points, 10, &line_dsc);
@ -122,7 +122,7 @@ static void draw_top(lv_obj_t *widget, lv_color_t cbuf[], struct status_state st
rotate_canvas(canvas, cbuf);
}
static void draw_middle(lv_obj_t *widget, lv_color_t cbuf[], struct status_state state) {
static void draw_middle(lv_obj_t *widget, lv_color_t cbuf[], const struct status_state *state) {
lv_obj_t *canvas = lv_obj_get_child(widget, 1);
lv_draw_rect_dsc_t rect_black_dsc;
@ -147,7 +147,7 @@ static void draw_middle(lv_obj_t *widget, lv_color_t cbuf[], struct status_state
};
for (int i = 0; i < 5; i++) {
bool selected = state.active_profile_index == i;
bool selected = i == state->active_profile_index;
lv_canvas_draw_arc(canvas, circle_offsets[i][0], circle_offsets[i][1], 13, 0, 359,
&arc_dsc);
@ -167,7 +167,7 @@ static void draw_middle(lv_obj_t *widget, lv_color_t cbuf[], struct status_state
rotate_canvas(canvas, cbuf);
}
static void draw_bottom(lv_obj_t *widget, lv_color_t cbuf[], struct status_state state) {
static void draw_bottom(lv_obj_t *widget, lv_color_t cbuf[], const struct status_state *state) {
lv_obj_t *canvas = lv_obj_get_child(widget, 2);
lv_draw_rect_dsc_t rect_black_dsc;
@ -179,14 +179,14 @@ static void draw_bottom(lv_obj_t *widget, lv_color_t cbuf[], struct status_state
lv_canvas_draw_rect(canvas, 0, 0, CANVAS_SIZE, CANVAS_SIZE, &rect_black_dsc);
// Draw layer
if (state.layer_label == NULL) {
if (state->layer_label == NULL) {
char text[9] = {};
sprintf(text, "LAYER %i", state.layer_index);
sprintf(text, "LAYER %i", state->layer_index);
lv_canvas_draw_text(canvas, 0, 5, 68, &label_dsc, text);
} else {
lv_canvas_draw_text(canvas, 0, 5, 68, &label_dsc, state.layer_label);
lv_canvas_draw_text(canvas, 0, 5, 68, &label_dsc, state->layer_label);
}
// Rotate canvas
@ -201,7 +201,7 @@ static void set_battery_status(struct zmk_widget_status *widget,
widget->state.battery = state.level;
draw_top(widget->obj, widget->cbuf, widget->state);
draw_top(widget->obj, widget->cbuf, &widget->state);
}
static void battery_status_update_cb(struct battery_status_state state) {
@ -226,33 +226,34 @@ ZMK_SUBSCRIPTION(widget_battery_status, zmk_battery_state_changed);
ZMK_SUBSCRIPTION(widget_battery_status, zmk_usb_conn_state_changed);
#endif /* IS_ENABLED(CONFIG_USB_DEVICE_STACK) */
static void set_output_status(struct zmk_widget_status *widget, struct output_status_state state) {
widget->state.selected_endpoint = state.selected_endpoint;
widget->state.active_profile_connected = state.active_profile_connected;
widget->state.active_profile_bonded = state.active_profile_bonded;
widget->state.active_profile_index = state.active_profile_index;
static void set_output_status(struct zmk_widget_status *widget,
const struct output_status_state *state) {
widget->state.selected_endpoint = state->selected_endpoint;
widget->state.active_profile_index = state->active_profile_index;
widget->state.active_profile_connected = state->active_profile_connected;
widget->state.active_profile_bonded = state->active_profile_bonded;
draw_top(widget->obj, widget->cbuf, widget->state);
draw_middle(widget->obj, widget->cbuf2, widget->state);
draw_top(widget->obj, widget->cbuf, &widget->state);
draw_middle(widget->obj, widget->cbuf2, &widget->state);
}
static void output_status_update_cb(struct output_status_state state) {
struct zmk_widget_status *widget;
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_output_status(widget, state); }
SYS_SLIST_FOR_EACH_CONTAINER(&widgets, widget, node) { set_output_status(widget, &state); }
}
static struct output_status_state output_status_get_state(const zmk_event_t *_eh) {
return (struct output_status_state){.selected_endpoint = zmk_endpoints_selected(),
.active_profile_connected =
zmk_ble_active_profile_is_connected(),
.active_profile_bonded = !zmk_ble_active_profile_is_open(),
.active_profile_index = zmk_ble_active_profile_index()};
;
return (struct output_status_state){
.selected_endpoint = zmk_endpoints_selected(),
.active_profile_index = zmk_ble_active_profile_index(),
.active_profile_connected = zmk_ble_active_profile_is_connected(),
.active_profile_bonded = !zmk_ble_active_profile_is_open(),
};
}
ZMK_DISPLAY_WIDGET_LISTENER(widget_output_status, struct output_status_state,
output_status_update_cb, output_status_get_state)
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_selection_changed);
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_changed);
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
ZMK_SUBSCRIPTION(widget_output_status, zmk_usb_conn_state_changed);
@ -265,7 +266,7 @@ static void set_layer_status(struct zmk_widget_status *widget, struct layer_stat
widget->state.layer_index = state.index;
widget->state.layer_label = state.label;
draw_bottom(widget->obj, widget->cbuf3, widget->state);
draw_bottom(widget->obj, widget->cbuf3, &widget->state);
}
static void layer_status_update_cb(struct layer_status_state state) {
@ -289,7 +290,7 @@ static void set_wpm_status(struct zmk_widget_status *widget, struct wpm_status_s
}
widget->state.wpm[9] = state.wpm;
draw_top(widget->obj, widget->cbuf, widget->state);
draw_top(widget->obj, widget->cbuf, &widget->state);
}
static void wpm_status_update_cb(struct wpm_status_state state) {

View file

@ -24,7 +24,7 @@ void rotate_canvas(lv_obj_t *canvas, lv_color_t cbuf[]) {
CANVAS_SIZE / 2, true);
}
void draw_battery(lv_obj_t *canvas, struct status_state state) {
void draw_battery(lv_obj_t *canvas, const struct status_state *state) {
lv_draw_rect_dsc_t rect_black_dsc;
init_rect_dsc(&rect_black_dsc, LVGL_BACKGROUND);
lv_draw_rect_dsc_t rect_white_dsc;
@ -32,11 +32,11 @@ void draw_battery(lv_obj_t *canvas, struct status_state state) {
lv_canvas_draw_rect(canvas, 0, 2, 29, 12, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 1, 3, 27, 10, &rect_black_dsc);
lv_canvas_draw_rect(canvas, 2, 4, (state.battery + 2) / 4, 8, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 2, 4, (state->battery + 2) / 4, 8, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 30, 5, 3, 6, &rect_white_dsc);
lv_canvas_draw_rect(canvas, 31, 6, 1, 4, &rect_black_dsc);
if (state.charging) {
if (state->charging) {
lv_draw_img_dsc_t img_dsc;
lv_draw_img_dsc_init(&img_dsc);
lv_canvas_draw_img(canvas, 9, -1, &bolt, &img_dsc);

View file

@ -19,10 +19,10 @@ struct status_state {
uint8_t battery;
bool charging;
#if !IS_ENABLED(CONFIG_ZMK_SPLIT) || IS_ENABLED(CONFIG_ZMK_SPLIT_ROLE_CENTRAL)
enum zmk_endpoint selected_endpoint;
struct zmk_endpoint_instance selected_endpoint;
int active_profile_index;
bool active_profile_connected;
bool active_profile_bonded;
uint8_t active_profile_index;
uint8_t layer_index;
const char *layer_label;
uint8_t wpm[10];
@ -39,7 +39,7 @@ struct battery_status_state {
};
void rotate_canvas(lv_obj_t *canvas, lv_color_t cbuf[]);
void draw_battery(lv_obj_t *canvas, struct status_state state);
void draw_battery(lv_obj_t *canvas, const struct status_state *state);
void init_label_dsc(lv_draw_label_dsc_t *label_dsc, lv_color_t color, const lv_font_t *font,
lv_text_align_t align);
void init_rect_dsc(lv_draw_rect_dsc_t *rect_dsc, lv_color_t bg_color);

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_REVIUNG34
config ZMK_KEYBOARD_NAME
default "REVIUNG34"
endif

View file

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

View file

@ -0,0 +1,13 @@
# REVIUNG34
REVIUNG34 is a 33-34 key unibody split keyboard by [gtips](https://github.com/gtips). An in-stock version can be found at [Little Keyboards](https://www.littlekeyboards.com/products/reviung34-analyst-keyboard-kit).
By default, the 2x1u layout is used. To use to the 1x2u layout, add the following to your keymap:
```
/ {
chosen {
zmk,matrix_transform = &single_2u_transform;
};
};
```

View file

@ -0,0 +1,48 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <9>; /* number of LEDs */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,3 @@
# Uncomment the following lines to enable RGB underglow
# CONFIG_ZMK_RGB_UNDERGLOW=y
# CONFIG_WS2812_STRIP=y

View file

@ -0,0 +1,77 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/rgb.h>
/ {
chosen {
// 34 keys.
zmk,matrix_transform = &dual_1u_transform;
// 33 keys. Center two thumb keys replaced by a single 2u key. Remember to adjust your
// keymap accordingly!
// zmk,matrix_transform = &single_2u_transform;
};
};
/ {
keymap {
compatible = "zmk,keymap";
base {
label = "Base";
bindings = <
&kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P
&kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI
&mt LSHFT Z &mt LCTRL X &mt LALT C &kp V &kp B &kp N &kp M &mt RALT COMMA &mt RCTRL DOT &mt RSHFT SLASH
&kp LGUI &lt 1 BSPC &lt 2 SPACE &mo 3
>;
};
lower {
label = "Lower";
bindings = <
&kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR
&trans &kp TILDE &kp DQT &kp PIPE &trans &trans &kp UNDER &kp PLUS &kp LBRC &kp RBRC
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &mo 4 &trans
>;
};
upper {
label = "Upper";
bindings = <
&kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0
&trans &kp GRAVE &kp SQT &kp BSLH &trans &trans &kp MINUS &kp EQUAL &kp LBKT &kp RBKT
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &mo 4 &trans &trans
>;
};
function {
label = "Function";
bindings = <
&kp TAB &trans &kp C_VOL_UP &trans &trans &trans &trans &trans &trans &kp ENTER
&kp ESC &kp C_BRI_DN &kp C_VOL_DN &kp C_BRI_UP &trans &trans &kp LEFT &kp DOWN &kp UP &kp RIGHT
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &kp C_PWR &trans &trans
>;
};
meta {
label = "Meta";
bindings = <
&rgb_ug RGB_HUI &rgb_ug RGB_SAI &rgb_ug RGB_BRI &rgb_ug RGB_SPI &rgb_ug RGB_EFF &none &none &none &none &none
&rgb_ug RGB_HUD &rgb_ug RGB_SAD &rgb_ug RGB_BRD &rgb_ug RGB_SPD &rgb_ug RGB_EFR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4
&none &none &rgb_ug RGB_TOG &none &none &none &none &bt BT_CLR &none &none
&none &trans &trans &none
>;
};
};
};

View file

@ -0,0 +1,63 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &dual_1u_transform;
};
dual_1u_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <9>;
rows = <4>;
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(3,5)
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(3,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(3,7)
RC(3,2) RC(3,3) RC(3,4) RC(3,8)
>;
};
single_2u_transform: keymap_transform_1 {
compatible = "zmk,matrix-transform";
columns = <9>;
rows = <4>;
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(3,5)
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(3,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(3,7)
RC(3,2) RC(3,4) RC(3,8)
>;
};
kscan0: kscan_0 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
col-gpios
= <&pro_micro 4 GPIO_ACTIVE_HIGH>
, <&pro_micro 5 GPIO_ACTIVE_HIGH>
, <&pro_micro 6 GPIO_ACTIVE_HIGH>
, <&pro_micro 7 GPIO_ACTIVE_HIGH>
, <&pro_micro 8 GPIO_ACTIVE_HIGH>
, <&pro_micro 15 GPIO_ACTIVE_HIGH>
, <&pro_micro 14 GPIO_ACTIVE_HIGH>
, <&pro_micro 16 GPIO_ACTIVE_HIGH>
, <&pro_micro 10 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&pro_micro 21 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 20 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 19 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 18 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
};

View file

@ -0,0 +1,9 @@
file_format: "1"
id: reviung34
name: REVIUNG34
type: shield
url: https://github.com/gtips/reviung/tree/master/reviung34
requires: [pro_micro]
features:
- keys
- underglow

View file

@ -0,0 +1,9 @@
# Copyright (c) 2023 The ZMK Contributors
# SPDX-License-Identifier: MIT
if SHIELD_REVIUNG53
config ZMK_KEYBOARD_NAME
default "Reviung53"
endif

View file

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

View file

@ -0,0 +1,47 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <10>;
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,47 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <10>;
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <LED_COLOR_ID_GREEN LED_COLOR_ID_RED LED_COLOR_ID_BLUE>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,3 @@
# Uncomment the following lines to enable RGB underglow
# CONFIG_ZMK_RGB_UNDERGLOW=y
# CONFIG_WS2812_STRIP=y

View file

@ -0,0 +1,109 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/rgb.h>
/ {
conditional_layers {
compatible = "zmk,conditional-layers";
tri_layer {
if-layers = <1 2>;
then-layer = <3>;
};
};
keymap {
compatible = "zmk,keymap";
default_layer {
// ----------------------------------------------------------------------------------------
// | | | ESC | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | DEL |
// | TAB | Q | W | E | R | T | Y | U | I | O | P | BKSP |
// | CAPS | A | S | D | F | G | H | J | K | L | ; | RET |
// | SHFT | Z | X | C | V | B | N | M | , | . | SHFT(/) |
// | CTRL | GUI | ALT | LOWER(SPACE) | RAISE(SPACE)| ALT | GUI | CTRL(\) |
// |
bindings = <
&kp ESC &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp DEL
&kp TAB &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC
&kp CAPS &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp RET
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp N &kp M &kp COMMA &kp DOT &mt RSHFT FSLH
&kp LCTRL &kp LCMD &kp LALT &lt 1 SPACE &lt 2 SPACE &kp RALT &kp RCMD &mt RCTRL BSLH
>;
};
lower_layer {
// --------------------------------------------------------------------------------------------
// | | | | F9 | F10 | F11 | F12 | INS | PAU | SCR | PSCR | |
// | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | |
// | NAV | | | | | | | _ | + | { | } | " |
// | | | | | | | | | | | ? |
// | | | | | | | | | |
// |
bindings = <
&trans &kp F9 &kp F10 &kp F11 &kp F12 &kp INS &kp PAUSE_BREAK &kp SLCK &kp PSCRN &trans
&kp TILDE &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp ASTRK &kp LPAR &kp RPAR &trans
&mo 4 &none &none &none &none &none &none &kp UNDER &kp PLUS &kp LBRC &kp RBRC &kp DQT
&trans &none &none &none &none &none &none &none &none &none &kp QMARK
&trans &trans &trans &trans &trans &trans &trans &kp PIPE
>;
};
raise_layer {
// --------------------------------------------------------------------------------------
// | | | | F9 | F10 | F11 | F12 | MUTE | VOL+ | VOL- | PLAY | |
// | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | |
// | NAV | | | | | | | - | = | [ | ] | ' |
// | | | | | | | | + | < | > | : |
// | | | | | | | | | |
// |
bindings = <
&trans &kp F9 &kp F10 &kp F11 &kp F12 &kp C_MUTE &kp C_VOL_UP &kp C_VOL_DN &kp C_PLAY &trans
&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &trans
&mo 4 &none &none &none &none &none &none &kp MINUS &kp EQUAL &kp LBKT &kp RBKT &kp SQT
&trans &none &none &none &none &none &none &kp PLUS &kp LT &kp GT &kp COLON
&trans &trans &trans &trans &trans &trans &trans &kp PIPE
>;
};
adjust_layer {
// ------------------------------------------------------------------------------------------------------------------------
// | | | BT CLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | BT CLR |
// | RGB BRI+ | RGB SAT+ | RGB HUE+ | RGB ANI+ | | RGB TOG | | | | | | |
// | RGB BRI- | RGB SAT- | RGB HUE- | RGB ANI- | | | | | | | | |
// | | | | | | | BOOT | | | | |
// | | | | | | | | |
// |
bindings = <
&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none &none &none &bt BT_CLR
&rgb_ug RGB_BRI &rgb_ug RGB_SAI &rgb_ug RGB_HUI &rgb_ug RGB_EFF &none &rgb_ug RGB_TOG &none &none &none &none &none &none
&rgb_ug RGB_BRD &rgb_ug RGB_SAD &rgb_ug RGB_HUD &rgb_ug RGB_EFR &none &none &none &none &none &none &none &none
&trans &none &none &none &none &none &bootloader &none &none &none &none
&trans &trans &trans &trans &trans &none &none &none
>;
};
nav_layer {
// ------------------------------------------------------------------------------------------------------------------------
// | | | ESC | | | | | | | | | DEL |
// | TAB | | UP | | | | | | | | | BSPC |
// | NAV | LEFT | DOWN | RIGHT | | | LEFT | DOWN | UP | RIGHT | | ENTER |
// | SHIFT | | | | | | HOME | END | PGUP | PGDN | SHIFT |
// | CTRL | GUI | ALT | SPACE | SPACE | ALT | GUI | CTRL |
// |
bindings = <
&kp ESC &none &none &none &none &none &none &none &none &kp DEL
&kp TAB &none &kp UP &none &none &none &none &none &none &none &none &kp BSPC
&trans &kp LEFT &kp DOWN &kp RIGHT &none &none &kp LEFT &kp DOWN &kp UP &kp RIGHT &none &kp RET
&kp LSHFT &none &none &none &none &none &kp HOME &kp END &kp PG_UP &kp PG_DN &kp RSHFT
&kp LCTRL &kp LCMD &kp LALT &kp SPACE &kp SPACE &kp LALT &kp RCMD &kp RCTRL
>;
};
};
};

View file

@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#include <dt-bindings/zmk/matrix_transform.h>
/ {
chosen {
zmk,kscan = &kscan0;
zmk,matrix_transform = &default_transform;
};
default_transform: keymap_transform_0 {
compatible = "zmk,matrix-transform";
columns = <8>;
rows = <7>;
map = <
RC(0,2) RC(0,3) RC(0,4) RC(0,5) RC(0,6) RC(0,7) RC(4,0) RC(4,1) RC(4,2) RC(4,3)
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(4,4) RC(4,5) RC(4,6) RC(4,7)
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(5,0) RC(5,1) RC(5,2) RC(5,3)
RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5) RC(3,6) RC(3,7) RC(5,4) RC(5,5) RC(5,6)
RC(6,0) RC(6,1) RC(6,2) RC(6,3) RC(6,4) RC(6,5) RC(6,6) RC(6,7)
>;
};
kscan0: kscan_0 {
compatible = "zmk,kscan-gpio-matrix";
label = "KSCAN";
diode-direction = "col2row";
col-gpios
= <&pro_micro 21 GPIO_ACTIVE_HIGH>
, <&pro_micro 20 GPIO_ACTIVE_HIGH>
, <&pro_micro 19 GPIO_ACTIVE_HIGH>
, <&pro_micro 18 GPIO_ACTIVE_HIGH>
, <&pro_micro 15 GPIO_ACTIVE_HIGH>
, <&pro_micro 14 GPIO_ACTIVE_HIGH>
, <&pro_micro 16 GPIO_ACTIVE_HIGH>
, <&pro_micro 10 GPIO_ACTIVE_HIGH>
;
row-gpios
= <&pro_micro 3 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 4 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 5 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
};

View file

@ -0,0 +1,9 @@
file_format: "1"
id: reviung53
name: REVIUNG53
type: shield
url: https://github.com/gtips/reviung/tree/master/reviung53
requires: [pro_micro]
features:
- keys
- underglow

View file

@ -46,4 +46,10 @@ endchoice
endif # LVGL
if ZMK_RGB_UNDERGLOW
config WS2812_STRIP
default y
endif
endif

View file

@ -0,0 +1,51 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <36>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <
LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE
>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,51 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <36>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <
LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE
>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,51 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <36>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <
LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE
>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -0,0 +1,51 @@
#include <dt-bindings/led/led.h>
&pinctrl {
spi3_default: spi3_default {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
};
};
spi3_sleep: spi3_sleep {
group1 {
psels = <NRF_PSEL(SPIM_MOSI, 0, 6)>;
low-power-enable;
};
};
};
&spi3 {
compatible = "nordic,nrf-spim";
status = "okay";
pinctrl-0 = <&spi3_default>;
pinctrl-1 = <&spi3_sleep>;
pinctrl-names = "default", "sleep";
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";
label = "WS2812";
/* SPI */
reg = <0>; /* ignored, but necessary for SPI bindings */
spi-max-frequency = <4000000>;
/* WS2812 */
chain-length = <36>; /* arbitrary; change at will */
spi-one-frame = <0x70>;
spi-zero-frame = <0x40>;
color-mapping = <
LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE
>;
};
};
/ {
chosen {
zmk,underglow = &led_strip;
};
};

View file

@ -7,3 +7,11 @@
# Uncomment these two lines to add support for encoders
# CONFIG_EC11=y
# CONFIG_EC11_TRIGGER_GLOBAL_THREAD=y
# Uncomment this line below to add rgb underglow / backlight support
# CONFIG_ZMK_RGB_UNDERGLOW=y
# Uncomment the line below to disable external power toggling by the underglow.
# By default toggling the underglow on and off also toggles external power
# on and off. This also causes the display to turn off.
# CONFIG_ZMK_RGB_UNDERGLOW_EXT_POWER=n

View file

@ -7,34 +7,53 @@
#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/rgb.h>
#include <dt-bindings/zmk/ext_power.h>
#define BASE 0
#define LOWER 1
#define RAISE 2
#define ADJUST 3
/ {
// Activate ADJUST layer by pressing raise and lower
conditional_layers {
compatible = "zmk,conditional-layers";
adjust_layer {
if-layers = <LOWER RAISE>;
then-layer = <ADJUST>;
};
};
keymap {
compatible = "zmk,keymap";
default_layer {
label = "default";
// ------------------------------------------------------------------------------------------------------------
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | |
// | ESC | Q | W | E | R | T | | Y | U | I | O | P | BKSPC |
// | TAB | A | S | D | F | G | | H | J | K | L | ; | ' |
// | SHIFT | Z | X | C | V | B | MUTE | | | N | M | , | . | / | SHIFT |
// | GUI | ALT | CTRL | LOWER| ENTER | | SPACE | RAISE| CTRL | ALT | GUI |
bindings = <
&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &none
&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC
&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp C_MUTE &none &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT
&kp LGUI &kp LALT &kp LCTRL &mo 1 &kp RET &kp SPACE &mo 2 &kp RCTRL &kp RALT &kp RGUI
&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &none
&kp ESC &kp Q &kp W &kp E &kp R &kp T &kp Y &kp U &kp I &kp O &kp P &kp BSPC
&kp TAB &kp A &kp S &kp D &kp F &kp G &kp H &kp J &kp K &kp L &kp SEMI &kp SQT
&kp LSHFT &kp Z &kp X &kp C &kp V &kp B &kp C_MUTE &none &kp N &kp M &kp COMMA &kp DOT &kp FSLH &kp RSHFT
&kp LGUI &kp LALT &kp LCTRL &mo LOWER &kp RET &kp SPACE &mo RAISE &kp RCTRL &kp RALT &kp RGUI
>;
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>;
};
lower_layer {
label = "lower";
// TODO: Some binds are waiting for shifted keycode support.
// ------------------------------------------------------------------------------------------------------------
// | | F1 | F2 | F3 | F4 | F5 | | F6 | F7 | F8 | F9 | F10 | F11 |
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 |
// | ` | 1 | 2 | 3 | 4 | 5 | | 6 | 7 | 8 | 9 | 0 | F12 |
// | | ! | @ | # | $ | % | | ^ | & | * | ( | ) | | |
// | | = | - | + | { | } | | | | [ | ] | ; | : | \ | |
// | | | | | | | | | | | |
@ -42,29 +61,48 @@
&trans &kp F1 &kp F2 &kp F3 &kp F4 &kp F5 &kp F6 &kp F7 &kp F8 &kp F9 &kp F10 &kp F11
&kp GRAVE &kp N1 &kp N2 &kp N3 &kp N4 &kp N5 &kp N6 &kp N7 &kp N8 &kp N9 &kp N0 &kp F12
&trans &kp EXCL &kp AT &kp HASH &kp DLLR &kp PRCNT &kp CARET &kp AMPS &kp KP_MULTIPLY &kp LPAR &kp RPAR &kp PIPE
&trans &kp EQUAL &kp MINUS &kp KP_PLUS &kp LBRC &kp RBRC &trans &trans &kp LBKT &kp RBKT &kp SEMI &kp COLON &kp BSLH &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &kp EQUAL &kp MINUS &kp KP_PLUS &kp LBRC &kp RBRC &trans &trans &kp LBKT &kp RBKT &kp SEMI &kp COLON &kp BSLH &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>;
};
raise_layer {
label = "raise";
// ------------------------------------------------------------------------------------------------------------
// |BTCLR| BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | |
// | | ALT | CTRL | SHIFT | | CAPS | | PGDN | <- | v | -> | DEL | BKSPC |
// | | UNDO | CUT | COPY | PASTE | | | | | | | | | | |
// | | | | | | | | | | | |
// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | | INS | PSCR | GUI | | | | PGUP | | ^ | | | |
// | | ALT | CTRL | SHIFT | | CAPS | | PGDN | <- | v | -> | DEL | BKSPC |
// | | UNDO | CUT | COPY | PASTE | | | | | | | | | | |
// | | | | | | | | | | | |
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
&trans &kp INS &kp PSCRN &kp K_CMENU &trans &trans &kp PG_UP &trans &kp UP &trans &kp N0 &trans
&trans &kp LALT &kp LCTRL &kp LSHFT &trans &kp CLCK &kp PG_DN &kp LEFT &kp DOWN &kp RIGHT &kp DEL &kp BSPC
&trans &kp K_UNDO &kp K_CUT &kp K_COPY &kp K_PASTE &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &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
&trans &kp INS &kp PSCRN &kp K_CMENU &trans &trans &kp PG_UP &trans &kp UP &trans &kp N0 &trans
&trans &kp LALT &kp LCTRL &kp LSHFT &trans &kp CLCK &kp PG_DN &kp LEFT &kp DOWN &kp RIGHT &kp DEL &kp BSPC
&trans &kp K_UNDO &kp K_CUT &kp K_COPY &kp K_PASTE &trans &trans &trans &trans &trans &trans &trans &trans &trans
&trans &trans &trans &trans &trans &trans &trans &trans &trans &trans
>;
sensor-bindings = <&inc_dec_kp C_VOL_UP C_VOL_DN &inc_dec_kp PG_UP PG_DN>;
};
adjust_layer {
// ----------------------------------------------------------------------------------------------------------------------------
// | BTCLR | BT1 | BT2 | BT3 | BT4 | BT5 | | | | | | | |
// | EXTPWR | RGB_HUD | RGB_HUI | RGB_SAD | RGB_SAI | RGB_EFF | | | | | | | |
// | | RGB_BRD | RGB_BRI | | | | | | | | | | |
// | | | | | | | RGB_TOG | | | | | | | | |
// | | | | | | | | | | | |
label = "adjust";
bindings = <
&bt BT_CLR &bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_SEL 4 &none &none &none &none &none &none
&ext_power EP_TOG &rgb_ug RGB_HUD &rgb_ug RGB_HUI &rgb_ug RGB_SAD &rgb_ug RGB_SAI &rgb_ug RGB_EFF &none &none &none &none &none &none
&none &rgb_ug RGB_BRD &rgb_ug RGB_BRI &none &none &none &none &none &none &none &none &none
&none &none &none &none &none &none &rgb_ug RGB_TOG &none &none &none &none &none &none &none
&none &none &none &none &none &none &none &none &none &none
>;
};
};
};

View file

@ -9,6 +9,7 @@ features:
- keys
- display
- encoder
- underglow
siblings:
- sofle_left
- sofle_right

View file

@ -40,28 +40,53 @@ RC(3,0) RC(3,1) RC(3,2) RC(3,3) RC(3,4) RC(3,5)
, <&pro_micro 6 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
, <&pro_micro 7 (GPIO_ACTIVE_HIGH | GPIO_PULL_DOWN)>
;
};
left_encoder: encoder_left { //roller
roller_left_encoder: encoder_left_roller {
compatible = "alps,ec11";
label = "LEFT_ENCODER";
a-gpios = <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <4>;
label = "ROLLER_LEFT_ENCODER";
a-gpios = <&pro_micro 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
steps = <80>;
status = "disabled";
};
right_encoder: encoder_right { //Standard encoder on left half
dial_left_encoder: encoder_left_dial {
compatible = "alps,ec11";
label = "RIGHT_ENCODER";
label = "DIAL_LEFT_ENCODER";
a-gpios = <&pro_micro 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
resolution = <2>;
steps = <80>;
status = "disabled";
};
roller_right_encoder: encoder_right_roller {
compatible = "alps,ec11";
label = "ROLLER_RIGHT_ENCODER";
a-gpios = <&pro_micro 8 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 9 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
steps = <80>;
status = "disabled";
};
dial_right_encoder: encoder_right_dial {
compatible = "alps,ec11";
label = "DIAL_RIGHT_ENCODER";
a-gpios = <&pro_micro 16 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
b-gpios = <&pro_micro 14 (GPIO_ACTIVE_HIGH | GPIO_PULL_UP)>;
steps = <80>;
status = "disabled";
};
sensors {
compatible = "zmk,keymap-sensors";
sensors = <&left_encoder &right_encoder>;
triggers-per-rotation = <20>;
sensors = <
&roller_left_encoder
&dial_left_encoder
&dial_right_encoder
&roller_right_encoder
>;
};
// TODO: RGB node(s)

View file

@ -33,7 +33,12 @@
&kp N1 &lt 3 DEL &lt 1 SPACE &kp TAB &kp N2 &kp N3 &kp ESC &kp BSPC &lt 2 RET &kp N4
>;
sensor-bindings = <&inc_dec_kp PAGE_UP PAGE_DOWN &inc_dec_kp TAB LS(TAB)>;
sensor-bindings = <
&inc_dec_kp PAGE_DOWN PAGE_UP
&inc_dec_kp C_VOL_DN C_VOL_UP
&inc_dec_kp DOWN UP
&inc_dec_kp LEFT RIGHT
>;
};
navnum_layer {
@ -57,7 +62,12 @@
&kp N1 &lt 3 DEL &lt 1 SPACE &kp TAB &kp N2 &kp N3 &kp ESC &kp BSPC &lt 2 RET &kp N4
>;
sensor-bindings = <&inc_dec_kp PAGE_UP PAGE_DOWN &inc_dec_kp TAB LS(TAB)>;
sensor-bindings = <
&inc_dec_kp PAGE_DOWN PAGE_UP
&inc_dec_kp C_VOL_DN C_VOL_UP
&inc_dec_kp DOWN UP
&inc_dec_kp LEFT RIGHT
>;
};
symbol_layer {
@ -81,7 +91,12 @@
&kp N1 &lt 3 DEL &lt 1 SPACE &kp TAB &kp N2 &kp N3 &kp ESC &kp BSPC &lt 2 RET &kp N4
>;
sensor-bindings = <&inc_dec_kp PAGE_UP PAGE_DOWN &inc_dec_kp TAB LS(TAB)>;
sensor-bindings = <
&inc_dec_kp PAGE_DOWN PAGE_UP
&inc_dec_kp C_VOL_DN C_VOL_UP
&inc_dec_kp DOWN UP
&inc_dec_kp LEFT RIGHT
>;
};
function_layer {
@ -105,8 +120,13 @@
&kp N1 &lt 3 DEL &lt 1 SPACE &kp TAB &kp N2 &kp N3 &kp ESC &kp BSPC &lt 2 RET &kp N4
>;
sensor-bindings = <&inc_dec_kp PAGE_UP PAGE_DOWN &inc_dec_kp TAB LS(TAB)>;
sensor-bindings = <
&inc_dec_kp PAGE_DOWN PAGE_UP
&inc_dec_kp C_VOL_DN C_VOL_UP
&inc_dec_kp DOWN UP
&inc_dec_kp LEFT RIGHT
>;
};
};
};
};

View file

@ -16,6 +16,10 @@
;
};
&left_encoder {
&roller_left_encoder {
status = "okay";
};
&dial_left_encoder {
status = "okay";
};

View file

@ -20,7 +20,10 @@
;
};
&right_encoder {
&roller_right_encoder {
status = "okay";
};
&dial_right_encoder {
status = "okay";
};

View file

@ -11,9 +11,17 @@
status = "okay";
};
&arduino_spi {
nice_view_spi: &arduino_spi {
status = "okay";
cs-gpios = <&arduino_header 16 GPIO_ACTIVE_HIGH>;
// Needed so the nice_view shield will enhance the existing node which falls *first*
// on the bus, properly picking up the first `cs-gpios` specifier.
ls0xx@0 {
reg = <0>;
};
led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-spi";

View file

@ -13,15 +13,21 @@ properties:
required: true
tapping-term-ms:
type: int
tapping_term_ms: # deprecated
tapping_term_ms:
type: int
deprecated: true
quick-tap-ms:
type: int
default: -1
quick_tap_ms: # deprecated
quick_tap_ms:
type: int
deprecated: true
global-quick-tap:
type: boolean
deprecated: true
require-prior-idle-ms:
type: int
default: -1
flavor:
type: string
required: false

View file

@ -18,6 +18,9 @@ child-binding:
timeout-ms:
type: int
default: 50
require-prior-idle-ms:
type: int
default: -1
slow-release:
type: boolean
layers:

View file

@ -1439,3 +1439,7 @@
#define C_KEYBOARD_INPUT_ASSIST_CANCEL \
(ZMK_HID_USAGE(HID_USAGE_CONSUMER, HID_USAGE_CONSUMER_KEYBOARD_INPUT_ASSIST_CANCEL))
#define C_KBIA_CANCEL (C_KEYBOARD_INPUT_ASSIST_CANCEL)
/* Apple Globe key */
#define C_AC_NEXT_KEYBOARD_LAYOUT_SELECT (ZMK_HID_USAGE(HID_USAGE_CONSUMER, 0x029D))
#define GLOBE (C_AC_NEXT_KEYBOARD_LAYOUT_SELECT)

View file

@ -6,10 +6,66 @@
#pragma once
#include <zmk/ble.h>
#include <zmk/endpoints_types.h>
int zmk_endpoints_select(enum zmk_endpoint endpoint);
int zmk_endpoints_toggle();
enum zmk_endpoint zmk_endpoints_selected();
/**
* Recommended length of string buffer for printing endpoint identifiers.
*/
#define ZMK_ENDPOINT_STR_LEN 10
#ifdef CONFIG_ZMK_USB
#define ZMK_ENDPOINT_USB_COUNT 1
#else
#define ZMK_ENDPOINT_USB_COUNT 0
#endif
#ifdef CONFIG_ZMK_BLE
#define ZMK_ENDPOINT_BLE_COUNT ZMK_BLE_PROFILE_COUNT
#else
#define ZMK_ENDPOINT_BLE_COUNT 0
#endif
/**
* The total number of different (struct zmk_endpoint_instance) values that can
* be selected.
*
* Note that this value may change between firmware versions, so it should not
* be used in any persistent storage.
*/
#define ZMK_ENDPOINT_COUNT (ZMK_ENDPOINT_USB_COUNT + ZMK_ENDPOINT_BLE_COUNT)
bool zmk_endpoint_instance_eq(struct zmk_endpoint_instance a, struct zmk_endpoint_instance b);
/**
* Writes a string identifying an endpoint instance.
*
* @param str Address of output string buffer
* @param len Length of string buffer. See ZMK_ENDPOINT_STR_LEN for recommended length.
*
* @returns Number of characters written.
*/
int zmk_endpoint_instance_to_str(struct zmk_endpoint_instance endpoint, char *str, size_t len);
/**
* Gets a unique index for an endpoint instance. This can be used together with
* ZMK_ENDPOINT_COUNT to manage separate state for each endpoint instance.
*
* Note that the index for a specific instance may change between firmware versions,
* so it should not be used in any persistent storage.
*/
int zmk_endpoint_instance_to_index(struct zmk_endpoint_instance endpoint);
/**
* Sets the preferred endpoint transport to use. (If the preferred endpoint is
* not available, a different one may automatically be selected.)
*/
int zmk_endpoints_select_transport(enum zmk_transport transport);
int zmk_endpoints_toggle_transport(void);
/**
* Gets the currently-selected endpoint.
*/
struct zmk_endpoint_instance zmk_endpoints_selected(void);
int zmk_endpoints_send_report(uint16_t usage_page);

View file

@ -6,7 +6,33 @@
#pragma once
enum zmk_endpoint {
ZMK_ENDPOINT_USB,
ZMK_ENDPOINT_BLE,
/**
* The method by which data is sent.
*/
enum zmk_transport {
ZMK_TRANSPORT_USB,
ZMK_TRANSPORT_BLE,
};
/**
* Configuration to select an endpoint on ZMK_TRANSPORT_USB.
*/
struct zmk_transport_usb_data {};
/**
* Configuration to select an endpoint on ZMK_TRANSPORT_BLE.
*/
struct zmk_transport_ble_data {
int profile_index;
};
/**
* A specific endpoint to which data may be sent.
*/
struct zmk_endpoint_instance {
enum zmk_transport transport;
union {
struct zmk_transport_usb_data usb; // ZMK_TRANSPORT_USB
struct zmk_transport_ble_data ble; // ZMK_TRANSPORT_BLE
};
};

View file

@ -11,8 +11,8 @@
#include <zmk/endpoints_types.h>
#include <zmk/event_manager.h>
struct zmk_endpoint_selection_changed {
enum zmk_endpoint endpoint;
struct zmk_endpoint_changed {
struct zmk_endpoint_instance endpoint;
};
ZMK_EVENT_DECLARE(zmk_endpoint_selection_changed);
ZMK_EVENT_DECLARE(zmk_endpoint_changed);

View file

@ -12,16 +12,15 @@
#include <errno.h>
#include <kernel.h>
#include <device.h>
#include <init.h>
#include <sys/byteorder.h>
#include <drivers/gpio.h>
#include <drivers/i2c.h>
#include <drivers/ext_power.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/init.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#define LOG_LEVEL CONFIG_GPIO_LOG_LEVEL
#include <logging/log.h>
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(gpio_max7318);

View file

@ -2,4 +2,5 @@
# SPDX-License-Identifier: MIT
add_subdirectory_ifdef(CONFIG_ZMK_BATTERY battery)
add_subdirectory_ifdef(CONFIG_EC11 ec11)
add_subdirectory_ifdef(CONFIG_EC11 ec11)
add_subdirectory_ifdef(CONFIG_MAX17048 max17048)

View file

@ -5,5 +5,6 @@ if SENSOR
rsource "battery/Kconfig"
rsource "ec11/Kconfig"
rsource "max17048/Kconfig"
endif # SENSOR
endif # SENSOR

View file

@ -0,0 +1,9 @@
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
zephyr_include_directories(.)
zephyr_library()
zephyr_library_sources_ifdef(CONFIG_MAX17048 max17048.c)
zephyr_library_sources_ifndef(CONFIG_MAX17048 ${ZEPHYR_BASE}/misc/empty_file.c)

View file

@ -0,0 +1,23 @@
# Copyright (c) 2022 The ZMK Contributors
# SPDX-License-Identifier: MIT
DT_COMPAT_MAXIM_MAX17048 := maxim,max17048
menuconfig MAX17048
bool "MAX17048/9 I2C-based Fuel Gauge"
default $(dt_compat_enabled,$(DT_COMPAT_MAXIM_MAX17048))
depends on I2C
select ZMK_BATTERY
help
Enable driver for MAX17048/9 I2C-based Fuel Gauge. Supports measuring
battery voltage and state-of-charge.
if MAX17048
config SENSOR_MAX17048_INIT_PRIORITY
int "Init priority"
default 75
help
Device driver initialization priority.
endif #MAX17048

View file

@ -0,0 +1,222 @@
/*
* Copyright (c) 2022 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#define DT_DRV_COMPAT maxim_max17048
#include <zephyr/device.h>
#include <zephyr/kernel.h>
#include <zephyr/sys/util.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/drivers/sensor.h>
#include "max17048.h"
#define LOG_LEVEL CONFIG_SENSOR_LOG_LEVEL
#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(sensor_max17048);
static int read_register(const struct device *dev, uint8_t reg, uint16_t *value) {
if (k_is_in_isr()) {
return -EWOULDBLOCK;
}
struct max17048_config *config = (struct max17048_config *)dev->config;
uint8_t data[2] = {0};
int ret = i2c_burst_read_dt(&config->i2c_bus, reg, &data[0], sizeof(data));
if (ret != 0) {
LOG_DBG("i2c_write_read FAIL %d\n", ret);
return ret;
}
// the register values are returned in big endian (MSB first)
*value = sys_get_be16(data);
return 0;
}
static int write_register(const struct device *dev, uint8_t reg, uint16_t value) {
if (k_is_in_isr()) {
return -EWOULDBLOCK;
}
struct max17048_config *config = (struct max17048_config *)dev->config;
uint8_t data[2] = {0};
sys_put_be16(value, &data[0]);
return i2c_burst_write_dt(&config->i2c_bus, reg, &data[0], sizeof(data));
}
static int set_rcomp_value(const struct device *dev, uint8_t rcomp_value) {
struct max17048_drv_data *const drv_data = (struct max17048_drv_data *const)dev->data;
k_sem_take(&drv_data->lock, K_FOREVER);
uint16_t tmp = 0;
int err = read_register(dev, REG_CONFIG, &tmp);
if (err != 0) {
goto done;
}
tmp = ((uint16_t)rcomp_value << 8) | (tmp & 0xFF);
err = write_register(dev, REG_CONFIG, tmp);
if (err != 0) {
goto done;
}
LOG_DBG("set RCOMP to %d", rcomp_value);
done:
k_sem_give(&drv_data->lock);
return err;
}
static int set_sleep_enabled(const struct device *dev, bool sleep) {
struct max17048_drv_data *const drv_data = (struct max17048_drv_data *const)dev->data;
k_sem_take(&drv_data->lock, K_FOREVER);
uint16_t tmp = 0;
int err = read_register(dev, REG_CONFIG, &tmp);
if (err != 0) {
goto done;
}
if (sleep) {
tmp |= 0x80;
} else {
tmp &= ~0x0080;
}
err = write_register(dev, REG_CONFIG, tmp);
if (err != 0) {
goto done;
}
LOG_DBG("sleep mode %s", sleep ? "enabled" : "disabled");
done:
k_sem_give(&drv_data->lock);
return err;
}
static int max17048_sample_fetch(const struct device *dev, enum sensor_channel chan) {
struct max17048_drv_data *const drv_data = dev->data;
k_sem_take(&drv_data->lock, K_FOREVER);
int err = 0;
if (chan == SENSOR_CHAN_GAUGE_STATE_OF_CHARGE || chan == SENSOR_CHAN_ALL) {
err = read_register(dev, REG_STATE_OF_CHARGE, &drv_data->raw_state_of_charge);
if (err != 0) {
LOG_WRN("failed to read state-of-charge: %d", err);
goto done;
}
LOG_DBG("read soc: %d", drv_data->raw_state_of_charge);
} else if (chan == SENSOR_CHAN_GAUGE_VOLTAGE || chan == SENSOR_CHAN_ALL) {
err = read_register(dev, REG_VCELL, &drv_data->raw_vcell);
if (err != 0) {
LOG_WRN("failed to read vcell: %d", err);
goto done;
}
LOG_DBG("read vcell: %d", drv_data->raw_vcell);
} else {
LOG_DBG("unsupported channel %d", chan);
err = -ENOTSUP;
}
done:
k_sem_give(&drv_data->lock);
return err;
}
static int max17048_channel_get(const struct device *dev, enum sensor_channel chan,
struct sensor_value *val) {
int err = 0;
struct max17048_drv_data *const drv_data = dev->data;
k_sem_take(&drv_data->lock, K_FOREVER);
struct max17048_drv_data *const data = dev->data;
unsigned int tmp = 0;
switch (chan) {
case SENSOR_CHAN_GAUGE_VOLTAGE:
// 1250 / 16 = 78.125
tmp = data->raw_vcell * 1250 / 16;
val->val1 = tmp / 1000000;
val->val2 = tmp % 1000000;
break;
case SENSOR_CHAN_GAUGE_STATE_OF_CHARGE:
val->val1 = (data->raw_state_of_charge >> 8);
val->val2 = (data->raw_state_of_charge & 0xFF) * 1000000 / 256;
break;
default:
err = -ENOTSUP;
break;
}
k_sem_give(&drv_data->lock);
return err;
}
static int max17048_init(const struct device *dev) {
struct max17048_drv_data *drv_data = dev->data;
const struct max17048_config *config = dev->config;
if (!device_is_ready(config->i2c_bus.bus)) {
LOG_WRN("i2c bus not ready!");
return -EINVAL;
}
uint16_t ic_version = 0;
int err = read_register(dev, REG_VERSION, &ic_version);
if (err != 0) {
LOG_WRN("could not get IC version!");
return err;
}
// the functions below need the semaphore, so initialise it here
k_sem_init(&drv_data->lock, 1, 1);
// bring the device out of sleep
set_sleep_enabled(dev, false);
// set the default rcomp value -- 0x97, as stated in the datasheet
set_rcomp_value(dev, 0x97);
LOG_INF("device initialised at 0x%x (version %d)", config->i2c_bus.addr, ic_version);
return 0;
}
static const struct sensor_driver_api max17048_api_table = {.sample_fetch = max17048_sample_fetch,
.channel_get = max17048_channel_get};
#define MAX17048_INIT(inst) \
static struct max17048_config max17048_##inst##_config = {.i2c_bus = \
I2C_DT_SPEC_INST_GET(inst)}; \
\
static struct max17048_drv_data max17048_##inst##_drvdata = { \
.raw_state_of_charge = 0, \
.raw_charge_rate = 0, \
.raw_vcell = 0, \
}; \
\
/* This has to init after SPI master */ \
DEVICE_DT_INST_DEFINE(inst, max17048_init, NULL, &max17048_##inst##_drvdata, \
&max17048_##inst##_config, POST_KERNEL, CONFIG_SENSOR_INIT_PRIORITY, \
&max17048_api_table);
DT_INST_FOREACH_STATUS_OKAY(MAX17048_INIT)

View file

@ -0,0 +1,41 @@
/*
* Copyright (c) 2022 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <zephyr/device.h>
#include <zephyr/sys/util.h>
#ifdef __cplusplus
extern "C" {
#endif
#define REG_VCELL 0x02
#define REG_STATE_OF_CHARGE 0x04
#define REG_MODE 0x06
#define REG_VERSION 0x08
#define REG_HIBERNATE 0x0A
#define REG_CONFIG 0x0C
#define REG_VALERT 0x14
#define REG_CHARGE_RATE 0x16
#define REG_VRESET 0x18
#define REG_STATUS 0x1A
struct max17048_config {
struct i2c_dt_spec i2c_bus;
};
struct max17048_drv_data {
struct k_sem lock;
uint16_t raw_state_of_charge;
uint16_t raw_charge_rate;
uint16_t raw_vcell;
};
#ifdef __cplusplus
}
#endif

View file

@ -12,9 +12,6 @@ compatible: "maxim,max7318"
include: [gpio-controller.yaml, i2c-device.yaml]
properties:
label:
required: true
"#gpio-cells":
const: 2

View file

@ -0,0 +1,12 @@
#
# Copyright (c) 2022 The ZMK Contributors
#
# SPDX-License-Identifier: MIT
#
description: >
This is a representation of the Maxim max17048 I2C Fuel Gauge.
compatible: "maxim,max17048"
include: [i2c-device.yaml]

View file

@ -57,7 +57,7 @@ struct behavior_hold_tap_config {
char *hold_behavior_dev;
char *tap_behavior_dev;
int quick_tap_ms;
bool global_quick_tap;
int require_prior_idle_ms;
enum flavor flavor;
bool retro_tap;
bool hold_trigger_on_release;
@ -97,7 +97,9 @@ struct last_tapped {
int64_t timestamp;
};
struct last_tapped last_tapped = {INT32_MIN, INT64_MIN};
// Set time stamp to large negative number initially for test suites, but not
// int64 min since it will overflow if -1 is added
struct last_tapped last_tapped = {INT32_MIN, INT32_MIN};
static void store_last_tapped(int64_t timestamp) {
if (timestamp > last_tapped.timestamp) {
@ -112,10 +114,11 @@ static void store_last_hold_tapped(struct active_hold_tap *hold_tap) {
}
static bool is_quick_tap(struct active_hold_tap *hold_tap) {
if (hold_tap->config->global_quick_tap || last_tapped.position == hold_tap->position) {
return (last_tapped.timestamp + hold_tap->config->quick_tap_ms) > hold_tap->timestamp;
if ((last_tapped.timestamp + hold_tap->config->require_prior_idle_ms) > hold_tap->timestamp) {
return true;
} else {
return false;
return (last_tapped.position == hold_tap->position) &&
(last_tapped.timestamp + hold_tap->config->quick_tap_ms) > hold_tap->timestamp;
}
}
@ -703,7 +706,9 @@ static int behavior_hold_tap_init(const struct device *dev) {
.hold_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 0), label), \
.tap_behavior_dev = DT_PROP(DT_INST_PHANDLE_BY_IDX(n, bindings, 1), label), \
.quick_tap_ms = DT_INST_PROP(n, quick_tap_ms), \
.global_quick_tap = DT_INST_PROP(n, global_quick_tap), \
.require_prior_idle_ms = DT_INST_PROP(n, global_quick_tap) \
? DT_INST_PROP(n, quick_tap_ms) \
: DT_INST_PROP(n, require_prior_idle_ms), \
.flavor = DT_ENUM_IDX(DT_DRV_INST(n), flavor), \
.retro_tap = DT_INST_PROP(n, retro_tap), \
.hold_trigger_on_release = DT_INST_PROP(n, hold_trigger_on_release), \

View file

@ -24,11 +24,11 @@ static int on_keymap_binding_pressed(struct zmk_behavior_binding *binding,
struct zmk_behavior_binding_event event) {
switch (binding->param1) {
case OUT_TOG:
return zmk_endpoints_toggle();
return zmk_endpoints_toggle_transport();
case OUT_USB:
return zmk_endpoints_select(ZMK_ENDPOINT_USB);
return zmk_endpoints_select_transport(ZMK_TRANSPORT_USB);
case OUT_BLE:
return zmk_endpoints_select(ZMK_ENDPOINT_BLE);
return zmk_endpoints_select_transport(ZMK_TRANSPORT_BLE);
default:
LOG_ERR("Unknown output command: %d", binding->param1);
}

View file

@ -16,6 +16,7 @@
#include <zmk/behavior.h>
#include <zmk/event_manager.h>
#include <zmk/events/position_state_changed.h>
#include <zmk/events/keycode_state_changed.h>
#include <zmk/hid.h>
#include <zmk/matrix.h>
#include <zmk/keymap.h>
@ -30,6 +31,7 @@ struct combo_cfg {
int32_t key_position_len;
struct zmk_behavior_binding behavior;
int32_t timeout_ms;
int32_t require_prior_idle_ms;
// if slow release is set, the combo releases when the last key is released.
// otherwise, the combo releases when the first key is released.
bool slow_release;
@ -72,6 +74,17 @@ int active_combo_count = 0;
struct k_work_delayable timeout_task;
int64_t timeout_task_timeout_at;
// this keeps track of the last non-combo, non-mod key tap
int64_t last_tapped_timestamp = INT32_MIN;
// this keeps track of the last time a combo was pressed
int64_t last_combo_timestamp = INT32_MIN;
static void store_last_tapped(int64_t timestamp) {
if (timestamp > last_combo_timestamp) {
last_tapped_timestamp = timestamp;
}
}
// Store the combo key pointer in the combos array, one pointer for each key position
// The combos are sorted shortest-first, then by virtual-key-position.
static int initialize_combo(struct combo_cfg *new_combo) {
@ -122,6 +135,10 @@ static bool combo_active_on_layer(struct combo_cfg *combo, uint8_t layer) {
return false;
}
static bool is_quick_tap(struct combo_cfg *combo, int64_t timestamp) {
return (last_tapped_timestamp + combo->require_prior_idle_ms) > timestamp;
}
static int setup_candidates_for_first_keypress(int32_t position, int64_t timestamp) {
int number_of_combo_candidates = 0;
uint8_t highest_active_layer = zmk_keymap_highest_layer_active();
@ -130,7 +147,7 @@ static int setup_candidates_for_first_keypress(int32_t position, int64_t timesta
if (combo == NULL) {
return number_of_combo_candidates;
}
if (combo_active_on_layer(combo, highest_active_layer)) {
if (combo_active_on_layer(combo, highest_active_layer) && !is_quick_tap(combo, timestamp)) {
candidates[number_of_combo_candidates].combo = combo;
candidates[number_of_combo_candidates].timeout_at = timestamp + combo->timeout_ms;
number_of_combo_candidates++;
@ -204,22 +221,34 @@ static inline bool candidate_is_completely_pressed(struct combo_cfg *candidate)
static int cleanup();
static int filter_timed_out_candidates(int64_t timestamp) {
int num_candidates = 0;
int remaining_candidates = 0;
for (int i = 0; i < CONFIG_ZMK_COMBO_MAX_COMBOS_PER_KEY; i++) {
struct combo_candidate *candidate = &candidates[i];
if (candidate->combo == NULL) {
break;
}
if (candidate->timeout_at > timestamp) {
// reorder candidates so they're contiguous
candidates[num_candidates].combo = candidate->combo;
candidates[num_candidates].timeout_at = candidate->timeout_at;
num_candidates++;
bool need_to_bubble_up = remaining_candidates != i;
if (need_to_bubble_up) {
// bubble up => reorder candidates so they're contiguous
candidates[remaining_candidates].combo = candidate->combo;
candidates[remaining_candidates].timeout_at = candidate->timeout_at;
// clear the previous location
candidates[i].combo = NULL;
candidates[i].timeout_at = 0;
}
remaining_candidates++;
} else {
candidate->combo = NULL;
}
}
return num_candidates;
LOG_DBG(
"after filtering out timed out combo candidates: remaining_candidates=%d timestamp=%lld",
remaining_candidates, timestamp);
return remaining_candidates;
}
static int clear_candidates() {
@ -240,7 +269,7 @@ static int capture_pressed_key(const zmk_event_t *ev) {
pressed_keys[i] = ev;
return ZMK_EV_EVENT_CAPTURED;
}
return 0;
return ZMK_EV_EVENT_BUBBLE;
}
const struct zmk_listener zmk_listener_combo;
@ -272,6 +301,8 @@ static inline int press_combo_behavior(struct combo_cfg *combo, int32_t timestam
.timestamp = timestamp,
};
last_combo_timestamp = timestamp;
return behavior_keymap_binding_pressed(&combo->behavior, event);
}
@ -401,7 +432,7 @@ static int position_state_down(const zmk_event_t *ev, struct zmk_position_state_
if (candidates[0].combo == NULL) {
num_candidates = setup_candidates_for_first_keypress(data->position, data->timestamp);
if (num_candidates == 0) {
return 0;
return ZMK_EV_EVENT_BUBBLE;
}
} else {
filter_timed_out_candidates(data->timestamp);
@ -441,7 +472,7 @@ static int position_state_up(const zmk_event_t *ev, struct zmk_position_state_ch
ZMK_EVENT_RAISE(ev);
return ZMK_EV_EVENT_CAPTURED;
}
return 0;
return ZMK_EV_EVENT_BUBBLE;
}
static void combo_timeout_handler(struct k_work *item) {
@ -449,7 +480,7 @@ static void combo_timeout_handler(struct k_work *item) {
// timer was cancelled or rescheduled.
return;
}
if (filter_timed_out_candidates(timeout_task_timeout_at) < 2) {
if (filter_timed_out_candidates(timeout_task_timeout_at) == 0) {
cleanup();
}
update_timeout_task();
@ -458,7 +489,7 @@ static void combo_timeout_handler(struct k_work *item) {
static int position_state_changed_listener(const zmk_event_t *ev) {
struct zmk_position_state_changed *data = as_zmk_position_state_changed(ev);
if (data == NULL) {
return 0;
return ZMK_EV_EVENT_BUBBLE;
}
if (data->state) { // keydown
@ -468,12 +499,31 @@ static int position_state_changed_listener(const zmk_event_t *ev) {
}
}
ZMK_LISTENER(combo, position_state_changed_listener);
static int keycode_state_changed_listener(const zmk_event_t *eh) {
struct zmk_keycode_state_changed *ev = as_zmk_keycode_state_changed(eh);
if (ev->state && !is_mod(ev->usage_page, ev->keycode)) {
store_last_tapped(ev->timestamp);
}
return ZMK_EV_EVENT_BUBBLE;
}
int behavior_combo_listener(const zmk_event_t *eh) {
if (as_zmk_position_state_changed(eh) != NULL) {
return position_state_changed_listener(eh);
} else if (as_zmk_keycode_state_changed(eh) != NULL) {
return keycode_state_changed_listener(eh);
}
return ZMK_EV_EVENT_BUBBLE;
}
ZMK_LISTENER(combo, behavior_combo_listener);
ZMK_SUBSCRIPTION(combo, zmk_position_state_changed);
ZMK_SUBSCRIPTION(combo, zmk_keycode_state_changed);
#define COMBO_INST(n) \
static struct combo_cfg combo_config_##n = { \
.timeout_ms = DT_PROP(n, timeout_ms), \
.require_prior_idle_ms = DT_PROP(n, require_prior_idle_ms), \
.key_positions = DT_PROP(n, key_positions), \
.key_position_len = DT_PROP_LEN(n, key_positions), \
.behavior = ZMK_KEYMAP_EXTRACT_BINDING(0, n), \

View file

@ -12,9 +12,8 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#include <zmk/display.h>
#include <zmk/display/widgets/output_status.h>
#include <zmk/event_manager.h>
#include <zmk/events/usb_conn_state_changed.h>
#include <zmk/events/ble_active_profile_changed.h>
#include <zmk/events/endpoint_selection_changed.h>
#include <zmk/events/endpoint_changed.h>
#include <zmk/usb.h>
#include <zmk/ble.h>
#include <zmk/endpoints.h>
@ -22,40 +21,38 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static sys_slist_t widgets = SYS_SLIST_STATIC_INIT(&widgets);
struct output_status_state {
enum zmk_endpoint selected_endpoint;
struct zmk_endpoint_instance selected_endpoint;
bool active_profile_connected;
bool active_profile_bonded;
uint8_t active_profile_index;
};
static struct output_status_state get_state(const zmk_event_t *_eh) {
return (struct output_status_state){.selected_endpoint = zmk_endpoints_selected(),
.active_profile_connected =
zmk_ble_active_profile_is_connected(),
.active_profile_bonded = !zmk_ble_active_profile_is_open(),
.active_profile_index = zmk_ble_active_profile_index()};
.active_profile_bonded = !zmk_ble_active_profile_is_open()};
;
}
static void set_status_symbol(lv_obj_t *label, struct output_status_state state) {
char text[10] = {};
switch (state.selected_endpoint) {
case ZMK_ENDPOINT_USB:
switch (state.selected_endpoint.transport) {
case ZMK_TRANSPORT_USB:
strcat(text, LV_SYMBOL_USB);
break;
case ZMK_ENDPOINT_BLE:
case ZMK_TRANSPORT_BLE:
if (state.active_profile_bonded) {
if (state.active_profile_connected) {
snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_OK,
state.active_profile_index + 1);
state.selected_endpoint.ble.profile_index + 1);
} else {
snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_CLOSE,
state.active_profile_index + 1);
state.selected_endpoint.ble.profile_index + 1);
}
} else {
snprintf(text, sizeof(text), LV_SYMBOL_WIFI " %i " LV_SYMBOL_SETTINGS,
state.active_profile_index + 1);
state.selected_endpoint.ble.profile_index + 1);
}
break;
}
@ -70,11 +67,9 @@ static void output_status_update_cb(struct output_status_state state) {
ZMK_DISPLAY_WIDGET_LISTENER(widget_output_status, struct output_status_state,
output_status_update_cb, get_state)
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_selection_changed);
#if IS_ENABLED(CONFIG_USB_DEVICE_STACK)
ZMK_SUBSCRIPTION(widget_output_status, zmk_usb_conn_state_changed);
#endif
ZMK_SUBSCRIPTION(widget_output_status, zmk_endpoint_changed);
// We don't get an endpoint changed event when the active profile connects/disconnects
// but there wasn't another endpoint to switch from/to, so update on BLE events too.
#if defined(CONFIG_ZMK_BLE)
ZMK_SUBSCRIPTION(widget_output_status, zmk_ble_active_profile_changed);
#endif

View file

@ -7,6 +7,8 @@
#include <zephyr/init.h>
#include <zephyr/settings/settings.h>
#include <stdio.h>
#include <zmk/ble.h>
#include <zmk/endpoints.h>
#include <zmk/hid.h>
@ -16,29 +18,29 @@
#include <zmk/event_manager.h>
#include <zmk/events/ble_active_profile_changed.h>
#include <zmk/events/usb_conn_state_changed.h>
#include <zmk/events/endpoint_selection_changed.h>
#include <zmk/events/endpoint_changed.h>
#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
#define DEFAULT_ENDPOINT \
COND_CODE_1(IS_ENABLED(CONFIG_ZMK_BLE), (ZMK_ENDPOINT_BLE), (ZMK_ENDPOINT_USB))
#define DEFAULT_TRANSPORT \
COND_CODE_1(IS_ENABLED(CONFIG_ZMK_BLE), (ZMK_TRANSPORT_BLE), (ZMK_TRANSPORT_USB))
static enum zmk_endpoint current_endpoint = DEFAULT_ENDPOINT;
static enum zmk_endpoint preferred_endpoint =
ZMK_ENDPOINT_USB; /* Used if multiple endpoints are ready */
static struct zmk_endpoint_instance current_instance = {};
static enum zmk_transport preferred_transport =
ZMK_TRANSPORT_USB; /* Used if multiple endpoints are ready */
static void update_current_endpoint();
static void update_current_endpoint(void);
#if IS_ENABLED(CONFIG_SETTINGS)
static void endpoints_save_preferred_work(struct k_work *work) {
settings_save_one("endpoints/preferred", &preferred_endpoint, sizeof(preferred_endpoint));
settings_save_one("endpoints/preferred", &preferred_transport, sizeof(preferred_transport));
}
static struct k_work_delayable endpoints_save_work;
#endif
static int endpoints_save_preferred() {
static int endpoints_save_preferred(void) {
#if IS_ENABLED(CONFIG_SETTINGS)
return k_work_reschedule(&endpoints_save_work, K_MSEC(CONFIG_ZMK_SETTINGS_SAVE_DEBOUNCE));
#else
@ -46,14 +48,60 @@ static int endpoints_save_preferred() {
#endif
}
int zmk_endpoints_select(enum zmk_endpoint endpoint) {
LOG_DBG("Selected endpoint %d", endpoint);
bool zmk_endpoint_instance_eq(struct zmk_endpoint_instance a, struct zmk_endpoint_instance b) {
if (a.transport != b.transport) {
return false;
}
if (preferred_endpoint == endpoint) {
switch (a.transport) {
case ZMK_TRANSPORT_USB:
return true;
case ZMK_TRANSPORT_BLE:
return a.ble.profile_index == b.ble.profile_index;
}
LOG_ERR("Invalid transport %d", a.transport);
return false;
}
int zmk_endpoint_instance_to_str(struct zmk_endpoint_instance endpoint, char *str, size_t len) {
switch (endpoint.transport) {
case ZMK_TRANSPORT_USB:
return snprintf(str, len, "USB");
case ZMK_TRANSPORT_BLE:
return snprintf(str, len, "BLE:%d", endpoint.ble.profile_index);
default:
return snprintf(str, len, "Invalid");
}
}
#define INSTANCE_INDEX_OFFSET_USB 0
#define INSTANCE_INDEX_OFFSET_BLE ZMK_ENDPOINT_USB_COUNT
int zmk_endpoint_instance_to_index(struct zmk_endpoint_instance endpoint) {
switch (endpoint.transport) {
case ZMK_TRANSPORT_USB:
return INSTANCE_INDEX_OFFSET_USB;
case ZMK_TRANSPORT_BLE:
return INSTANCE_INDEX_OFFSET_BLE + endpoint.ble.profile_index;
}
LOG_ERR("Invalid transport %d", endpoint.transport);
return 0;
}
int zmk_endpoints_select_transport(enum zmk_transport transport) {
LOG_DBG("Selected endpoint transport %d", transport);
if (preferred_transport == transport) {
return 0;
}
preferred_endpoint = endpoint;
preferred_transport = transport;
endpoints_save_preferred();
@ -62,20 +110,22 @@ int zmk_endpoints_select(enum zmk_endpoint endpoint) {
return 0;
}
enum zmk_endpoint zmk_endpoints_selected() { return current_endpoint; }
int zmk_endpoints_toggle() {
enum zmk_endpoint new_endpoint =
(preferred_endpoint == ZMK_ENDPOINT_USB) ? ZMK_ENDPOINT_BLE : ZMK_ENDPOINT_USB;
return zmk_endpoints_select(new_endpoint);
int zmk_endpoints_toggle_transport(void) {
enum zmk_transport new_transport =
(preferred_transport == ZMK_TRANSPORT_USB) ? ZMK_TRANSPORT_BLE : ZMK_TRANSPORT_USB;
return zmk_endpoints_select_transport(new_transport);
}
static int send_keyboard_report() {
struct zmk_endpoint_instance zmk_endpoints_selected(void) {
return current_instance;
}
static int send_keyboard_report(void) {
struct zmk_hid_keyboard_report *keyboard_report = zmk_hid_get_keyboard_report();
switch (current_endpoint) {
switch (current_instance.transport) {
#if IS_ENABLED(CONFIG_ZMK_USB)
case ZMK_ENDPOINT_USB: {
case ZMK_TRANSPORT_USB: {
int err = zmk_usb_hid_send_report((uint8_t *)keyboard_report, sizeof(*keyboard_report));
if (err) {
LOG_ERR("FAILED TO SEND OVER USB: %d", err);
@ -85,7 +135,7 @@ static int send_keyboard_report() {
#endif /* IS_ENABLED(CONFIG_ZMK_USB) */
#if IS_ENABLED(CONFIG_ZMK_BLE)
case ZMK_ENDPOINT_BLE: {
case ZMK_TRANSPORT_BLE: {
int err = zmk_hog_send_keyboard_report(&keyboard_report->body);
if (err) {
LOG_ERR("FAILED TO SEND OVER HOG: %d", err);
@ -93,19 +143,18 @@ static int send_keyboard_report() {
return err;
}
#endif /* IS_ENABLED(CONFIG_ZMK_BLE) */
default:
LOG_ERR("Unsupported endpoint %d", current_endpoint);
return -ENOTSUP;
}
LOG_ERR("Unsupported endpoint transport %d", current_instance.transport);
return -ENOTSUP;
}
static int send_consumer_report() {
static int send_consumer_report(void) {
struct zmk_hid_consumer_report *consumer_report = zmk_hid_get_consumer_report();
switch (current_endpoint) {
switch (current_instance.transport) {
#if IS_ENABLED(CONFIG_ZMK_USB)
case ZMK_ENDPOINT_USB: {
case ZMK_TRANSPORT_USB: {
int err = zmk_usb_hid_send_report((uint8_t *)consumer_report, sizeof(*consumer_report));
if (err) {
LOG_ERR("FAILED TO SEND OVER USB: %d", err);
@ -115,7 +164,7 @@ static int send_consumer_report() {
#endif /* IS_ENABLED(CONFIG_ZMK_USB) */
#if IS_ENABLED(CONFIG_ZMK_BLE)
case ZMK_ENDPOINT_BLE: {
case ZMK_TRANSPORT_BLE: {
int err = zmk_hog_send_consumer_report(&consumer_report->body);
if (err) {
LOG_ERR("FAILED TO SEND OVER HOG: %d", err);
@ -123,11 +172,10 @@ static int send_consumer_report() {
return err;
}
#endif /* IS_ENABLED(CONFIG_ZMK_BLE) */
default:
LOG_ERR("Unsupported endpoint %d", current_endpoint);
return -ENOTSUP;
}
LOG_ERR("Unsupported endpoint transport %d", current_instance.transport);
return -ENOTSUP;
}
int zmk_endpoints_send_report(uint16_t usage_page) {
@ -136,12 +184,13 @@ int zmk_endpoints_send_report(uint16_t usage_page) {
switch (usage_page) {
case HID_USAGE_KEY:
return send_keyboard_report();
case HID_USAGE_CONSUMER:
return send_consumer_report();
default:
LOG_ERR("Unsupported usage page %d", usage_page);
return -ENOTSUP;
}
LOG_ERR("Unsupported usage page %d", usage_page);
return -ENOTSUP;
}
#if IS_ENABLED(CONFIG_SETTINGS)
@ -151,12 +200,12 @@ static int endpoints_handle_set(const char *name, size_t len, settings_read_cb r
LOG_DBG("Setting endpoint value %s", name);
if (settings_name_steq(name, "preferred", NULL)) {
if (len != sizeof(enum zmk_endpoint)) {
LOG_ERR("Invalid endpoint size (got %d expected %d)", len, sizeof(enum zmk_endpoint));
if (len != sizeof(enum zmk_transport)) {
LOG_ERR("Invalid endpoint size (got %d expected %d)", len, sizeof(enum zmk_transport));
return -EINVAL;
}
int err = read_cb(cb_arg, &preferred_endpoint, sizeof(enum zmk_endpoint));
int err = read_cb(cb_arg, &preferred_transport, sizeof(enum zmk_transport));
if (err <= 0) {
LOG_ERR("Failed to read preferred endpoint from settings (err %d)", err);
return err;
@ -171,6 +220,60 @@ static int endpoints_handle_set(const char *name, size_t len, settings_read_cb r
struct settings_handler endpoints_handler = {.name = "endpoints", .h_set = endpoints_handle_set};
#endif /* IS_ENABLED(CONFIG_SETTINGS) */
static bool is_usb_ready(void) {
#if IS_ENABLED(CONFIG_ZMK_USB)
return zmk_usb_is_hid_ready();
#else
return false;
#endif
}
static bool is_ble_ready(void) {
#if IS_ENABLED(CONFIG_ZMK_BLE)
return zmk_ble_active_profile_is_connected();
#else
return false;
#endif
}
static enum zmk_transport get_selected_transport(void) {
if (is_ble_ready()) {
if (is_usb_ready()) {
LOG_DBG("Both endpoint transports are ready. Using %d", preferred_transport);
return preferred_transport;
}
LOG_DBG("Only BLE is ready.");
return ZMK_TRANSPORT_BLE;
}
if (is_usb_ready()) {
LOG_DBG("Only USB is ready.");
return ZMK_TRANSPORT_USB;
}
LOG_DBG("No endpoint transports are ready.");
return DEFAULT_TRANSPORT;
}
static struct zmk_endpoint_instance get_selected_instance(void) {
struct zmk_endpoint_instance instance = {.transport = get_selected_transport()};
switch (instance.transport) {
#if IS_ENABLED(CONFIG_ZMK_BLE)
case ZMK_TRANSPORT_BLE:
instance.ble.profile_index = zmk_ble_active_profile_index();
break;
#endif // IS_ENABLED(CONFIG_ZMK_BLE)
default:
// No extra data for this transport.
break;
}
return instance;
}
static int zmk_endpoints_init(const struct device *_arg) {
#if IS_ENABLED(CONFIG_SETTINGS)
settings_subsys_init();
@ -186,45 +289,11 @@ static int zmk_endpoints_init(const struct device *_arg) {
settings_load_subtree("endpoints");
#endif
current_instance = get_selected_instance();
return 0;
}
static bool is_usb_ready() {
#if IS_ENABLED(CONFIG_ZMK_USB)
return zmk_usb_is_hid_ready();
#else
return false;
#endif
}
static bool is_ble_ready() {
#if IS_ENABLED(CONFIG_ZMK_BLE)
return zmk_ble_active_profile_is_connected();
#else
return false;
#endif
}
static enum zmk_endpoint get_selected_endpoint() {
if (is_ble_ready()) {
if (is_usb_ready()) {
LOG_DBG("Both endpoints are ready. Using %d", preferred_endpoint);
return preferred_endpoint;
}
LOG_DBG("Only BLE is ready.");
return ZMK_ENDPOINT_BLE;
}
if (is_usb_ready()) {
LOG_DBG("Only USB is ready.");
return ZMK_ENDPOINT_USB;
}
LOG_DBG("No endpoints are ready.");
return DEFAULT_ENDPOINT;
}
static void disconnect_current_endpoint() {
zmk_hid_keyboard_clear();
zmk_hid_consumer_clear();
@ -233,18 +302,21 @@ static void disconnect_current_endpoint() {
zmk_endpoints_send_report(HID_USAGE_CONSUMER);
}
static void update_current_endpoint() {
enum zmk_endpoint new_endpoint = get_selected_endpoint();
static void update_current_endpoint(void) {
struct zmk_endpoint_instance new_instance = get_selected_instance();
if (new_endpoint != current_endpoint) {
/* Cancel all current keypresses so keys don't stay held on the old endpoint. */
if (!zmk_endpoint_instance_eq(new_instance, current_instance)) {
// Cancel all current keypresses so keys don't stay held on the old endpoint.
disconnect_current_endpoint();
current_endpoint = new_endpoint;
LOG_INF("Endpoint changed: %d", current_endpoint);
current_instance = new_instance;
ZMK_EVENT_RAISE(new_zmk_endpoint_selection_changed(
(struct zmk_endpoint_selection_changed){.endpoint = current_endpoint}));
char endpoint_str[ZMK_ENDPOINT_STR_LEN];
zmk_endpoint_instance_to_str(current_instance, endpoint_str, sizeof(endpoint_str));
LOG_INF("Endpoint changed: %s", endpoint_str);
ZMK_EVENT_RAISE(
new_zmk_endpoint_changed((struct zmk_endpoint_changed){.endpoint = current_instance}));
}
}

View file

@ -5,6 +5,6 @@
*/
#include <zephyr/kernel.h>
#include <zmk/events/endpoint_selection_changed.h>
#include <zmk/events/endpoint_changed.h>
ZMK_EVENT_IMPL(zmk_endpoint_selection_changed);
ZMK_EVENT_IMPL(zmk_endpoint_changed);

View file

@ -19,6 +19,21 @@ LOG_MODULE_DECLARE(zmk, CONFIG_ZMK_LOG_LEVEL);
static int hid_listener_keycode_pressed(const struct zmk_keycode_state_changed *ev) {
int err, explicit_mods_changed, implicit_mods_changed;
if (!is_mod(ev->usage_page, ev->keycode) &&
zmk_hid_is_pressed(ZMK_HID_USAGE(ev->usage_page, ev->keycode))) {
LOG_DBG("unregistering usage_page 0x%02X keycode 0x%02X since it was already pressed",
ev->usage_page, ev->keycode);
err = zmk_hid_release(ZMK_HID_USAGE(ev->usage_page, ev->keycode));
if (err < 0) {
LOG_DBG("Unable to pre-release keycode (%d)", err);
return err;
}
err = zmk_endpoints_send_report(ev->usage_page);
if (err < 0) {
LOG_ERR("Failed to send key report for pre-releasing keycode (%d)", err);
}
}
LOG_DBG("usage_page 0x%02X keycode 0x%02X implicit_mods 0x%02X explicit_mods 0x%02X",
ev->usage_page, ev->keycode, ev->implicit_modifiers, ev->explicit_modifiers);
err = zmk_hid_press(ZMK_HID_USAGE(ev->usage_page, ev->keycode));

View file

@ -0,0 +1 @@
s/.*\(hid_listener_keycode_pressed\|filter_timed_out_candidates\): //p

View file

@ -0,0 +1,8 @@
after filtering out timed out combo candidates: remaining_candidates=2 timestamp=71
after filtering out timed out combo candidates: remaining_candidates=1 timestamp=81
after filtering out timed out combo candidates: remaining_candidates=0 timestamp=91
usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
after filtering out timed out combo candidates: remaining_candidates=2 timestamp=143
after filtering out timed out combo candidates: remaining_candidates=1 timestamp=153
after filtering out timed out combo candidates: remaining_candidates=1 timestamp=159
usage_page 0x07 keycode 0x1D implicit_mods 0x00 explicit_mods 0x00

View file

@ -0,0 +1,98 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
#define kA 0
#define kB 1
#define kC 2
#define kD 3
/ {
combos {
compatible = "zmk,combos";
// Intentionally out of order in the config, to make sure 'combo.c' handles it properly
combo_40 {
timeout-ms = <40>;
key-positions = <kA kD>;
bindings = <&kp Z>;
};
combo_20 {
timeout-ms = <20>;
key-positions = <kA kB>;
bindings = <&kp X>;
};
combo_30 {
timeout-ms = <30>;
key-positions = <kA kC>;
bindings = <&kp Y>;
};
};
keymap {
compatible = "zmk,keymap";
label ="Default keymap";
default_layer {
bindings = <
&kp A &kp B
&kp C &kp D
>;
};
};
};
#define press_A_and_wait(delay_next) \
ZMK_MOCK_PRESS(0,0,delay_next)
#define press_B_and_wait(delay_next) \
ZMK_MOCK_PRESS(0,1,delay_next)
#define press_C_and_wait(delay_next) \
ZMK_MOCK_PRESS(1,0,delay_next)
#define press_D_and_wait(delay_next) \
ZMK_MOCK_PRESS(1,1,delay_next)
#define release_A_and_wait(delay_next) \
ZMK_MOCK_RELEASE(0,0,delay_next)
#define release_D_and_wait(delay_next) \
ZMK_MOCK_RELEASE(1,1,delay_next)
&kscan {
events = <
/* Note: This starts at T+50 because the ZMK_MOCK_PRESS seems to launch the first event at T+(first wait duration). So in our case T+50 */
/*** First Phase: All 3 combos expire ***/
/* T+50+0= T+50: Press A and wait 50ms */
press_A_and_wait(50)
/* T+50+20= T+70: 'combo_20' should expire */
/* T+50+30= T+80: 'combo_30' should expire */
/* T+50+40= T+90: 'combo_40' should expire, and we should send the keycode 'A' */
/* T+50+50= T+100: We release A and wait 20ms */
release_A_and_wait(20)
/*** Second Phase: 2 combo expire, 1 combo triggers ***/
/* T+120+0= T+120: Press A and wait 35ms */
press_A_and_wait(35)
/* T+120+20= T+140: 'combo_20' should expire */
/* T+120+30= T+150: 'combo_30' should expire */
/* T+120+35= T+155: We press 'D', this should trigger 'combo_40' and send the keycode 'Z'. We wait 15ms */
press_D_and_wait(15)
/*** Cleanup ***/
/* T+120+50= T+170: We release both keys */
release_A_and_wait(20)
release_D_and_wait(0)
>;
};

View file

@ -0,0 +1 @@
s/.*hid_listener_keycode_//p

View file

@ -0,0 +1,14 @@
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x05 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x1B implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x1B implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x1B implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x1B implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x04 implicit_mods 0x00 explicit_mods 0x00
pressed: usage_page 0x07 keycode 0x1C implicit_mods 0x00 explicit_mods 0x00
released: usage_page 0x07 keycode 0x1C implicit_mods 0x00 explicit_mods 0x00

View file

@ -0,0 +1,64 @@
#include <dt-bindings/zmk/keys.h>
#include <behaviors.dtsi>
#include <dt-bindings/zmk/kscan_mock.h>
/ {
combos {
compatible = "zmk,combos";
combo_one {
timeout-ms = <50>;
key-positions = <0 1>;
bindings = <&kp X>;
require-prior-idle-ms = <100>;
};
combo_two {
timeout-ms = <50>;
key-positions = <0 2>;
bindings = <&kp Y>;
};
};
keymap {
compatible = "zmk,keymap";
label ="Default keymap";
default_layer {
bindings = <
&kp A &kp B
&kp C &kp D
>;
};
};
};
&kscan {
events = <
/* Tap A */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,60)
/* Quick Tap A and B */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,200)
/* Combo One */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,10)
/* Combo One Again (shouldn't quick tap) */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(0,1,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,1,10)
/* Tap A */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,60)
/* Combo 2 */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(1,0,10)
>;
};

View file

@ -7,7 +7,7 @@
events = <
/* tap */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,0,250)
/* normal quick tap */
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(0,0,400)
@ -16,7 +16,7 @@
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
ZMK_MOCK_RELEASE(0,0,400)
/* global quick tap */
/* require-prior-idle */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(1,0,10)

View file

@ -11,8 +11,8 @@
flavor = "balanced";
tapping-term-ms = <300>;
quick-tap-ms = <300>;
require-prior-idle-ms = <100>;
bindings = <&kp>, <&kp>;
global-quick-tap;
};
};

View file

@ -7,7 +7,7 @@
events = <
/* tap */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,0,250)
/* normal quick tap */
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(0,0,400)
@ -16,7 +16,7 @@
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
ZMK_MOCK_RELEASE(0,0,400)
/* global quick tap */
/* require-prior-idle */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(1,0,10)

View file

@ -11,8 +11,8 @@
flavor = "hold-preferred";
tapping-term-ms = <300>;
quick-tap-ms = <300>;
require-prior-idle-ms = <100>;
bindings = <&kp>, <&kp>;
global-quick-tap;
};
};

View file

@ -7,7 +7,7 @@
events = <
/* tap */
ZMK_MOCK_PRESS(0,0,10)
ZMK_MOCK_RELEASE(0,0,10)
ZMK_MOCK_RELEASE(0,0,250)
/* normal quick tap */
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(0,0,400)
@ -16,7 +16,7 @@
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_RELEASE(1,0,10)
ZMK_MOCK_RELEASE(0,0,400)
/* global quick tap */
/* require-prior-idle */
ZMK_MOCK_PRESS(1,0,10)
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_RELEASE(1,0,10)

View file

@ -6,7 +6,7 @@
&kscan {
events = <
/* hold the first mod tap */
ZMK_MOCK_PRESS(0,0,400)
ZMK_MOCK_PRESS(0,0,10)
/* hold the second mod tap */
ZMK_MOCK_PRESS(0,1,400)
/* press the normal key */

View file

@ -11,8 +11,8 @@
flavor = "tap-preferred";
tapping-term-ms = <300>;
quick-tap-ms = <300>;
require-prior-idle-ms = <100>;
bindings = <&kp>, <&kp>;
global-quick-tap;
};
};

Some files were not shown because too many files have changed in this diff Show more