Trying to write non blocking code, failing

all the multi-element conditional statements makes the code hard to read and difficult to know what happens when

looks like you have a state machine (e.g. inProcess) that moves sequentially thru a set of states -- a "sequencer"

i believe the code would be easier to read/understand/debug/enhance if the various processing for each state were under a "switch (inProcess)" statement.
within each state, there can be conditional code for the various stimuli determining when to advance to the next state and what actions to take

detecting the stimuli should be outside the state machine blocks. i believe the various timing code can also be improved, possibly just a single piece of code that generates a single stim indicating the timer has expired

1 Like