PMW3610 driver implementation for ZMK
This work is based on ufan's zmk pixart sensor drivers and inorichi's zmk-pmw3610-driver.
Include this project on ZMK's west manifest in config/west.yml
:
manifest:
remotes:
- name: zmkfirmware
url-base: https://github.com/petejohanson
- name: badjeff
url-base: https://github.com/badjeff
projects:
- name: zmk
remote: zmkfirmware
revision: feat/pointers-move-scroll
import: app/west.yml
- name: zmk-pmw3610-driver
remote: badjeff
revision: main
self:
path: config
Update board.overlay
adding the necessary bits (update the pins for your board accordingly):
&pinctrl {
spi0_default: spi0_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
};
};
spi0_sleep: spi0_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 0, 8)>,
<NRF_PSEL(SPIM_MOSI, 0, 17)>,
<NRF_PSEL(SPIM_MISO, 0, 17)>;
low-power-enable;
};
};
};
&spi0 {
status = "okay";
compatible = "nordic,nrf-spim";
pinctrl-0 = <&spi0_default>;
pinctrl-1 = <&spi0_sleep>;
pinctrl-names = "default", "sleep";
cs-gpios = <&gpio0 20 GPIO_ACTIVE_LOW>;
trackball: trackball@0 {
status = "okay";
compatible = "pixart,pmw3610";
reg = <0>;
spi-max-frequency = <2000000>;
irq-gpios = <&gpio0 6 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
cpi = <600>;
evt-type = <INPUT_EV_REL>;
x-input-code = <INPUT_REL_X>;
y-input-code = <INPUT_REL_Y>;
};
};
/ {
trackball_listener {
compatible = "zmk,input-listener";
device = <&trackball>;
};
};
Enable the driver config in <shield>.config
file (read the Kconfig file to find out all possible options):
CONFIG_SPI=y
CONFIG_INPUT=y
CONFIG_ZMK_MOUSE=y
CONFIG_PMW3610=y
# CONFIG_PMW3610_SWAP_XY=y
# CONFIG_PMW3610_INVERT_X=y
# CONFIG_PMW3610_INVERT_Y=y
# CONFIG_PMW3610_REPORT_INTERVAL_MIN=12
# CONFIG_PMW3610_LOG_LEVEL_DBG=y