I'm trying to implement a FSM which handles a button in the following way:
When in Standby mode, it just waits for button to get pressed.
When it is pressed, it moves to intButtonPress state, where a 2 second timer is started. If it times out, it means that the button was held for 2 seconds and the next state must be Action. If the button is released before timeout, state returns to Standby as the button wasn't held long enough.
When in Action mode, some action is performed, but it can be interrupted by the button press. Problem is that i can't reuse intButtonPress state since it's timeout transition would lead back to Action state, so an obvious solution is to use an identical state whose only difference is that it leads to Standby state, but it's ugly.
Are there better ways to handle this?
FSM is here: https://i.sstatic.net/BpRMJ.png (can't embed pictures)
Answering my own question - use hierarchical state machines: https://i.sstatic.net/rlVHd.png
Super-Standby state is not strictly needed.