5#include <avr/interrupt.h>
13static volatile bool lastLeftA;
14static volatile bool lastLeftB;
15static volatile bool lastRightA;
16static volatile bool lastRightB;
18static volatile bool errorLeft;
19static volatile bool errorRight;
23static volatile uint16_t countLeft;
24static volatile uint16_t countRight;
31 countLeft += (newLeftA ^ lastLeftB) - (lastLeftA ^ newLeftB);
33 if((lastLeftA ^ newLeftA) & (lastLeftB ^ newLeftB))
47 countRight += (newRightA ^ lastRightB) - (lastRightA ^ newRightB);
49 if((lastRightA ^ newRightA) & (lastRightB ^ newRightB))
54 lastRightA = newRightA;
55 lastRightB = newRightB;
58void Zumo32U4Encoders::init2()
69 PCMSK0 = (1 << PCINT4);
75 attachInterrupt(4, rightISR, CHANGE);
96 int16_t counts = countLeft;
106 int16_t counts = countRight;
116 int16_t counts = countLeft;
127 int16_t counts = countRight;
137 bool error = errorLeft;
146 bool error = errorRight;
static void setInputPulledUp() __attribute__((always_inline))
Sets a pin to be a digital input with the internal pull-up resistor enabled.
static bool isInputHigh() __attribute__((always_inline))
Reads the input value of the pin.
static int16_t getCountsLeft()
static int16_t getCountsAndResetRight()
static int16_t getCountsAndResetLeft()
static bool checkErrorRight()
static bool checkErrorLeft()
static int16_t getCountsRight()