.. include:: Firmware: Dedicated Thread For Timer Tick ========================================= .. image:: fsm-timer-tick-thread.svg :scale: 80% Plan ---- * Currently, FSM is responsible for generating its own events * Timer tick * Sensor burning * Operator button * Starting with timer tick: pull these out into ``main()`` * Semaphore * Periodic timer into ``main()`` |longrightarrow| *give* semaphore * Timer tick thread into main |longrightarrow| *take* semaphore (waiting for timer), and call *public* ``FSM::timer_tick()`` * *Ultimate goal:* remove ``FSM::start()`` and make FSM completely *passive* * |longrightarrow| Talk about testability ``main()``: Timer, And Timer Tick Thread ---------------------------------------- .. literalinclude:: code/main.cpp :caption: :download:`code/main.cpp` :language: c++ FSM: Much Smaller ----------------- .. literalinclude:: code/fsm.h :caption: :download:`code/fsm.h` :language: c++ .. literalinclude:: code/fsm.cpp :caption: :download:`code/fsm.cpp` :language: c++