How pulsecoreengineering/pulsehsm works
PulseHSM is a small, allocation-free embedded hierarchical state-machine library. A user supplies a static state table and callbacks, starts the machine with begin(), then calls update() from the main loop; the runtime dispatches queued events, runs timed and per-state update behavior, and applies requested transitions with hierarchical entry/exit semantics. The graph emphasizes this runtime workflow and its internal state-table and transition machinery. README-described capabilities are included; source excerpts do not expose every helper implementation, so uncertain internal links are omitted.
Main entry points: PulseHSM.cpp Start machine · PulseHSM.h Static state table
Components 16
User interface
- Static state table
PulseHSM.h - Table validation
PulseHSM.h
HSM runtime
- PulseHSM instance
PulseHSM.h - Start machine
PulseHSM.cpp - Update scheduler
PulseHSM.cpp
State processing
- Active state cache
PulseHSM.cpp - Transition execution
PulseHSM.cpp - Hierarchy traversal
PulseHSM.cpp - State callbacks
PulseHSM.h - Timed transitions
PulseHSM.cpp
Event handling
- Event enqueue API
PulseHSM.cpp - Fixed event queue
PulseHSM.h - Event dispatch
PulseHSM.cpp - Interrupt protection
PulseHSM.h
Other components
- Embedded application
- Arduino timing
Connections 26
- Embedded application → Static state table: defines states
- Embedded application → Table validation: validates table
- Embedded application → Start machine: starts machine
- Embedded application → Update scheduler: ticks runtime
- Static state table → PulseHSM instance: configures
- Table validation → Static state table: checks structure
- Start machine → PulseHSM instance: initializes
- Start machine → Hierarchy traversal: resolves initial state
- Start machine → Active state cache: builds cache
- Start machine → State callbacks: runs entry actions
- Update scheduler → Event dispatch: dispatches events
- Update scheduler → Timed transitions: checks timeout
- Update scheduler → Active state cache: runs update chain
- Update scheduler → Transition execution: applies pending state
- Event enqueue API → Fixed event queue: enqueues event
- Event enqueue API → Interrupt protection: protects access
- Event dispatch → Fixed event queue: dequeues event
- Event dispatch → Hierarchy traversal: bubbles through
- Event dispatch → State callbacks: invokes handlers
- Transition execution → Hierarchy traversal: finds shared ancestor
- Transition execution → State callbacks: runs entry and exit
- Transition execution → Active state cache: refreshes cache
- Hierarchy traversal → Static state table: reads parent links
- Active state cache → Static state table: reads state rows
- Timed transitions → Arduino timing: reads elapsed time
- Start machine → Arduino timing: records entry time