Firmware: Add support for rotary encoder

This commit is contained in:
Lexi / Zoe 2024-05-22 19:18:25 +02:00
parent 1a0e0c11c1
commit 79560566a1
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
4 changed files with 29 additions and 3 deletions

View File

@ -178,7 +178,6 @@ pcbs:
params: params:
from: "{{colrow}}" from: "{{colrow}}"
to: "{{row_net}}" to: "{{row_net}}"
# TODO: Check whether these pins are correct (should C really be GND?)
A: P3 A: P3
B: P4 B: P4
C: GND C: GND

View File

@ -13,7 +13,7 @@
"features": { "features": {
"bootmagic": true, "bootmagic": true,
"command": false, "command": false,
"console": false, "console": true,
"extrakey": true, "extrakey": true,
"mousekey": true, "mousekey": true,
"nkro": true, "nkro": true,
@ -55,6 +55,14 @@
] ]
} }
}, },
"encoder": {
"rotary": [
{
"pin_a": "D0",
"pin_b": "D4"
}
]
},
"rgb_matrix": { "rgb_matrix": {
"driver": "ws2812", "driver": "ws2812",
"default": { "default": {

View File

@ -28,10 +28,25 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
// Keyboard control layer for entering bootloader and controlling the RGB light (hold 0,4) // Keyboard control layer for entering bootloader and controlling the RGB light (hold 0,4)
[1] = LAYOUT_ortho_5x5( [1] = LAYOUT_ortho_5x5(
QK_BOOTLOADER, QK_REBOOT, _______, _______, QK_CLEAR_EEPROM, QK_BOOTLOADER, QK_REBOOT, QK_DEBUG_TOGGLE, _______, QK_CLEAR_EEPROM,
RGB_TOG, RGB_MODE_REVERSE, RGB_MODE_FORWARD, _______, _______, RGB_TOG, RGB_MODE_REVERSE, RGB_MODE_FORWARD, _______, _______,
RGB_VAI, RGB_SAI, RGB_HUI, RGB_SPI, _______, RGB_VAI, RGB_SAI, RGB_HUI, RGB_SPI, _______,
RGB_VAD, RGB_SAD, RGB_HUD, RGB_SPD, _______, RGB_VAD, RGB_SAD, RGB_HUD, RGB_SPD, _______,
RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW, RGB_MODE_SWIRL, _______ RGB_MODE_PLAIN, RGB_MODE_BREATHE, RGB_MODE_RAINBOW, RGB_MODE_SWIRL, _______
), ),
}; };
// Define mapping for rotary encoder
#if defined(ENCODER_MAP_ENABLE)
const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
// Default layer: Emulate scroll wheel
[0] = {
ENCODER_CCW_CW(KC_MS_WH_UP, KC_MS_WH_DOWN)
},
// Keyboard control layer: Control RGB LED brightness
[1] = {
ENCODER_CCW_CW(RGB_VAD, RGB_VAI)
}
};
#endif

View File

@ -1,2 +1,6 @@
# Enable support for rotary encoder
ENCODER_ENABLE = yes
ENCODER_MAP_ENABLE = yes
# Add custom RGB LED effects # Add custom RGB LED effects
RGB_MATRIX_CUSTOM_USER = yes RGB_MATRIX_CUSTOM_USER = yes