]> git.donarmstrong.com Git - qmk_firmware.git/blobdiff - docs/feature_encoders.md
Removed prescaler define from avr i2c, as it was impossible to use (#6617)
[qmk_firmware.git] / docs / feature_encoders.md
index 208d6db13cddcce222a18a7d1c459b214b20d962..cbf72914e9288626b0ba1a53ae4ed2733805013f 100644 (file)
@@ -6,7 +6,6 @@ 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 }
 
@@ -21,6 +20,15 @@ Additionally, the resolution can be specified in the same file (the default & su
 
     #define ENCODER_RESOLUTION 4
 
+## Split Keyboards
+
+If you are using different pinouts for the encoders on each half of a split keyboard, you can define the pinout for the right half like this:
+
+```c
+#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
+#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
+```
+
 ## Callbacks
 
 The callback functions can be inserted into your `<keyboard>.c`:
@@ -32,15 +40,19 @@ The callback functions can be inserted into your `<keyboard>.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