Skip to content

Instantly share code, notes, and snippets.

@pietgeursen
Created October 23, 2017 07:08
Show Gist options
  • Save pietgeursen/9cba89b875813a6761f2e9504b9ce964 to your computer and use it in GitHub Desktop.
Save pietgeursen/9cba89b875813a6761f2e9504b9ce964 to your computer and use it in GitHub Desktop.
Quadrature decoder function.
int32_t get_quad_direction(uint32_t prev, uint32_t latest){
return ((prev >> 1) ^ (latest & 0b01)) == 1 ? -1 : 1;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment