From 70bf1230fa45dde5c91bf684f439bc1e88d4413c Mon Sep 17 00:00:00 2001 From: Pete Johanson Date: Wed, 6 May 2020 10:04:19 -0400 Subject: [PATCH] Tweak to use a chosen node for kscan device. --- .../petejohanson_handwire.overlay | 11 ++++++++--- src/main.c | 4 +++- src/zmk.h | 6 +++--- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay b/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay index 3a777a69..215531d2 100644 --- a/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay +++ b/boards/shields/petejohanson_handwire/petejohanson_handwire.overlay @@ -3,6 +3,7 @@ / { chosen { zmk,keymap = &keymap0; + zmk,kscan = &kscan0; }; layers { @@ -10,7 +11,11 @@ default: layer_0 { label = "Default"; - keys = ; + keys = + < + KC_A KC_B + KC_C KC_D + >; }; lower: layer_1 { @@ -31,9 +36,9 @@ layers = <&default &lower &raise>; }; - kscan { + kscan0: kscan { compatible = "gpio-kscan"; - label = "Handwired GPIO KSCAN matrix"; + label = "KSCAN"; diode-direction = "row2col"; row-gpios = <&arduino_header 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, diff --git a/src/main.c b/src/main.c index 33cf61de..8604989c 100644 --- a/src/main.c +++ b/src/main.c @@ -8,14 +8,16 @@ #include #include +#include "zmk.h" #include "kscan.h" #include "usb_hid.h" +#define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID) void main(void) { printk("Welcome to ZMK!\n"); - if (zmk_kscan_init(CONFIG_KSCAN_MATRIX_DEV_NAME) != 0) { + if (zmk_kscan_init(ZMK_KSCAN_DEV) != 0) { printk("Keyboard Scan Init Failed\n"); return; } diff --git a/src/zmk.h b/src/zmk.h index a5a5ff19..82ef3b6b 100644 --- a/src/zmk.h +++ b/src/zmk.h @@ -1,8 +1,8 @@ #ifndef ZMK_H #define ZMK_H -#define __ZMK_MATRIX_NODE_ID DT_PATH(kscan) -#define ZMK_MATRIX_ROWS DT_PROP_LEN(__ZMK_MATRIX_NODE_ID,row_gpios) -#define ZMK_MATRIX_COLS DT_PROP_LEN(__ZMK_MATRIX_NODE_ID,col_gpios) +#define ZMK_MATRIX_NODE_ID DT_CHOSEN(zmk_kscan) +#define ZMK_MATRIX_ROWS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,row_gpios) +#define ZMK_MATRIX_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios) #endif