X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=docs%2Ffeature_encoders.md;h=bb2d538e7ef027075ac2159d9fdf85bd87460e95;hb=6af77551c67c846b06c596cbd367d66c755f8051;hp=036c6a1d8961485d59de2917b9a224e1a6b10672;hpb=24b3556e844ec76813a42ce4c5b7a77a6f874d5a;p=qmk_firmware.git diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md index 036c6a1d8..bb2d538e7 100644 --- a/docs/feature_encoders.md +++ b/docs/feature_encoders.md @@ -6,14 +6,13 @@ Basic encoders are supported by adding this to your `rules.mk`: and this to your `config.h`: - #define NUMBER_OF_ENCODERS 1 #define ENCODERS_PAD_A { B12 } #define ENCODERS_PAD_B { B13 } Each PAD_A/B variable defines an array so multiple encoders can be defined, e.g.: #define ENCODERS_PAD_A { encoder1a, encoder2a } - #define ENCODERS_PAD_B { encoder1a, encoder2b } + #define ENCODERS_PAD_B { encoder1b, encoder2b } If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. @@ -32,15 +31,19 @@ The callback functions can be inserted into your `.c`: or `keymap.c`: void encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { - if (clockwise) { - register_code(KC_PGDN); - unregister_code(KC_PGDN); - } else { - register_code(KC_PGUP); - unregister_code(KC_PGUP); - } + if (index == 0) { /* First encoder */ + if (clockwise) { + tap_code(KC_PGDN); + } else { + tap_code(KC_PGUP); } + } else if (index == 1) { /* Second encoder */ + if (clockwise) { + tap_code(KC_UP); + } else { + tap_code(KC_DOWN); + } + } } ## Hardware