Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* returns change in encoder state (-1,0,1) */
- int8_t read_encoder()
- {
- static int8_t enc_states[] = {
- 0,-1,1,0,1,0,0,-1,-1,0,0,1,0,1,-1,0 };
- static uint8_t old_AB = 0;
- /**/
- old_AB <<= 2; //remember previous state
- old_AB |= ( ENC_PORT & 0x03 ); //add current state
- return ( enc_states[( old_AB & 0x0f )]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement