Volume as default encoder documentation example (#15678)

Co-authored-by: filterpaper <filterpaper@localhost>
master
Albert Y 2022-01-02 16:07:22 +08:00 committed by GitHub
parent f3c080b4b4
commit 6f043c5497
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 8 deletions

View File

@ -70,15 +70,15 @@ or `keymap.c`:
bool encoder_update_user(uint8_t index, bool clockwise) { bool encoder_update_user(uint8_t index, bool clockwise) {
if (index == 0) { /* First encoder */ if (index == 0) { /* First encoder */
if (clockwise) { if (clockwise) {
tap_code(KC_PGDN); tap_code_delay(KC_VOLU, 10);
} else { } else {
tap_code(KC_PGUP); tap_code_delay(KC_VOLD, 10);
} }
} else if (index == 1) { /* Second encoder */ } else if (index == 1) { /* Second encoder */
if (clockwise) { if (clockwise) {
tap_code(KC_DOWN); rgb_matrix_increase_hue();
} else { } else {
tap_code(KC_UP); rgb_matrix_decrease_hue();
} }
} }
return false; return false;
@ -100,9 +100,9 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} }
} else if (index == 1) { } else if (index == 1) {
if (clockwise) { if (clockwise) {
tap_code(KC_VOLU); tap_code_delay(KC_VOLU, 10);
} else { } else {
tap_code(KC_VOLD); tap_code_delay(KC_VOLD, 10);
} }
} }
} else { /* Layer 0 */ } else { /* Layer 0 */
@ -114,9 +114,9 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} }
} else if (index == 1) { } else if (index == 1) {
if (clockwise) { if (clockwise) {
tap_code(KC_DOWN); rgb_matrix_increase_speed();
} else { } else {
tap_code(KC_UP); rgb_matrix_decrease_speed();
} }
} }
} }
@ -124,6 +124,8 @@ bool encoder_update_user(uint8_t index, bool clockwise) {
} }
``` ```
?> Media and mouse countrol keycodes such as `KC_VOLU` and `KC_WH_D` requires `EXTRAKEY_ENABLE = yes` and `MOUSEKEY_ENABLE = yes` respectively in user's `rules.mk` if they are not enabled as default on keyboard level configuration.
## Hardware ## Hardware
The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground. The A an B lines of the encoders should be wired directly to the MCU, and the C/common lines should be wired to ground.