Skip to content

Global Variable in Rotary Encoder Library #3

Open
burck1 opened this Issue Feb 16, 2013 · 0 comments

1 participant

@burck1
burck1 commented Feb 16, 2013

Friday night I created and successfully tested 2 libraries, SimpleRotaryEncoder and RotaryEncoder. These libraries handle data logged from the rotary encoders on each wheel.

SimpleRotaryEncoder keeps track of a single sensor on a wheel (there are 2 total) and outputs the count of pulses recorded.

RotaryEncoder keeps track of both sensors. It outputs a count of the the number of pulses as well, but it will subtract from the count when the wheel is turned in reverse.

The issue I am having is the attachInterrupt function requires me to input a static function handle. So I had to create a wrapper method (_interruptHandler_wrapper) that uses a global variable to call the function. This means that if more than one RotaryEncoder/SimpleRotaryEncoder is created in the main program, only one works since they have the same global variables.

I need help getting rid of the global variables and and figuring out a different way to setup the interrupt handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.