Przeglądaj źródła

Remove the need to set NUM_OF_ENCODERS

Instead, calculate the size of the array, and use that instead
Drashna Jaelre 6 lat temu
rodzic
commit
54aa30c2ec
2 zmienionych plików z 4 dodań i 7 usunięć
  1. 0 1
      docs/feature_encoders.md
  2. 4 6
      quantum/encoder.c

+ 0 - 1
docs/feature_encoders.md

@@ -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 }
 

+ 4 - 6
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 };