Skip to content

Instantly share code, notes, and snippets.

/*
I am using Oleg's algorithm for reading an encoder using a lookup table, here:
https://www.circuitsathome.com/mcu/reading-rotary-encoder-on-arduino
But instead of this table of 16 bytes:
static int8_t enc_states[] = { 0, -1, 1, 0, 1, 0, 0, -1, -1, 0, 0, 1, 0, 1, -1, 0 };
I am using two tables of 8 bits each. The bits in these tables indicate sign bits and one bits
of the generated results. This takes advantage of the fact that I can easily encode 3 values