mirror of
https://wiki.pbeirne.com/patb/cmt.git
synced 2026-12-03 12:05:20 -05:00
change side-by-side graphics to "display: flex" style
This commit is contained in:
+19
-17
@@ -238,7 +238,7 @@ Now let's look at how that information gets sent to the rest of the code:
|
|||||||
|
|
||||||
## newEvent()
|
## newEvent()
|
||||||
|
|
||||||
Here's a block diagram of the message flow 
|
Here's a block diagram of the message flow 
|
||||||
|
|
||||||
How do we send the information (events/messages) from the interrupt
|
How do we send the information (events/messages) from the interrupt
|
||||||
service routine to the
|
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.
|
The other task of this project simply flashes the LED on and off.
|
||||||
|
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
The code for this might be:
|
The code for this might be:
|
||||||
|
|
||||||
@@ -473,7 +473,7 @@ void ledTask(uint8 evt) {
|
|||||||
|
|
||||||
Perhaps a more accurate state diagram might be:
|
Perhaps a more accurate state diagram might be:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
As you build the code from the diagram, I *strongly* suggest that you use
|
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.
|
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
|
## Variations
|
||||||
|
|
||||||
<style>
|
|
||||||
.imageleft {float: left;}
|
|
||||||
.imageright {float: right;}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
Now that the infrastructure is in place, it's easy to expand or modify
|
Now that the infrastructure is in place, it's easy to expand or modify
|
||||||
the code for changes in the project definition.
|
the code for changes in the project definition.
|
||||||
|
|
||||||
For example, suppose we want the `respondToButtonTask()` to restart the
|
For example, suppose we want the `respondToButtonTask()` to restart the
|
||||||
LED timer on each key press:
|
LED timer on each key press:
|
||||||
|
|
||||||
{.imageleft}
|
<div style="display: flex;">
|
||||||
|
\
|
||||||
```C
|
```C
|
||||||
void rtbTask(uint8 event) {
|
void rtbTask(uint8 event) {
|
||||||
switch(rtbState) {
|
switch(rtbState) {
|
||||||
@@ -742,13 +737,14 @@ void rtbTask(uint8 event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
Or have a 2nd press of the button cause the LED to extinguish early:
|
Or have a 2nd press of the button cause the LED to extinguish early:
|
||||||
|
|
||||||
{.imageleft}
|
<div style="display: flex;">
|
||||||
|
\
|
||||||
```C
|
```C
|
||||||
void rtbTask(uint8 event) {
|
void rtbTask(uint8 event) {
|
||||||
switch(rtbState) {
|
switch(rtbState) {
|
||||||
@@ -774,6 +770,7 @@ void rtbTask(uint8 event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -781,7 +778,9 @@ void rtbTask(uint8 event) {
|
|||||||
How about have the button start a flash sequence, and a 2nd press stops
|
How about have the button start a flash sequence, and a 2nd press stops
|
||||||
it: (see also [substates](#substates))
|
it: (see also [substates](#substates))
|
||||||
|
|
||||||
{.imageright}
|
<div style="display: flex;">
|
||||||
|
|
||||||
|
\
|
||||||
|
|
||||||
```C
|
```C
|
||||||
void rtbTask(uint8 event) {
|
void rtbTask(uint8 event) {
|
||||||
@@ -822,7 +821,7 @@ void rtbTask(uint8 event) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
Each of these diagrams corresponds to trivial changes in the state code.
|
Each of these diagrams corresponds to trivial changes in the state code.
|
||||||
@@ -999,6 +998,7 @@ void taskWindow(char event, int windowIndex) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
</details>
|
</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.
|
Here is the state diagram.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
And here is the corresponding code.
|
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,
|
For things like flashing LED's, you could create two states,
|
||||||
and toggle between them, like this:
|
and toggle between them, like this:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
@@ -1614,7 +1614,8 @@ Alternatively, you could use the *timer counter*
|
|||||||
variable, and make changes at the half-way point through the count.
|
variable, and make changes at the half-way point through the count.
|
||||||
This simplifies the substate design to this:
|
This simplifies the substate design to this:
|
||||||
|
|
||||||
{.imageright}
|
<div style="display: flex;">
|
||||||
|
\
|
||||||
|
|
||||||
```C
|
```C
|
||||||
const uint16 FLASH_CYCLE_TIME 150;
|
const uint16 FLASH_CYCLE_TIME 150;
|
||||||
@@ -1651,6 +1652,7 @@ void rtbTaskCode(char event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
```
|
```
|
||||||
|
</div>
|
||||||
|
|
||||||
## State Machine Initialization
|
## State Machine Initialization
|
||||||
|
|
||||||
|
|||||||
@@ -96,10 +96,14 @@
|
|||||||
<item>void</item>
|
<item>void</item>
|
||||||
<item>int8_t</item>
|
<item>int8_t</item>
|
||||||
<item>int16_t</item>
|
<item>int16_t</item>
|
||||||
|
<item>int8</item>
|
||||||
|
<item>int16</item>
|
||||||
|
<item>int32</item>
|
||||||
<item>int32_t</item>
|
<item>int32_t</item>
|
||||||
<item>int64_t</item>
|
<item>int64_t</item>
|
||||||
<item>uint8</item>
|
<item>uint8</item>
|
||||||
<item>uint16</item>
|
<item>uint16</item>
|
||||||
|
<item>uint32</item>
|
||||||
<item>uint8_t</item>
|
<item>uint8_t</item>
|
||||||
<item>uint16_t</item>
|
<item>uint16_t</item>
|
||||||
<item>uint32_t</item>
|
<item>uint32_t</item>
|
||||||
|
|||||||
Reference in New Issue
Block a user