5.1 State machines
Modelling behaviour as states and events, three ways to implement a machine in C, event-driven machines with run-to-completion, and hierarchical machines…
Lessons
- State machine fundamentals · States, events, transitions, actions, Mealy and Moore.
- State machine patterns in C · Switch, transition tables and state-function pointers compared.
- Event-driven state machines · From polling to events, queues and run-to-completion.
- Hierarchical state machines · Nested states, entry and exit actions, and statecharts.
Project: EV charging station controller
The controller of an electric-car charger, where a wrong state means power to a cable nobody paid for, or a plug pulled out live. Four labs, each a working part of the controller, checked in the page.