as quick feedback on this
// the possible states of the state-machine
typedef enum {
STATE_BEGIN_INPUT,
STATE_GETTING_ROTATION,
STATE_GETTING_SPEED,
STATE_OUTPUT_RS} states;
-
typedefis no longer needed. - by default enum entries are stored using an
int, which is two bytes. As you have very few and you don't care what value they hold, I would suggest to define them asbyte - semantically your
statesvariable only represent one state. so better practice to call thatstateorcurrentStatefor example
so would write this such
enum : byte {
STATE_BEGIN_INPUT,
STATE_GETTING_ROTATION,
STATE_GETTING_SPEED,
STATE_OUTPUT_RS} state;