summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-07-16 01:40:54 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2019-07-19 10:25:26 +0900
commit3aced2b5c9bc14e2640acc4ba5cefd20d1a37be5 (patch)
treeede29caaccbdc077d687d1a2c812d30e67c02b94
parentce1b51be8bab049f8f53ce381889357b2c615696 (diff)
Remove the need to specify NUM_OF_ENCODERS for the Encoder feature (#6328)
* Remove the need to set NUM_OF_ENCODERS Instead, calculate the size of the array, and use that instead * Add hack for split common support * Remove NUM_OF_ENCODERS from keyboard config Can be reverted, if needed
-rw-r--r--keyboards/planck/ez/config.h1
-rw-r--r--quantum/encoder.c10
-rw-r--r--quantum/split_common/transport.c2
3 files changed, 6 insertions, 7 deletions
diff --git a/keyboards/planck/ez/config.h b/keyboards/planck/ez/config.h
index 4edd258eb9..d10510568e 100644
--- a/keyboards/planck/ez/config.h
+++ b/keyboards/planck/ez/config.h
@@ -43,7 +43,6 @@
#define MATRIX_ROW_PINS { A10, A9, A8, B15, C13, C14, C15, A2 }
#define MATRIX_COL_PINS { B11, B10, B2, B1, A7, B0 }
-#define NUMBER_OF_ENCODERS 1
#define ENCODERS_PAD_A { B12 }
#define ENCODERS_PAD_B { B13 }
diff --git a/quantum/encoder.c b/quantum/encoder.c
index ddf6234ab8..31f00c346b 100644
--- a/quantum/encoder.c
+++ b/quantum/encoder.c
@@ -25,16 +25,14 @@
#define ENCODER_RESOLUTION 4
#endif
-#ifndef NUMBER_OF_ENCODERS
- #error "Number of encoders not defined by NUMBER_OF_ENCODERS"
-#endif
-
#if !defined(ENCODERS_PAD_A) || !defined(ENCODERS_PAD_B)
#error "No encoder pads defined by ENCODERS_PAD_A and ENCODERS_PAD_B"
#endif
-static pin_t encoders_pad_a[NUMBER_OF_ENCODERS] = ENCODERS_PAD_A;
-static pin_t encoders_pad_b[NUMBER_OF_ENCODERS] = ENCODERS_PAD_B;
+
+#define NUMBER_OF_ENCODERS (sizeof(encoders_pad_a)/sizeof(pin_t))
+static pin_t encoders_pad_a[] = ENCODERS_PAD_A;
+static pin_t encoders_pad_b[] = ENCODERS_PAD_B;
static int8_t encoder_LUT[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
diff --git a/quantum/split_common/transport.c b/quantum/split_common/transport.c
index b32d48eb88..ba21d0c7b1 100644
--- a/quantum/split_common/transport.c
+++ b/quantum/split_common/transport.c
@@ -17,6 +17,8 @@
#ifdef ENCODER_ENABLE
# include "encoder.h"
+static pin_t encoders_pad[] = ENCODERS_PAD_A;
+# define NUMBER_OF_ENCODERS (sizeof(encoders_pad)/sizeof(pin_t))
#endif
#if defined(USE_I2C) || defined(EH)