]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
Add support for different encoder pinout for right half of split keyboard (#6521)
authorDanny <nooges@users.noreply.github.com>
Fri, 16 Aug 2019 23:46:41 +0000 (19:46 -0400)
committerDrashna Jaelre <drashna@live.com>
Fri, 16 Aug 2019 23:46:41 +0000 (16:46 -0700)
* Add support for different encoder pinouts for split keyboard

* Update documentation for new encoder pinout feature

docs/feature_encoders.md
docs/feature_split_keyboard.md
quantum/encoder.c

index bb2d538e7ef027075ac2159d9fdf85bd87460e95..cbf72914e9288626b0ba1a53ae4ed2733805013f 100644 (file)
@@ -20,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`:
index 4addb1bfd0f32323c4583d3a72fafab3a9d53f86..60e0d278c05acd8e066e3bf5db64ba8ff0187ce7 100644 (file)
@@ -166,6 +166,13 @@ This allows you to specify a different set of pins for the matrix on the right s
 
 This allows you to specify a different set of direct pins for the right side.
 
+```c
+#define ENCODERS_PAD_A_RIGHT { encoder1a, encoder2a }
+#define ENCODERS_PAD_B_RIGHT { encoder1b, encoder2b }
+```
+
+This allows you to specify a different set of encoder pins for the right side.
+
 ```c
 #define RGBLIGHT_SPLIT
 ```
index 31f00c346bad00bb257ed38da195b77f3150de06..10d8cf7da0f8b551231601501d9b9bf3bb48fda5 100644 (file)
@@ -16,6 +16,9 @@
  */
 
 #include "encoder.h"
+#ifdef SPLIT_KEYBOARD
+  #include "split_util.h"
+#endif
 
 // for memcpy
 #include <string.h>
@@ -54,6 +57,17 @@ void encoder_update_kb(int8_t index, bool clockwise) {
 }
 
 void encoder_init(void) {
+#if defined(SPLIT_KEYBOARD) && defined(ENCODERS_PAD_A_RIGHT) && defined(ENCODERS_PAD_B_RIGHT)
+  if (!isLeftHand) {
+    const pin_t encoders_pad_a_right[] = ENCODERS_PAD_A_RIGHT;
+    const pin_t encoders_pad_b_right[] = ENCODERS_PAD_B_RIGHT;
+    for (uint8_t i = 0; i < NUMBER_OF_ENCODERS; i++) {
+      encoders_pad_a[i] = encoders_pad_a_right[i];
+      encoders_pad_b[i] = encoders_pad_b_right[i];
+    }
+  }
+#endif
+
   for (int i = 0; i < NUMBER_OF_ENCODERS; i++) {
     setPinInputHigh(encoders_pad_a[i]);
     setPinInputHigh(encoders_pad_b[i]);