This repository is a Zephyr module designed to be used with ZMK Firmware. It provides a custom, patched driver for ALPS EC11 incremental encoders.
Credits: The code in this module is predominantly taken from ZMK Pull Request #3409.
This patch has been turned into a standalone module so that users running older versions of ZMK (like v0.3) can have the benefit of the patch without needing to maintain their own complete fork of the ZMK repository.
The default ZMK EC11 driver can occasionally lose or drop rotational pulses. This happens because the original driver reads both pin states whenever any edge is detected; if the timing is slightly off or the signal coming from the EC11 is messy, a pulse can easily be lost.
This patch reworks the driver's logic so that only one pin (the "active" pin) has interrupts enabled at a time. When an edge is detected on this active pin, the driver assumes it has flipped and only reads the state of the inactive pin. By combining this reading with the previous state of the inactive pin, the driver accurately calculates the direction and magnitude of the pulse delta. This results in a much more reliable, skip-free scrolling experience.
To use this module, you need to add it to your ZMK configuration repository's west.yml file (usually located in the config/ directory).
Open your west.yml and add a new remote (pointing to the GitHub account hosting this repository) and add the module to the projects list.
manifest:
remotes:
- name: zmkfirmware
url-base: [https://github.com/zmkfirmware](https://github.com/zmkfirmware)
# Add the remote where this repository is hosted
- name: MickiusMousius
url-base: https://github.com/MickiusMousius
projects:
- name: zmk
remote: zmkfirmware
revision: main
import: app/west.yml
# Add this module
- name: zmk-patch-ec11
remote: MickiusMousius
revision: main
self:
path: config
Because this module uses the same devicetree bindings (compatible = "alps,ec11";) as the default ZMK driver, you do not need to change anything in your .dtsi or .keymap files. Your existing encoder definitions will continue to work perfectly.
However, to prevent build errors caused by multiple definitions, you must explicitly disable ZMK's built-in EC11 driver and enable this patched version.
Add the following lines to your keyboard's configuration file (e.g., config/your_keyboard.conf):
# Disable the built-in ZMK EC11 driver to prevent linker conflicts
CONFIG_EC11=n
# Enable the patched EC11 driver module
CONFIG_ZMK_PATCH_EC11=y
# (Optional) Trigger mode configurations using the new namespace:
# CONFIG_ZMK_PATCH_EC11_TRIGGER_GLOBAL_THREAD=y
# CONFIG_ZMK_PATCH_EC11_TRIGGER_OWN_THREAD=y
This project is licensed under the MIT License.