add comments

This commit is contained in:
2023-10-12 22:15:24 +01:00
parent eb97dc0f60
commit a602f20e01
4 changed files with 50 additions and 31 deletions

View File

@@ -70,8 +70,12 @@ enum states get_current_state()
}
// doesn't have to be a fn anymore, but will be to maintain readability, expandability,
// compatibility with setup() fn
// also speed impact probably doesn't matter much since setup() runs once per boot
void initialiseEncoderStateMachine()
{
// gets current state (initial) state and sets it
state = get_current_state();
}
@@ -80,11 +84,12 @@ void updateEncoderStateMachine()
{
enum states new_state = get_current_state(); // get new state, don't update state yet so states can be compared
// check new state is valid, coming from state1, increment error count if not
// adjust count as appropriate if new state is valid
// repeat for all other state cases
switch (state)
{
case state1:
// check new state is valid, coming from state1, increment error count if not
// adjust count as appropriate if new state is valid
switch (new_state) {
case state1: break;
case state2: count++; break;