2020 February 29 Breaking Changes Update (#8064)
[jackhill/qmk/firmware.git] / docs / feature_encoders.md
index cbf7291..4a0ae60 100644 (file)
@@ -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 `<keyboard>.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