Since this project has rather many and sometimes even complex states it was much easier to design the Model and let Simulink worry about the actual coding. This approach seems more flexible and makes debugging a breeze.
Graphical Coding with Simulink and Stateflow
Button Logic, with a single push button you can invoke different actions
Software debouncing using stateflow was used to eliminate quirky (mostly analog) inputs.