diff options
Diffstat (limited to 'docs/feature_encoders.md')
-rw-r--r-- | docs/feature_encoders.md | 52 |
1 files changed, 34 insertions, 18 deletions
diff --git a/docs/feature_encoders.md b/docs/feature_encoders.md index cbf72914e..4a0ae60c3 100644 --- a/docs/feature_encoders.md +++ b/docs/feature_encoders.md | |||
@@ -2,23 +2,35 @@ | |||
2 | 2 | ||
3 | Basic encoders are supported by adding this to your `rules.mk`: | 3 | Basic encoders are supported by adding this to your `rules.mk`: |
4 | 4 | ||
5 | ENCODER_ENABLE = yes | 5 | ```make |
6 | ENCODER_ENABLE = yes | ||
7 | ``` | ||
6 | 8 | ||
7 | and this to your `config.h`: | 9 | and this to your `config.h`: |
8 | 10 | ||
9 | #define ENCODERS_PAD_A { B12 } | 11 | ```c |
10 | #define ENCODERS_PAD_B { B13 } | 12 | #define ENCODERS_PAD_A { B12 } |
13 | #define ENCODERS_PAD_B { B13 } | ||
14 | ``` | ||
11 | 15 | ||
12 | Each PAD_A/B variable defines an array so multiple encoders can be defined, e.g.: | 16 | Each PAD_A/B variable defines an array so multiple encoders can be defined, e.g.: |
13 | 17 | ||
14 | #define ENCODERS_PAD_A { encoder1a, encoder2a } | 18 | ```c |
15 | #define ENCODERS_PAD_B { encoder1b, encoder2b } | 19 | #define ENCODERS_PAD_A { encoder1a, encoder2a } |
20 | #define ENCODERS_PAD_B { encoder1b, encoder2b } | ||
21 | ``` | ||
22 | |||
23 | If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. They can also be flipped with a define: | ||
16 | 24 | ||
17 | If your encoder's clockwise directions are incorrect, you can swap the A & B pad definitions. | 25 | ```c |
26 | #define ENCODER_DIRECTION_FLIP | ||
27 | ``` | ||
18 | 28 | ||
19 | Additionally, the resolution can be specified in the same file (the default & suggested is 4): | 29 | Additionally, the resolution can be specified in the same file (the default & suggested is 4): |
20 | 30 | ||
21 | #define ENCODER_RESOLUTION 4 | 31 | ```c |
32 | #define ENCODER_RESOLUTION 4 | ||
33 | ``` | ||
22 | 34 | ||
23 | ## Split Keyboards | 35 | ## Split Keyboards |
24 | 36 | ||
@@ -33,27 +45,31 @@ If you are using different pinouts for the encoders on each half of a split keyb | |||
33 | 45 | ||
34 | The callback functions can be inserted into your `<keyboard>.c`: | 46 | The callback functions can be inserted into your `<keyboard>.c`: |
35 | 47 | ||
36 | void encoder_update_kb(uint8_t index, bool clockwise) { | 48 | ```c |
37 | encoder_update_user(index, clockwise); | 49 | void encoder_update_kb(uint8_t index, bool clockwise) { |
38 | } | 50 | encoder_update_user(index, clockwise); |
51 | } | ||
52 | ``` | ||
39 | 53 | ||
40 | or `keymap.c`: | 54 | or `keymap.c`: |
41 | 55 | ||
42 | void encoder_update_user(uint8_t index, bool clockwise) { | 56 | ```c |
43 | if (index == 0) { /* First encoder */ | 57 | void encoder_update_user(uint8_t index, bool clockwise) { |
58 | if (index == 0) { /* First encoder */ | ||
44 | if (clockwise) { | 59 | if (clockwise) { |
45 | tap_code(KC_PGDN); | 60 | tap_code(KC_PGDN); |
46 | } else { | 61 | } else { |
47 | tap_code(KC_PGUP); | 62 | tap_code(KC_PGUP); |
48 | } | 63 | } |
49 | } else if (index == 1) { /* Second encoder */ | 64 | } else if (index == 1) { /* Second encoder */ |
50 | if (clockwise) { | 65 | if (clockwise) { |
51 | tap_code(KC_UP); | 66 | tap_code(KC_DOWN); |
52 | } else { | 67 | } else { |
53 | tap_code(KC_DOWN); | 68 | tap_code(KC_UP); |
54 | } | 69 | } |
55 | } | ||
56 | } | 70 | } |
71 | } | ||
72 | ``` | ||
57 | 73 | ||
58 | ## Hardware | 74 | ## Hardware |
59 | 75 | ||