-
Sun 2019.07.07
I'll go out on a limb here for @barry_b_benson, myself and others @allObjects, as I/we may not have experience with state machines as you pointed out in #2 above. Although I/we get the pseudo code as presented, how might one code that suggestion?
EDIT: Isn't that what is done in #7 - How to improve?
ref: "In every state there is defined behavior which will only be executed when the object is in that state"
ref: https://guide.freecodecamp.org/software-engineering/design-patterns/finite-state-machine/
As said, make it a deterministic state machine, and you get rid of all the problems... and you also do not need a while or other loop to wait until something happens... this could actually make Espriuno irresponsive - freeze - because the loop holds on to the thread... and any other event will not be serve by Espruiono ('s JavaScript engine). ...loops are for arduinians... (event driven, 'open / logical' loops is to go for with Espruino).