change side-by-side graphics to "display: flex" style

This commit is contained in:
2025-01-22 23:50:35 -05:00
parent f83c0bc355
commit e487e5b1aa
2 changed files with 23 additions and 17 deletions
+19 -17
View File
@@ -238,7 +238,7 @@ Now let's look at how that information gets sent to the rest of the code:
## newEvent()
Here's a block diagram of the message flow ![](dispatch1.jpg)
Here's a block diagram of the message flow ![message flow](dispatch1.jpg)
How do we send the information (events/messages) from the interrupt
service routine to the
@@ -433,7 +433,7 @@ discussion about [shared timers](#timers-as-a-resource)
The other task of this project simply flashes the LED on and off.
![](led_state_simple.png)
![LED state machine, basic](led_state_simple.png)
The code for this might be:
@@ -473,7 +473,7 @@ void ledTask(uint8 evt) {
Perhaps a more accurate state diagram might be:
![](led_state.png)
![LED state machine, alternate](led_state.png)
As you build the code from the diagram, I *strongly* suggest that you use
a `switch(currentState) ....case STATE_1` approach to the task routine.
@@ -705,19 +705,14 @@ easily handle *dozens* of tasks, even on sub-$1 processors.
## Variations
<style>
.imageleft {float: left;}
.imageright {float: right;}
</style>
Now that the infrastructure is in place, it's easy to expand or modify
the code for changes in the project definition.
For example, suppose we want the `respondToButtonTask()` to restart the
LED timer on each key press:
![](rtb_state_2.png){.imageleft}
<div style="display: flex;">
![RTB (respond to button) state machine, with restart](rtb_state_2.png)\
```C
void rtbTask(uint8 event) {
switch(rtbState) {
@@ -742,13 +737,14 @@ void rtbTask(uint8 event) {
}
}
```
</div>
<hr>
Or have a 2nd press of the button cause the LED to extinguish early:
![](rtb_state_3.png){.imageleft}
<div style="display: flex;">
![RTB state machine, with early-off](rtb_state_3.png)\
```C
void rtbTask(uint8 event) {
switch(rtbState) {
@@ -774,6 +770,7 @@ void rtbTask(uint8 event) {
}
}
```
</div>
<hr>
@@ -781,7 +778,9 @@ void rtbTask(uint8 event) {
How about have the button start a flash sequence, and a 2nd press stops
it: (see also [substates](#substates))
![](rtb_state_4.png){.imageright}
<div style="display: flex;">
![RTB state machine, push to stop](rtb_state_4.png)\
```C
void rtbTask(uint8 event) {
@@ -822,7 +821,7 @@ void rtbTask(uint8 event) {
}
}
```
</div>
<hr>
Each of these diagrams corresponds to trivial changes in the state code.
@@ -999,6 +998,7 @@ void taskWindow(char event, int windowIndex) {
}
}
```
</details>
@@ -1014,7 +1014,7 @@ and turn off the light and alarm. And if the door closes during the 90 seconds,
Here is the state diagram.
![](fridge_state.png)
![fridge state machine](fridge_state.png)
And here is the corresponding code.
@@ -1596,7 +1596,7 @@ void (*myvectors[])(void) __attribute__ ((section(".vectors")))= {
For things like flashing LED's, you could create two states,
and toggle between them, like this:
![](rtb_state_4.png)
![RTB state machine, with substates](rtb_state_4.png)
<hr>
@@ -1614,7 +1614,8 @@ Alternatively, you could use the *timer counter*
variable, and make changes at the half-way point through the count.
This simplifies the substate design to this:
![](rtb_state_5.png){.imageright}
<div style="display: flex;">
![RTB state machine, with substates](rtb_state_5.png)\
```C
const uint16 FLASH_CYCLE_TIME 150;
@@ -1651,6 +1652,7 @@ void rtbTaskCode(char event) {
}
```
</div>
## State Machine Initialization
+4
View File
@@ -96,10 +96,14 @@
<item>void</item>
<item>int8_t</item>
<item>int16_t</item>
<item>int8</item>
<item>int16</item>
<item>int32</item>
<item>int32_t</item>
<item>int64_t</item>
<item>uint8</item>
<item>uint16</item>
<item>uint32</item>
<item>uint8_t</item>
<item>uint16_t</item>
<item>uint32_t</item>