From 26eef35f07698d23aafae90e1c230b52e100a334 Mon Sep 17 00:00:00 2001 From: James Young Date: Sat, 29 Feb 2020 12:00:00 -0800 Subject: 2020 February 29 Breaking Changes Update (#8064) --- docs/feature_encoders.md | 52 +++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 18 deletions(-) (limited to 'docs/feature_encoders.md') diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md index cbf72914e9..4a0ae60c31 100644 --- a/docs/feature_encoders.md +++ b/docs/feature_encoders.md @@ -2,23 +2,35 @@ Basic encoders are supported by adding this to your `rules.mk`: - ENCODER_ENABLE = yes +```make +ENCODER_ENABLE = yes +``` and this to your `config.h`: - #define ENCODERS_PAD_A { B12 } - #define ENCODERS_PAD_B { B13 } +```c +#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 { encoder1b, encoder2b } +```c +#define ENCODERS_PAD_A { encoder1a, encoder2a } +#define ENCODERS_PAD_B { encoder1b, encoder2b } +``` + +If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. They can also be flipped with a define: -If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. +```c +#define ENCODER_DIRECTION_FLIP +``` Additionally, the resolution can be specified in the same file (the default & suggested is 4): - #define ENCODER_RESOLUTION 4 +```c +#define ENCODER_RESOLUTION 4 +``` ## Split Keyboards @@ -33,27 +45,31 @@ If you are using different pinouts for the encoders on each half of a split keyb The callback functions can be inserted into your `.c`: - void encoder_update_kb(uint8_t index, bool clockwise) { - encoder_update_user(index, clockwise); - } +```c +void encoder_update_kb(uint8_t index, bool clockwise) { + encoder_update_user(index, clockwise); +} +``` or `keymap.c`: - void encoder_update_user(uint8_t index, bool clockwise) { - if (index == 0) { /* First encoder */ +```c +void encoder_update_user(uint8_t index, bool clockwise) { + if (index == 0) { /* First encoder */ if (clockwise) { - tap_code(KC_PGDN); + tap_code(KC_PGDN); } else { - tap_code(KC_PGUP); + tap_code(KC_PGUP); } - } else if (index == 1) { /* Second encoder */ + } else if (index == 1) { /* Second encoder */ if (clockwise) { - tap_code(KC_UP); + tap_code(KC_DOWN); } else { - tap_code(KC_DOWN); + tap_code(KC_UP); } - } } +} +``` ## Hardware -- cgit v1.2.3