Browse Source

Tweak to use a chosen node for kscan device.

xmkb
Pete Johanson 5 years ago
parent
commit
70bf1230fa
  1. 11
      boards/shields/petejohanson_handwire/petejohanson_handwire.overlay
  2. 4
      src/main.c
  3. 6
      src/zmk.h

11
boards/shields/petejohanson_handwire/petejohanson_handwire.overlay

@ -3,6 +3,7 @@
/ { / {
chosen { chosen {
zmk,keymap = &keymap0; zmk,keymap = &keymap0;
zmk,kscan = &kscan0;
}; };
layers { layers {
@ -10,7 +11,11 @@
default: layer_0 { default: layer_0 {
label = "Default"; label = "Default";
keys = <KC_A KC_B KC_C KC_D>; keys =
<
KC_A KC_B
KC_C KC_D
>;
}; };
lower: layer_1 { lower: layer_1 {
@ -31,9 +36,9 @@
layers = <&default &lower &raise>; layers = <&default &lower &raise>;
}; };
kscan { kscan0: kscan {
compatible = "gpio-kscan"; compatible = "gpio-kscan";
label = "Handwired GPIO KSCAN matrix"; label = "KSCAN";
diode-direction = "row2col"; diode-direction = "row2col";
row-gpios = <&arduino_header 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>, row-gpios = <&arduino_header 8 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>,

4
src/main.c

@ -8,14 +8,16 @@
#include <device.h> #include <device.h>
#include <devicetree.h> #include <devicetree.h>
#include "zmk.h"
#include "kscan.h" #include "kscan.h"
#include "usb_hid.h" #include "usb_hid.h"
#define ZMK_KSCAN_DEV DT_LABEL(ZMK_MATRIX_NODE_ID)
void main(void) void main(void)
{ {
printk("Welcome to ZMK!\n"); 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"); printk("Keyboard Scan Init Failed\n");
return; return;
} }

6
src/zmk.h

@ -1,8 +1,8 @@
#ifndef ZMK_H #ifndef ZMK_H
#define ZMK_H #define ZMK_H
#define __ZMK_MATRIX_NODE_ID DT_PATH(kscan) #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_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_COLS DT_PROP_LEN(ZMK_MATRIX_NODE_ID,col_gpios)
#endif #endif

Loading…
Cancel
Save