Exercise-003 Implementing STAT state
In this article, let’s implement the STAT state.
The requirement is when the application is in IDLE mode, pressing the START/PAUSE button should show the STAT for 1 sec and auto return to the IDLE mode.
When the application is in IDLE mode, pressing the START_PAUSE button should show the STAT. That’s why we have to define one Transition from IDLE to STAT, as shown in Figure 1.
We call it START_PAUSE. No guard, no action. When the STAT state is entered, it shows the productive time, and it also sends one message, and then it should auto return after 1 second to IDLE mode.
Let’s assume our application is in a STAT state. The STAT state doesn’t care for increment time event, decrement time event, it doesn’t care for START_PAUSE event, it also doesn’t care for Abort event. It displays something and then auto return after 1 second.
Let’s put one more Transition from STAT to IDLE (Figure 2). We call it a TIME_TICK event. Guard is events ‘ss’ parameter should be = 10 [e->ss == 10]. When this event happens, and if (ss=10), then that is an auto return to the IDLE mode.
We have completed the state machine diagram for our application.
FastBit Embedded Brain Academy Courses
Click here: https://fastbitlab.com/course1