brianmichalk
Active member
Using quadrature Encoder library, v1.3, Teensy3.2.
I thought I would be clever with a macro definition to get around the requirement of
defining the encoder A/B pins at compile time. The problem is that a supplier
swapped the encoder lines on a motor I'm using, so I added a solder pad that when
shorted, would inform the firmware whether to reverse the pins.
It looks like the macro extension is not supported:
#define REVERSE_PIN 9 // if pin 9 is grounded, then reverse the encoder pin A/B
#define ENCODER_A_PIN ({ \
int i = 0;\
pinMode(REVERSE_PIN, INPUT_PULLUP);\
delay(10);\
if (digitalRead(REVERSE_PIN)==LOW) { i=1;}\
i;\
})
I can modify the library, and will do so. I am wondering if there is a better way to do this.
I thought I would be clever with a macro definition to get around the requirement of
defining the encoder A/B pins at compile time. The problem is that a supplier
swapped the encoder lines on a motor I'm using, so I added a solder pad that when
shorted, would inform the firmware whether to reverse the pins.
It looks like the macro extension is not supported:
#define REVERSE_PIN 9 // if pin 9 is grounded, then reverse the encoder pin A/B
#define ENCODER_A_PIN ({ \
int i = 0;\
pinMode(REVERSE_PIN, INPUT_PULLUP);\
delay(10);\
if (digitalRead(REVERSE_PIN)==LOW) { i=1;}\
i;\
})
I can modify the library, and will do so. I am wondering if there is a better way to do this.