Compare commits
17 Commits
3f1ce81ad5
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 34f4799c2f | |||
|
|
5ab2981ba2 | ||
|
|
b35e6e6a22 | ||
|
|
72f43d9060 | ||
|
|
d48fb874c1 | ||
|
|
2a155fd752 | ||
|
|
3d1c318b19 | ||
|
|
aeb2554e95 | ||
|
|
70f80452fc | ||
| 14cb929b7c | |||
| b428b0cd76 | |||
| 1f091485ac | |||
| 75aa68bae2 | |||
| 744051f61f | |||
| 8cc4c9089f | |||
| ffc2f67b53 | |||
| 06ad7c948b |
BIN
01-task_description/SWESemesterProject.pdf
Normal file
BIN
01-task_description/SWESemesterProject.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/Deployement.pdf
Normal file
BIN
02-UML/PDF/Deployement.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/ST_APP.pdf
Normal file
BIN
02-UML/PDF/ST_APP.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/ST_BLINKER.pdf
Normal file
BIN
02-UML/PDF/ST_BLINKER.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/ST_BUTTON.pdf
Normal file
BIN
02-UML/PDF/ST_BUTTON.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/ST_CLICK_HANDLER.pdf
Normal file
BIN
02-UML/PDF/ST_CLICK_HANDLER.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/Sequence.pdf
Normal file
BIN
02-UML/PDF/Sequence.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/UseCase.pdf
Normal file
BIN
02-UML/PDF/UseCase.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/class.pdf
Normal file
BIN
02-UML/PDF/class.pdf
Normal file
Binary file not shown.
BIN
02-UML/PDF/testDiagram.pdf
Normal file
BIN
02-UML/PDF/testDiagram.pdf
Normal file
Binary file not shown.
226
02-UML/ST_APP.uxf
Normal file
226
02-UML/ST_APP.uxf
Normal file
@@ -0,0 +1,226 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="15.1">
|
||||
<zoom_level>12</zoom_level>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>936</x>
|
||||
<y>168</y>
|
||||
<w>24</w>
|
||||
<h>24</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=initial</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>564</x>
|
||||
<y>228</y>
|
||||
<w>768</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>WAIT</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>936</x>
|
||||
<y>180</y>
|
||||
<w>36</w>
|
||||
<h>72</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=-></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>564</x>
|
||||
<y>384</y>
|
||||
<w>168</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_BLINKER_L</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>1188</x>
|
||||
<y>384</y>
|
||||
<w>144</w>
|
||||
<h>288</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_BLINKER_W</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>852</x>
|
||||
<y>504</y>
|
||||
<w>168</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_BLINKER_R</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1248</x>
|
||||
<y>264</y>
|
||||
<w>120</w>
|
||||
<h>144</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<->
|
||||
evLongClick</panel_attributes>
|
||||
<additional_attributes>10.0;100.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>564</x>
|
||||
<y>624</y>
|
||||
<w>456</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_BLINKER_LR</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1008</x>
|
||||
<y>636</y>
|
||||
<w>204</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evLongClick</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;150.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1008</x>
|
||||
<y>516</y>
|
||||
<w>204</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evLongClick</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;150.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>720</x>
|
||||
<y>396</y>
|
||||
<w>492</w>
|
||||
<h>48</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evLongClick</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;390.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>576</x>
|
||||
<y>264</y>
|
||||
<w>120</w>
|
||||
<h>144</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickL(n)</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;100.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>264</y>
|
||||
<w>168</w>
|
||||
<h>144</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickL / evEndL
|
||||
</panel_attributes>
|
||||
<additional_attributes>10.0;100.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>576</x>
|
||||
<y>420</y>
|
||||
<w>120</w>
|
||||
<h>228</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickR(n)</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;170.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>696</x>
|
||||
<y>420</y>
|
||||
<w>180</w>
|
||||
<h>228</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickR / evEndR</panel_attributes>
|
||||
<additional_attributes>10.0;170.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>864</x>
|
||||
<y>264</y>
|
||||
<w>120</w>
|
||||
<h>264</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickR(n)</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;200.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>984</x>
|
||||
<y>264</y>
|
||||
<w>180</w>
|
||||
<h>264</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickR / evEndR</panel_attributes>
|
||||
<additional_attributes>10.0;200.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>864</x>
|
||||
<y>540</y>
|
||||
<w>120</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickL(n)</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>984</x>
|
||||
<y>540</y>
|
||||
<w>168</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evClickL / evEndL</panel_attributes>
|
||||
<additional_attributes>10.0;70.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
183
02-UML/ST_BLINKER.uxf
Normal file
183
02-UML/ST_BLINKER.uxf
Normal file
@@ -0,0 +1,183 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="15.1">
|
||||
<zoom_level>17</zoom_level>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>646</x>
|
||||
<y>51</y>
|
||||
<w>34</w>
|
||||
<h>34</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=initial</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>646</x>
|
||||
<y>68</y>
|
||||
<w>153</w>
|
||||
<h>153</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evBLInit</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>510</x>
|
||||
<y>187</y>
|
||||
<w>306</w>
|
||||
<h>85</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_WAIT
|
||||
--
|
||||
remainBlinks = 3;</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>510</x>
|
||||
<y>374</y>
|
||||
<w>306</w>
|
||||
<h>102</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_ON
|
||||
--
|
||||
if(blink3) remainBlinks--
|
||||
-.
|
||||
/ entry: turnOn()</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>646</x>
|
||||
<y>459</y>
|
||||
<w>153</w>
|
||||
<h>136</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evTimer</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;60.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>544</x>
|
||||
<y>561</y>
|
||||
<w>238</w>
|
||||
<h>102</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_OFF
|
||||
--
|
||||
-.
|
||||
/ entry: turnOff()</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>646</x>
|
||||
<y>646</y>
|
||||
<w>153</w>
|
||||
<h>153</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evTimer</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>527</x>
|
||||
<y>255</y>
|
||||
<w>272</w>
|
||||
<h>153</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evBlinkN
|
||||
m2=/ nBlinkIsOn = true</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>765</x>
|
||||
<y>255</y>
|
||||
<w>289</w>
|
||||
<h>153</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evBlink
|
||||
m2=/ nBlinkIsOn = false</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>629</x>
|
||||
<y>765</y>
|
||||
<w>68</w>
|
||||
<h>68</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>442</x>
|
||||
<y>408</y>
|
||||
<w>221</w>
|
||||
<h>442</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[else]</panel_attributes>
|
||||
<additional_attributes>110.0;230.0;10.0;230.0;10.0;10.0;40.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>680</x>
|
||||
<y>204</y>
|
||||
<w>391</w>
|
||||
<h>646</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[remainBlinks==0]</panel_attributes>
|
||||
<additional_attributes>10.0;350.0;210.0;350.0;210.0;10.0;80.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>1462</x>
|
||||
<y>0</y>
|
||||
<w>952</w>
|
||||
<h>527</h>
|
||||
</coordinates>
|
||||
<panel_attributes>BLINKER
|
||||
--
|
||||
+state: BLINKER_STATES
|
||||
+tON: uint16_t
|
||||
+tOFF: uint16_t
|
||||
+blink3: bool
|
||||
+nBlink: uint8_t
|
||||
+turnOn: blinkerCallBack
|
||||
+turnOff: blinkerCallBack
|
||||
--
|
||||
+BLINKER_init(me: BLINKER*): void
|
||||
+BLINKER_defineCallBack(f: fBlinkerCallBack, param: void*): blinkerCallBack
|
||||
+BLINKER_starBehaviour(me: BLINKER*): void
|
||||
+BLINKER_setTurnOn(me: BLINKER*, callBack: blinkerCallBack): void
|
||||
+BLINKER_setTurnOff(me: BLINKER*, callBack: blinkerCallBack): void
|
||||
+BLINKER_blink3(me: BLINKER*): void
|
||||
+BLINKER_blink(me: BLINKER*): void
|
||||
+BLINKER_processEvent(mev: Event*): bool
|
||||
+BLINKER_endBlink(me: BLINKER*): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
191
02-UML/ST_BUTTON.uxf
Normal file
191
02-UML/ST_BUTTON.uxf
Normal file
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="15.1">
|
||||
<zoom_level>20</zoom_level>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>860</x>
|
||||
<y>80</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=initial</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>380</x>
|
||||
<y>400</y>
|
||||
<w>280</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_PBPRESSED</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>1100</x>
|
||||
<y>400</y>
|
||||
<w>280</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_PBRELEASED</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1220</x>
|
||||
<y>460</y>
|
||||
<w>180</w>
|
||||
<h>240</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBPoll</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;100.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>860</x>
|
||||
<y>100</y>
|
||||
<w>180</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBInit</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>840</x>
|
||||
<y>240</y>
|
||||
<w>80</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>500</x>
|
||||
<y>260</y>
|
||||
<w>380</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[pB==1]</panel_attributes>
|
||||
<additional_attributes>170.0;10.0;10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>500</x>
|
||||
<y>460</y>
|
||||
<w>180</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBPoll</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>900</x>
|
||||
<y>260</y>
|
||||
<w>380</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[pB==0]</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;170.0;10.0;170.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>480</x>
|
||||
<y>600</y>
|
||||
<w>80</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>1200</x>
|
||||
<y>660</y>
|
||||
<w>80</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=decision</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>580</x>
|
||||
<y>320</y>
|
||||
<w>660</w>
|
||||
<h>440</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[pB==1] / pbPress()</panel_attributes>
|
||||
<additional_attributes>310.0;190.0;260.0;190.0;40.0;10.0;10.0;10.0;10.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>540</x>
|
||||
<y>320</y>
|
||||
<w>660</w>
|
||||
<h>380</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
|
||||
m1=[pB==0] / pbRelease()</panel_attributes>
|
||||
<additional_attributes>10.0;160.0;60.0;160.0;280.0;10.0;310.0;10.0;310.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>300</x>
|
||||
<y>320</y>
|
||||
<w>220</w>
|
||||
<h>380</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[else]</panel_attributes>
|
||||
<additional_attributes>90.0;160.0;10.0;160.0;10.0;10.0;70.0;10.0;70.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>1260</x>
|
||||
<y>320</y>
|
||||
<w>220</w>
|
||||
<h>440</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=[else]</panel_attributes>
|
||||
<additional_attributes>10.0;190.0;90.0;190.0;90.0;10.0;30.0;10.0;30.0;40.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLNote</id>
|
||||
<coordinates>
|
||||
<x>700</x>
|
||||
<y>760</y>
|
||||
<w>400</w>
|
||||
<h>100</h>
|
||||
</coordinates>
|
||||
<panel_attributes>pbRelease() & pbPress()
|
||||
are CallBack Functions</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
</diagram>
|
||||
155
02-UML/ST_CLICK_HANDLER.uxf
Normal file
155
02-UML/ST_CLICK_HANDLER.uxf
Normal file
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="15.1">
|
||||
<zoom_level>20</zoom_level>
|
||||
<element>
|
||||
<id>UMLSpecialState</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>20</y>
|
||||
<w>40</w>
|
||||
<h>40</h>
|
||||
</coordinates>
|
||||
<panel_attributes>type=initial</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>40</y>
|
||||
<w>160</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evCHInit</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>400</x>
|
||||
<y>180</y>
|
||||
<w>280</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_WAIT</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>240</y>
|
||||
<w>200</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBPress</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>440</y>
|
||||
<w>220</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBRelease</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>360</x>
|
||||
<y>380</y>
|
||||
<w>360</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_LONG_CLICK</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>360</x>
|
||||
<y>580</y>
|
||||
<w>360</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_SINGLE_CLICK</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLState</id>
|
||||
<coordinates>
|
||||
<x>360</x>
|
||||
<y>780</y>
|
||||
<w>360</w>
|
||||
<h>80</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ST_DOUBLE_CLICK</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>520</x>
|
||||
<y>640</y>
|
||||
<w>200</w>
|
||||
<h>180</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
evPBPress</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;70.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>660</x>
|
||||
<y>200</y>
|
||||
<w>560</w>
|
||||
<h>280</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evCHtimer / chLongClick()</panel_attributes>
|
||||
<additional_attributes>30.0;110.0;260.0;110.0;260.0;10.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>660</x>
|
||||
<y>200</y>
|
||||
<w>560</w>
|
||||
<h>480</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evCHtimer / chSingleClick()</panel_attributes>
|
||||
<additional_attributes>30.0;210.0;260.0;210.0;260.0;10.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>660</x>
|
||||
<y>200</y>
|
||||
<w>560</w>
|
||||
<h>660</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evCHtimer / chDoubleClick()</panel_attributes>
|
||||
<additional_attributes>30.0;300.0;260.0;300.0;260.0;10.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>660</x>
|
||||
<y>200</y>
|
||||
<w>560</w>
|
||||
<h>700</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=->
|
||||
m1=evPBRelease / chDoubleClick()</panel_attributes>
|
||||
<additional_attributes>30.0;320.0;260.0;320.0;260.0;10.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
File diff suppressed because it is too large
Load Diff
408
02-UML/class.uxf
Normal file
408
02-UML/class.uxf
Normal file
@@ -0,0 +1,408 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<diagram program="umlet" version="15.1">
|
||||
<zoom_level>9</zoom_level>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>45</x>
|
||||
<y>603</y>
|
||||
<w>279</w>
|
||||
<h>216</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Button
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
- id: uint8_t
|
||||
- state: STATE
|
||||
- press: callBack
|
||||
- release: callBack
|
||||
--
|
||||
+ init(uint8_t id): void
|
||||
+ init_HW(): void
|
||||
+ defineCallBack(fCallBack f, void* p): callBack
|
||||
+ setPressCallBack(callBack c): void
|
||||
+ setReleaseCallBack(callBack c): void
|
||||
+ isPressed(): void
|
||||
+ startBehaviour(): void
|
||||
+ processEvent(Event* ev): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>783</x>
|
||||
<y>495</y>
|
||||
<w>279</w>
|
||||
<h>243</h>
|
||||
</coordinates>
|
||||
<panel_attributes>ClickHandler
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
- state: STATE
|
||||
- longClick: callBack
|
||||
- singleClick: callBack
|
||||
- doubleClick: callBack
|
||||
--
|
||||
+ init(Button b): void
|
||||
+ defineCallBack(fCallBack f, void* p): callBack
|
||||
+ startBehaviour(): void
|
||||
+ setLongClickCallBack(callBack c): void
|
||||
+ setSingleClickCallBack(callBack c): void
|
||||
+ setDoubleClickCallBack(callBack c): void
|
||||
+ processEvent(Event* ev): bool
|
||||
-.
|
||||
- buttonPress(): void
|
||||
- buttonRelease(): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>387</x>
|
||||
<y>729</y>
|
||||
<w>180</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Led
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
- id: uint8_t
|
||||
--
|
||||
+ init(uint8_t id): void
|
||||
+ init_HW(): void
|
||||
-.
|
||||
+ on(): void
|
||||
+ off(): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>315</x>
|
||||
<y>639</y>
|
||||
<w>486</w>
|
||||
<h>36</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<->
|
||||
m2=-b</panel_attributes>
|
||||
<additional_attributes>520.0;10.0;10.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>1098</x>
|
||||
<y>468</y>
|
||||
<w>279</w>
|
||||
<h>369</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Blinker
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
- state: STATE
|
||||
- tON: uint16_t
|
||||
- tOFF: uint16_t
|
||||
- nBlink: uint8_t
|
||||
- nBlinkIsOn: bool
|
||||
- remainBlinks: uint8_t
|
||||
- turnOn: callBack
|
||||
- turnOff: callBack
|
||||
- finished: callBack
|
||||
--
|
||||
+ init(): void
|
||||
+ defineCallBack(fCallBack f, void* p): callBack
|
||||
+ setTurnOnCallBack(callBack c): void
|
||||
+ setTurnOffCallBack(callBack c): void
|
||||
+ setFinishedCallBack(callBack c): void
|
||||
+ defineNblink(uint8_t n): void
|
||||
+ setTimeOn(uint16_t t): void
|
||||
+ setTimeOff(uint16_t t): void
|
||||
-.
|
||||
+ startBehaviour(): void
|
||||
+ processEvent(Event* ev): void
|
||||
+ blinkN(): void
|
||||
+ blink(): void
|
||||
+ endBlink(): void
|
||||
+ toggle(): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>801</x>
|
||||
<y>216</y>
|
||||
<w>126</w>
|
||||
<h>108</h>
|
||||
</coordinates>
|
||||
<panel_attributes>Factory
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
+ init(): void
|
||||
+ build(): void
|
||||
+ start(): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLPackage</id>
|
||||
<coordinates>
|
||||
<x>117</x>
|
||||
<y>288</y>
|
||||
<w>324</w>
|
||||
<h>117</h>
|
||||
</coordinates>
|
||||
<panel_attributes>mcc_generated_files
|
||||
bg=pink
|
||||
transparency=0
|
||||
layer=0</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLPackage</id>
|
||||
<coordinates>
|
||||
<x>729</x>
|
||||
<y>117</y>
|
||||
<w>720</w>
|
||||
<h>288</h>
|
||||
</coordinates>
|
||||
<panel_attributes>app
|
||||
bg=pink
|
||||
transparency=0
|
||||
layer=0</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLPackage</id>
|
||||
<coordinates>
|
||||
<x>18</x>
|
||||
<y>513</y>
|
||||
<w>585</w>
|
||||
<h>378</h>
|
||||
</coordinates>
|
||||
<panel_attributes>board
|
||||
bg=pink
|
||||
transparency=0
|
||||
layer=0</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLPackage</id>
|
||||
<coordinates>
|
||||
<x>729</x>
|
||||
<y>423</y>
|
||||
<w>720</w>
|
||||
<h>468</h>
|
||||
</coordinates>
|
||||
<panel_attributes>middleware
|
||||
bg=pink
|
||||
transparency=0
|
||||
layer=0</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLClass</id>
|
||||
<coordinates>
|
||||
<x>1134</x>
|
||||
<y>162</y>
|
||||
<w>207</w>
|
||||
<h>198</h>
|
||||
</coordinates>
|
||||
<panel_attributes>App
|
||||
bg=yellow
|
||||
transparency=0
|
||||
layer=1
|
||||
--
|
||||
- state: STATE
|
||||
--
|
||||
+ init(): void
|
||||
-.
|
||||
+ startBehaviour(): void
|
||||
+ processEvent(Event* ev): void
|
||||
- clickL(): void
|
||||
- clickLn(): void
|
||||
- clickR(): void
|
||||
- clickRn(): void
|
||||
- endL(): void
|
||||
- endR(): void
|
||||
- longClick(): void</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>171</x>
|
||||
<y>396</y>
|
||||
<w>72</w>
|
||||
<h>225</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
m1=<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;230.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>405</x>
|
||||
<y>396</y>
|
||||
<w>72</w>
|
||||
<h>351</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
m1=<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;370.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>252</x>
|
||||
<y>252</y>
|
||||
<w>567</w>
|
||||
<h>369</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2= +b1..b3</panel_attributes>
|
||||
<additional_attributes>610.0;10.0;300.0;10.0;300.0;270.0;10.0;270.0;10.0;390.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>531</x>
|
||||
<y>288</y>
|
||||
<w>288</w>
|
||||
<h>459</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2= +11..l10</panel_attributes>
|
||||
<additional_attributes>300.0;10.0;200.0;10.0;200.0;340.0;10.0;340.0;10.0;490.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>846</x>
|
||||
<y>315</y>
|
||||
<w>81</w>
|
||||
<h>198</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2=+ch1..ch3</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;200.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>918</x>
|
||||
<y>234</y>
|
||||
<w>234</w>
|
||||
<h>36</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2=+app</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;240.0;10.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>918</x>
|
||||
<y>297</y>
|
||||
<w>324</w>
|
||||
<h>189</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2=+blL</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;150.0;10.0;150.0;150.0;310.0;150.0;310.0;190.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>918</x>
|
||||
<y>279</y>
|
||||
<w>360</w>
|
||||
<h>207</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2=+blR</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;160.0;10.0;160.0;160.0;350.0;160.0;350.0;210.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>918</x>
|
||||
<y>261</y>
|
||||
<w>396</w>
|
||||
<h>225</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=<<<<<->
|
||||
m2=+blB</panel_attributes>
|
||||
<additional_attributes>10.0;10.0;170.0;10.0;170.0;170.0;390.0;170.0;390.0;230.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>UMLPackage</id>
|
||||
<coordinates>
|
||||
<x>27</x>
|
||||
<y>117</y>
|
||||
<w>630</w>
|
||||
<h>117</h>
|
||||
</coordinates>
|
||||
<panel_attributes>xf
|
||||
bg=pink
|
||||
transparency=0
|
||||
layer=0</panel_attributes>
|
||||
<additional_attributes/>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>63</x>
|
||||
<y>225</y>
|
||||
<w>72</w>
|
||||
<h>396</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;420.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>612</x>
|
||||
<y>225</y>
|
||||
<w>504</w>
|
||||
<h>603</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;650.0;540.0;650.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>630</x>
|
||||
<y>225</y>
|
||||
<w>171</w>
|
||||
<h>315</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;10.0;10.0;330.0;170.0;330.0</additional_attributes>
|
||||
</element>
|
||||
<element>
|
||||
<id>Relation</id>
|
||||
<coordinates>
|
||||
<x>648</x>
|
||||
<y>171</y>
|
||||
<w>504</w>
|
||||
<h>36</h>
|
||||
</coordinates>
|
||||
<panel_attributes>lt=.>
|
||||
<<import>></panel_attributes>
|
||||
<additional_attributes>10.0;20.0;540.0;20.0</additional_attributes>
|
||||
</element>
|
||||
</diagram>
|
||||
76
02-UML/singleLeftClick.puml
Normal file
76
02-UML/singleLeftClick.puml
Normal file
@@ -0,0 +1,76 @@
|
||||
@startuml
|
||||
'https://plantuml.com/sequence-diagram
|
||||
actor User as usr
|
||||
participant "Pb L" as pbL
|
||||
participant "Pb R" as pbR
|
||||
participant "LED L" as ledL
|
||||
participant "LED R" as ledR
|
||||
|
||||
|
||||
== Single click ==
|
||||
|
||||
group Single click left
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
pbL -> ledL --++ : blink
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
pbL -> ledL -- : endBlink
|
||||
deactivate ledL
|
||||
end
|
||||
|
||||
group Single click right
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
pbR -> ledR --++ : blink
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
pbR -> ledR -- : endBlink
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
== Double click ==
|
||||
|
||||
group Double click left
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
usr -\ pbL : pressButton
|
||||
pbL -> ledL --++ : blink
|
||||
note right ledL: blink 3x
|
||||
ledL ->x ledL -- : finished
|
||||
end
|
||||
|
||||
group Double click right
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
usr -\ pbR : pressButton
|
||||
pbR -> ledR --++ : blink
|
||||
note right ledR: blink 3x
|
||||
ledR ->x ledR -- : finished
|
||||
end
|
||||
|
||||
== Long click ==
|
||||
|
||||
group Long click left
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR--: blink
|
||||
activate ledL
|
||||
activate ledR
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR -- : endBlink
|
||||
deactivate ledL
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
group Long click right
|
||||
usr -\ pbR ++: pressButton
|
||||
pbR -> ledR--: blink
|
||||
activate ledL
|
||||
activate ledR
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR -- : endBlink
|
||||
deactivate ledL
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
@enduml
|
||||
1
02-UML/testDiagram.svg
Normal file
1
02-UML/testDiagram.svg
Normal file
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 25 KiB |
216
03-software/ch/kb28/blinkerProject/app/app.c
Normal file
216
03-software/ch/kb28/blinkerProject/app/app.c
Normal file
@@ -0,0 +1,216 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "app.h"
|
||||
#include "factory/factory.h"
|
||||
#include "../middleware/blinker.h"
|
||||
#include "../middleware/clickHandler.h"
|
||||
|
||||
void clickL(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickL, 0, 0);
|
||||
}
|
||||
void clickLn(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickLn, 0, 0);
|
||||
}
|
||||
void clickR(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickR, 0, 0);
|
||||
}
|
||||
void clickRn(APP* me){
|
||||
POST(me, &APP_processEvent, evAPclickRn, 0, 0);
|
||||
}
|
||||
void endL(APP* me){
|
||||
POST(me, &APP_processEvent, evAPendL, 0, 0);
|
||||
}
|
||||
void endR(APP* me){
|
||||
POST(me, &APP_processEvent, evAPendR, 0, 0);
|
||||
}
|
||||
void longClick(APP* me){
|
||||
POST(me, &APP_processEvent, evAPlongClick, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
void APP_init(APP* me){
|
||||
|
||||
me->state = STAP_INIT;
|
||||
|
||||
CLICK_HANDLER_setSingleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&clickL, me));
|
||||
CLICK_HANDLER_setSingleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&clickR, me));
|
||||
|
||||
CLICK_HANDLER_setDoubleClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&clickLn, me));
|
||||
CLICK_HANDLER_setDoubleClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&clickRn, me));
|
||||
|
||||
CLICK_HANDLER_setLongClickCallback(ch1(), CLICK_HANDLER_defineCallBack(&longClick, me));
|
||||
CLICK_HANDLER_setLongClickCallback(ch3(), CLICK_HANDLER_defineCallBack(&longClick, me));
|
||||
|
||||
BLINKER_setFinished(blL(), BLINKER_defineCallBack(&endL, me));
|
||||
BLINKER_setFinished(blR(), BLINKER_defineCallBack(&endR, me));
|
||||
|
||||
}
|
||||
|
||||
void APP_startBehaviour(APP* me){
|
||||
POST(me, &APP_processEvent, evAPinit, 0, 0);
|
||||
}
|
||||
|
||||
bool APP_processEvent(Event* ev){
|
||||
bool processed = false;
|
||||
APP* me = (APP*) Event_getTarget(ev);
|
||||
APP_STATES oldState = me->state;
|
||||
evIDT evid = Event_getId(ev);
|
||||
|
||||
switch(me->state) { // In state
|
||||
case STAP_INIT:
|
||||
if(evid == evAPinit) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_blink(blL());
|
||||
}
|
||||
if(evid == evAPclickLn) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_blinkN(blL());
|
||||
}
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_blink(blR());
|
||||
}
|
||||
if(evid == evAPclickRn) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_blinkN(blR());
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_blink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
if(evid == evAPclickR){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_blink(blR());
|
||||
}
|
||||
if(evid == evAPclickRn){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_blinkN(blR());
|
||||
}
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blL());
|
||||
}
|
||||
if(evid == evAPendL) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_blink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
if(evid == evAPclickL){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_blink(blL());
|
||||
}
|
||||
if(evid == evAPclickLn){
|
||||
me->state = STAP_BLINKER_LR;
|
||||
BLINKER_blinkN(blL());
|
||||
}
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blR());
|
||||
}
|
||||
if(evid == evAPendR) {
|
||||
me->state = STAP_WAIT;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blR());
|
||||
BLINKER_blink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
if(evid == evAPclickR) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
BLINKER_endBlink(blR());
|
||||
}
|
||||
if(evid == evAPendR) {
|
||||
me->state = STAP_BLINKER_L;
|
||||
}
|
||||
if(evid == evAPclickL) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
BLINKER_endBlink(blL());
|
||||
}
|
||||
if(evid == evAPendL) {
|
||||
me->state = STAP_BLINKER_R;
|
||||
}
|
||||
if(evid == evAPlongClick) {
|
||||
me->state = STAP_BLINKER_W;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_endBlink(blR());
|
||||
BLINKER_blink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
if(evid == evAPlongClick){
|
||||
me->state = STAP_WAIT;
|
||||
BLINKER_endBlink(blB());
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(oldState != me->state) {
|
||||
switch(oldState) { // on exit
|
||||
case STAP_INIT:
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
break;
|
||||
}
|
||||
|
||||
switch(me->state) { // on entry
|
||||
case STAP_INIT:
|
||||
break;
|
||||
|
||||
case STAP_WAIT:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_L:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_R:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_LR:
|
||||
break;
|
||||
|
||||
case STAP_BLINKER_W:
|
||||
break;
|
||||
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
40
03-software/ch/kb28/blinkerProject/app/app.h
Normal file
40
03-software/ch/kb28/blinkerProject/app/app.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version 1.0.0
|
||||
* @date 2023-06-17
|
||||
*/
|
||||
#ifndef APP_H
|
||||
#define APP_H
|
||||
|
||||
#include "../xf/xf.h"
|
||||
|
||||
typedef enum {
|
||||
STAP_INIT,
|
||||
STAP_WAIT,
|
||||
STAP_BLINKER_L,
|
||||
STAP_BLINKER_R,
|
||||
STAP_BLINKER_LR,
|
||||
STAP_BLINKER_W
|
||||
} APP_STATES;
|
||||
|
||||
typedef enum {
|
||||
evAPinit = 150,
|
||||
evAPclickL,
|
||||
evAPclickLn,
|
||||
evAPclickR,
|
||||
evAPclickRn,
|
||||
evAPendL,
|
||||
evAPendR,
|
||||
evAPlongClick
|
||||
} APP_EVENTS;
|
||||
|
||||
typedef struct {
|
||||
APP_STATES state; // Actual state
|
||||
} APP;
|
||||
|
||||
void APP_init(APP* me);
|
||||
void APP_startBehaviour(APP* me);
|
||||
bool APP_processEvent(Event* ev);
|
||||
|
||||
#endif /* APP_H */
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 0.0.6
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
#include "factory.h"
|
||||
|
||||
|
||||
@@ -47,9 +52,28 @@ BUTTON* b3() {
|
||||
return &theFactory.b3_;
|
||||
}
|
||||
|
||||
CLICK_HANDLER* ch1() {
|
||||
return &theFactory.ch1_;
|
||||
}
|
||||
CLICK_HANDLER* ch2() {
|
||||
return &theFactory.ch2_;
|
||||
}
|
||||
CLICK_HANDLER* ch3() {
|
||||
return &theFactory.ch3_;
|
||||
}
|
||||
|
||||
LEDBlinker* lb() {
|
||||
return &theFactory.lb_;
|
||||
BLINKER* blL() {
|
||||
return &theFactory.blL_;
|
||||
}
|
||||
BLINKER* blR() {
|
||||
return &theFactory.blR_;
|
||||
}
|
||||
BLINKER* blB() {
|
||||
return &theFactory.blB_;
|
||||
}
|
||||
|
||||
APP* app() {
|
||||
return &theFactory.app_;
|
||||
}
|
||||
|
||||
//initialize all objects
|
||||
@@ -65,11 +89,6 @@ void Factory_init() {
|
||||
LED_init(l9(), 9);
|
||||
LED_init(l10(), 10);
|
||||
|
||||
BUTTON_init(b1(), 1);
|
||||
BUTTON_init(b2(), 2);
|
||||
BUTTON_init(b3(), 3);
|
||||
|
||||
|
||||
LED_initHW(l1());
|
||||
LED_initHW(l2());
|
||||
LED_initHW(l3());
|
||||
@@ -81,18 +100,62 @@ void Factory_init() {
|
||||
LED_initHW(l9());
|
||||
LED_initHW(l10());
|
||||
|
||||
|
||||
BUTTON_init(b1(), 1);
|
||||
BUTTON_init(b2(), 2);
|
||||
BUTTON_init(b3(), 3);
|
||||
|
||||
BUTTON_initHW(b1());
|
||||
BUTTON_initHW(b2());
|
||||
BUTTON_initHW(b3());
|
||||
|
||||
CLICK_HANDLER_init(ch1(), b1());
|
||||
CLICK_HANDLER_init(ch2(), b2());
|
||||
CLICK_HANDLER_init(ch3(), b3());
|
||||
|
||||
BLINKER_init(blL());
|
||||
BLINKER_init(blR());
|
||||
BLINKER_init(blB());
|
||||
|
||||
APP_init(app());
|
||||
|
||||
}
|
||||
|
||||
void warningBlink(void* on_){
|
||||
bool on = (bool)on_;
|
||||
BLINKER_endBlink(blL());
|
||||
BLINKER_endBlink(blR());
|
||||
if(on) {
|
||||
LED_on(l1());
|
||||
LED_on(l10());
|
||||
} else {
|
||||
LED_off(l1());
|
||||
LED_off(l10());
|
||||
}
|
||||
}
|
||||
|
||||
//connect objects if required
|
||||
void Factory_build() {
|
||||
|
||||
BLINKER_setTurnOn(blL(), BLINKER_defineCallBack(&LED_on, l1()));
|
||||
BLINKER_setTurnOff(blL(), BLINKER_defineCallBack(&LED_off, l1()));
|
||||
BLINKER_setTurnOn(blR(), BLINKER_defineCallBack(&LED_on, l10()));
|
||||
BLINKER_setTurnOff(blR(), BLINKER_defineCallBack(&LED_off, l10()));
|
||||
BLINKER_setTurnOn(blB(), BLINKER_defineCallBack(&warningBlink, true));
|
||||
BLINKER_setTurnOff(blB(), BLINKER_defineCallBack(&warningBlink, false));
|
||||
|
||||
}
|
||||
|
||||
//start all state machines
|
||||
void Factory_start() {
|
||||
LEDBlinker_startBehaviour(lb());
|
||||
BUTTON_startBehaviour(b1());
|
||||
BUTTON_startBehaviour(b2());
|
||||
BUTTON_startBehaviour(b3());
|
||||
CLICK_HANDLER_startBehaviour(ch1());
|
||||
CLICK_HANDLER_startBehaviour(ch2());
|
||||
CLICK_HANDLER_startBehaviour(ch3());
|
||||
BLINKER_starBehaviour(blL());
|
||||
BLINKER_starBehaviour(blR());
|
||||
BLINKER_starBehaviour(blB());
|
||||
APP_startBehaviour(app());
|
||||
}
|
||||
|
||||
@@ -1,17 +1,20 @@
|
||||
/* this is the Factory class */
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 0.0.6
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
|
||||
#ifndef FACTORY_ONCE
|
||||
#define FACTORY_ONCE
|
||||
#ifndef FACTORY_H
|
||||
#define FACTORY_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "../../board/led/led.h"
|
||||
#include "../../board/button/button.h"
|
||||
#include "../ledblinker.h"
|
||||
#define LID 1
|
||||
|
||||
#include "../../middleware/clickHandler.h"
|
||||
#include "../../middleware/blinker.h"
|
||||
#include "../app.h"
|
||||
|
||||
typedef struct {
|
||||
LED l1_;
|
||||
@@ -27,8 +30,13 @@ typedef struct {
|
||||
BUTTON b1_;
|
||||
BUTTON b2_;
|
||||
BUTTON b3_;
|
||||
|
||||
LEDBlinker lb_;
|
||||
CLICK_HANDLER ch1_;
|
||||
CLICK_HANDLER ch2_;
|
||||
CLICK_HANDLER ch3_;
|
||||
BLINKER blL_;
|
||||
BLINKER blR_;
|
||||
BLINKER blB_;
|
||||
APP app_;
|
||||
} Factory;
|
||||
|
||||
|
||||
@@ -52,6 +60,14 @@ BUTTON* b1();
|
||||
BUTTON* b2();
|
||||
BUTTON* b3();
|
||||
|
||||
LEDBlinker* lb();
|
||||
CLICK_HANDLER* ch1();
|
||||
CLICK_HANDLER* ch2();
|
||||
CLICK_HANDLER* ch3();
|
||||
|
||||
BLINKER* blL();
|
||||
BLINKER* blR();
|
||||
BLINKER* blB();
|
||||
|
||||
APP* app();
|
||||
|
||||
#endif
|
||||
@@ -1,57 +0,0 @@
|
||||
#include "ledblinker.h"
|
||||
#include "factory/factory.h"
|
||||
#include "../board/led/led.h"
|
||||
|
||||
void LEDBlinker_init(LEDBlinker* me) {
|
||||
me->state = ST_LBINIT;
|
||||
}
|
||||
|
||||
void LEDBlinker_startBehaviour(LEDBlinker* me) {
|
||||
POST(me, &LEDBlinker_processEvent, evLBInit,0,0);
|
||||
}
|
||||
|
||||
bool LEDBlinker_processEvent(Event* ev) {
|
||||
bool processed = false;
|
||||
LEDBlinker* me = (LEDBlinker*)Event_getTarget(ev);
|
||||
LBSTATES oldState = me->state;
|
||||
evIDT evid = Event_getId(ev);
|
||||
|
||||
switch (me->state) {
|
||||
case ST_LBINIT:
|
||||
if (evid == evLBInit) {
|
||||
me->state = ST_LBOFF;
|
||||
}
|
||||
break;
|
||||
case ST_LBOFF:
|
||||
if (evid == evLBTMOn) {
|
||||
me->state = ST_LBON;
|
||||
}
|
||||
break;
|
||||
case ST_LBON:
|
||||
if (evid == evLBTMOff) {
|
||||
me->state = ST_LBOFF;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (oldState != me->state) {
|
||||
switch (me->state) {
|
||||
case ST_LBINIT:
|
||||
break;
|
||||
case ST_LBOFF:
|
||||
LED_off(l1());
|
||||
POST(me, &LEDBlinker_processEvent, evLBTMOn,TMOFF,0);
|
||||
break;
|
||||
case ST_LBON:
|
||||
LED_on(l1());
|
||||
POST(me, &LEDBlinker_processEvent, evLBTMOff,TMON,0);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
/*
|
||||
* File: ledblinker.h
|
||||
* Author: rim
|
||||
*
|
||||
* Created on May 14, 2023, 9:58 AM
|
||||
*/
|
||||
|
||||
#ifndef LEDBLINKER_H
|
||||
#define LEDBLINKER_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "../xf/xf.h"
|
||||
|
||||
enum LBSTATES_ {ST_LBINIT, ST_LBOFF, ST_LBON};
|
||||
enum LBEVENTS_ {evLBInit=200, evLBTMOff, evLBTMOn};
|
||||
typedef enum LBSTATES_ LBSTATES;
|
||||
typedef enum LBEVENTS_ LBEVENTS;
|
||||
|
||||
struct LEDBlinker_ {
|
||||
LBSTATES state;
|
||||
};
|
||||
|
||||
typedef struct LEDBlinker_ LEDBlinker;
|
||||
|
||||
#define TMON 500
|
||||
#define TMOFF 1000
|
||||
|
||||
|
||||
void LEDBlinker_init(LEDBlinker* me);
|
||||
|
||||
void LEDBlinker_startBehaviour(LEDBlinker* me);
|
||||
bool LEDBlinker_processEvent(Event* ev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* LEDBLINKER_H */
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
|
||||
#include "../mcc_generated_files/mcc.h"
|
||||
#include "../board/led/led.h"
|
||||
#include "../app/factory/factory.h"
|
||||
#include "../xf/xf.h"
|
||||
#include "../board/button/button.h"
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +14,7 @@ void main(void)
|
||||
INTERRUPT_GlobalInterruptEnable();
|
||||
//INTERRUPT_GlobalInterruptDisable();
|
||||
//INTERRUPT_PeripheralInterruptEnable();
|
||||
//INTERRUPT_PeripheralInterruptDisable();
|
||||
//INTERRUPT_PeripheralInterruptDisable();
|
||||
|
||||
XF_init();
|
||||
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
/**
|
||||
* @file button.c
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version 0.1
|
||||
* @date 2023-06-06
|
||||
*
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "button.h"
|
||||
#include "../../mcc_generated_files/pin_manager.h"
|
||||
#include "../led/led.h"
|
||||
#include "../../app/factory/factory.h"
|
||||
|
||||
/**
|
||||
@@ -20,7 +17,8 @@
|
||||
void BUTTON_init(BUTTON* me, uint8_t id) {
|
||||
me->id = id;
|
||||
me->state = ST_PBINIT;
|
||||
|
||||
me->press.fCallBack = NULL;
|
||||
me->release.fCallBack = NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,31 +80,29 @@ bool BUTTON_processEvent(Event * ev) {
|
||||
switch(me->state){
|
||||
case ST_PBINIT:
|
||||
if (evid == evPBInit) {
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, 0, 0);
|
||||
if(BUTTON_isPressed(me)) {
|
||||
me->state = ST_PBPRESSED;
|
||||
} else {
|
||||
me->state = ST_PBRELEASED;
|
||||
}
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, PB_POLL_TIME, 0);
|
||||
}
|
||||
break;
|
||||
case ST_PBPOLL:
|
||||
break;
|
||||
case ST_PBRELEASED:
|
||||
if(evid == evPBPoll) {
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, PB_POLL_TIME, 0);
|
||||
if(BUTTON_isPressed(me)) {
|
||||
me->state = ST_PBPRESSED;
|
||||
}
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, PB_POLL_TIME, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
case ST_PBPRESSED:
|
||||
if(evid == evPBPoll) {
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, PB_POLL_TIME, 0);
|
||||
if(!BUTTON_isPressed(me)){
|
||||
me->state = ST_PBRELEASED;
|
||||
}
|
||||
POST(me, &BUTTON_processEvent, evPBPoll, PB_POLL_TIME, 0);
|
||||
|
||||
}
|
||||
break;
|
||||
@@ -116,16 +112,26 @@ bool BUTTON_processEvent(Event * ev) {
|
||||
switch(me->state){
|
||||
case ST_PBINIT:
|
||||
break;
|
||||
case ST_PBPOLL:
|
||||
break;
|
||||
case ST_PBRELEASED:
|
||||
LED_off(l10());
|
||||
if(me->release.fCallBack != NULL) me->release.fCallBack(me->release.param);
|
||||
break;
|
||||
case ST_PBPRESSED:
|
||||
LED_on(l10());
|
||||
if(me->press.fCallBack != NULL) me->press.fCallBack(me->press.param);
|
||||
break;
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
void BUTTON_setEventFunctions(BUTTON* me, buttonCallBack fPress, buttonCallBack fRelease) {
|
||||
me->press = fPress;
|
||||
me->release = fRelease;
|
||||
}
|
||||
|
||||
buttonCallBack BUTTON_defineCallBack(fButtonCallback f, void* param){
|
||||
buttonCallBack c;
|
||||
c.fCallBack = f;
|
||||
c.param = param;
|
||||
return c;
|
||||
}
|
||||
@@ -1,32 +1,97 @@
|
||||
/**
|
||||
* @file button.h
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version 0.1
|
||||
* @date 2023-06-06
|
||||
*
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
#ifndef BUTTON_H
|
||||
#define BUTTON_H
|
||||
#define BUTTON_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include "../../xf/xf.h"
|
||||
|
||||
#define PB_POLL_TIME 20
|
||||
#define PB_POLL_TIME 20 // Poll time for BUTTON
|
||||
|
||||
typedef enum {ST_PBINIT, ST_PBWAIT, ST_PBPOLL, ST_PBRELEASED, ST_PBPRESSED} BUTTON_STATES;
|
||||
typedef enum {evPBInit=100, evPBPoll} BUTTON_EVENTS;
|
||||
typedef enum {
|
||||
ST_PBINIT,
|
||||
ST_PBRELEASED,
|
||||
ST_PBPRESSED
|
||||
} BUTTON_STATES;
|
||||
|
||||
typedef enum {
|
||||
evPBInit=50,
|
||||
evPBPoll
|
||||
} BUTTON_EVENTS;
|
||||
|
||||
// Calback function
|
||||
typedef void (*fButtonCallback)(void*);
|
||||
typedef struct {
|
||||
fButtonCallback fCallBack;
|
||||
void* param;
|
||||
} buttonCallBack;
|
||||
|
||||
typedef struct {
|
||||
uint8_t id;
|
||||
BUTTON_STATES state;
|
||||
|
||||
uint8_t id; // Id of the button
|
||||
BUTTON_STATES state; // Actual state
|
||||
buttonCallBack press; // Callback for the rising edge of the button
|
||||
buttonCallBack release; // Callback for the falling edge of the button
|
||||
} BUTTON;
|
||||
|
||||
/**
|
||||
* @brief Initialize the button
|
||||
*
|
||||
* @param me button itself
|
||||
* @param id The id of the button
|
||||
*/
|
||||
void BUTTON_init(BUTTON* me, uint8_t id);
|
||||
|
||||
/**
|
||||
* @brief Initialize the hardware of the button
|
||||
*
|
||||
* @param me button itself
|
||||
*/
|
||||
void BUTTON_initHW(BUTTON* me);
|
||||
|
||||
/**
|
||||
* @brief Set both callback event functions
|
||||
*
|
||||
* @param me button itself
|
||||
* @param fPress callback function when the button have a rising edge
|
||||
* @param release callback function whent the have a falling edge
|
||||
*/
|
||||
void BUTTON_setEventFunctions(BUTTON* me, buttonCallBack fPress, buttonCallBack release);
|
||||
|
||||
/**
|
||||
* @brief Check if the button is pressed
|
||||
* The function returns true if the button is pressed, false otherwise
|
||||
*
|
||||
* @param me button itself
|
||||
* @return true if the button is pressed
|
||||
* @return false if the button is not pressed
|
||||
*/
|
||||
bool BUTTON_isPressed(BUTTON* me);
|
||||
|
||||
/**
|
||||
* @biref Start state machine of the BUTTON
|
||||
*
|
||||
* @param me the button itself
|
||||
*/
|
||||
void BUTTON_startBehaviour(BUTTON* me);
|
||||
|
||||
/**
|
||||
* @brief State machine of the BUTTON
|
||||
*
|
||||
* @param ev event to process on the state machine
|
||||
*/
|
||||
bool BUTTON_processEvent(Event* ev);
|
||||
|
||||
/**
|
||||
* @brief Define a callback for BUTTON
|
||||
*
|
||||
* @param f callback function
|
||||
* @param param callback parameter for the function
|
||||
* @return the callback struct
|
||||
*/
|
||||
buttonCallBack BUTTON_defineCallBack(fButtonCallback f, void* param);
|
||||
|
||||
#endif /* BUTTON_H */
|
||||
@@ -1,8 +1,13 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "led.h"
|
||||
#include "../../mcc_generated_files/pin_manager.h"
|
||||
|
||||
void LED_init(LED* me, uint8_t id)
|
||||
{
|
||||
void LED_init(LED* me, uint8_t id) {
|
||||
me->id = id;
|
||||
}
|
||||
|
||||
@@ -10,15 +15,13 @@ void LED_init(LED* me, uint8_t id)
|
||||
* @brief Initialize the Driver
|
||||
*
|
||||
*/
|
||||
void LED_initHW(LED* me)
|
||||
{
|
||||
void LED_initHW(LED* me) {
|
||||
LED_off(me);
|
||||
}
|
||||
|
||||
void LED_on(LED* me)
|
||||
{
|
||||
switch (me->id)
|
||||
{
|
||||
void LED_on(void* me) {
|
||||
LED* l = (LED*) me;
|
||||
switch (l->id) {
|
||||
case 1:
|
||||
OUTPUT1_SetHigh();
|
||||
break;
|
||||
@@ -53,10 +56,9 @@ void LED_on(LED* me)
|
||||
|
||||
}
|
||||
|
||||
void LED_off(LED* me)
|
||||
{
|
||||
switch (me->id)
|
||||
{
|
||||
void LED_off(void* me) {
|
||||
LED* l = (LED*) me;
|
||||
switch (l->id) {
|
||||
case 1:
|
||||
OUTPUT1_SetLow();
|
||||
break;
|
||||
|
||||
@@ -1,26 +1,43 @@
|
||||
/*
|
||||
* File: led.h
|
||||
* Author: rim
|
||||
*
|
||||
* Created on May 15, 2023, 7:56 AM
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#ifndef LED_H
|
||||
#define LED_H
|
||||
#define LED_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct LED_
|
||||
{
|
||||
uint8_t id;
|
||||
};
|
||||
|
||||
typedef struct LED_ LED;
|
||||
// LED struct
|
||||
typedef struct {
|
||||
uint8_t id; // The id of the LED
|
||||
}LED;
|
||||
|
||||
/**
|
||||
* Initialize the led
|
||||
* @param me the led itself
|
||||
* @param id the id of the led
|
||||
*/
|
||||
void LED_init(LED* me, uint8_t id);
|
||||
|
||||
/**
|
||||
* Initializing the led
|
||||
* @param me the led itself
|
||||
*/
|
||||
void LED_initHW(LED* me);
|
||||
void LED_on(LED* me);
|
||||
void LED_off(LED* me);
|
||||
|
||||
/**
|
||||
* Turn On the led
|
||||
* @param me the led itself
|
||||
*/
|
||||
void LED_on(void* me);
|
||||
|
||||
/**
|
||||
* Turn Off the led
|
||||
* @param me the led itself
|
||||
*/
|
||||
void LED_off(void* me);
|
||||
|
||||
#endif /* LED_H */
|
||||
|
||||
|
||||
155
03-software/ch/kb28/blinkerProject/middleware/blinker.c
Normal file
155
03-software/ch/kb28/blinkerProject/middleware/blinker.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "blinker.h"
|
||||
|
||||
|
||||
void BLINKER_init(BLINKER* me) {
|
||||
me->state = STBL_INIT;
|
||||
me->tON = 500;
|
||||
me->tOFF = 500;
|
||||
me->nBlink = 3;
|
||||
me->nBlinkIsOn = false;
|
||||
me->remainBlinks = 3;
|
||||
me->turnOn.fCallBack = NULL;
|
||||
me->turnOff.fCallBack = NULL;
|
||||
}
|
||||
|
||||
blinkerCallBack BLINKER_defineCallBack(fBlinkerCallBack f, void* param) {
|
||||
blinkerCallBack c;
|
||||
c.fCallBack = f;
|
||||
c.param = param;
|
||||
return c;
|
||||
}
|
||||
|
||||
void BLINKER_starBehaviour(BLINKER* me) {
|
||||
POST(me, &BLINKER_processEvent, evBLinit, 0, 0);
|
||||
}
|
||||
|
||||
void BLINKER_setTurnOn(BLINKER* me, blinkerCallBack callBack) {
|
||||
me->turnOn = callBack;
|
||||
}
|
||||
|
||||
void BLINKER_setTurnOff(BLINKER* me, blinkerCallBack callBack) {
|
||||
me->turnOff = callBack;
|
||||
}
|
||||
|
||||
void BLINKER_setFinished(BLINKER* me, blinkerCallBack callBack){
|
||||
me->finished = callBack;
|
||||
}
|
||||
|
||||
void BLINKER_defineNblink(BLINKER* me, uint8_t n){
|
||||
me->nBlink = n;
|
||||
}
|
||||
|
||||
void BLINKER_setTimeOn(BLINKER*me, uint16_t t) {
|
||||
me->tON = t;
|
||||
}
|
||||
|
||||
void BLINKER_setTimeOff(BLINKER*me, uint16_t t) {
|
||||
me->tOFF = t;
|
||||
}
|
||||
|
||||
void BLINKER_blinkN(BLINKER* me){
|
||||
POST(me, &BLINKER_processEvent, evBLblinkN, 0, 0);
|
||||
}
|
||||
|
||||
void BLINKER_blink(BLINKER* me){
|
||||
POST(me, &BLINKER_processEvent, evBLblink, 0, 0);
|
||||
}
|
||||
|
||||
bool BLINKER_processEvent(Event* ev) {
|
||||
bool processed = false;
|
||||
BLINKER* me = (BLINKER*) Event_getTarget(ev);
|
||||
BLINKER_STATES oldState = me->state;
|
||||
evIDT evid = Event_getId(ev);
|
||||
|
||||
switch(me->state) {
|
||||
case STBL_INIT:
|
||||
if(evid == evBLinit) {
|
||||
me->state = STBL_WAIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case STBL_WAIT:
|
||||
me->remainBlinks = me->nBlink;
|
||||
|
||||
if(evid == evBLblinkN) {
|
||||
me->state = STBL_ON;
|
||||
me->nBlinkIsOn = true;
|
||||
POST(me, &BLINKER_processEvent, evBLtimer, me->tON, 0);
|
||||
}
|
||||
|
||||
if(evid==evBLblink) {
|
||||
me->state = STBL_ON;
|
||||
me->nBlinkIsOn = false;
|
||||
POST(me, &BLINKER_processEvent, evBLtimer, me->tON, 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case STBL_ON:
|
||||
if(me->nBlinkIsOn) me->remainBlinks--;
|
||||
|
||||
if(evid == evBLtimer) {
|
||||
me->state = STBL_OFF;
|
||||
POST(me, &BLINKER_processEvent, evBLtimer, me->tOFF, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case STBL_OFF:
|
||||
|
||||
if(evid == evBLtimer) {
|
||||
if(me->remainBlinks == 0) {
|
||||
me->state = STBL_WAIT;
|
||||
if(me->finished.fCallBack != NULL) me->finished.fCallBack(me->finished.param);
|
||||
} else {
|
||||
me->state = STBL_ON;
|
||||
POST(me, &BLINKER_processEvent, evBLtimer, me->tON, 0);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if(oldState != me->state) {
|
||||
switch(me->state) { // on entry
|
||||
case STBL_INIT:
|
||||
break;
|
||||
|
||||
case STBL_WAIT:
|
||||
break;
|
||||
|
||||
case STBL_ON:
|
||||
if(me->turnOn.fCallBack != NULL) me->turnOn.fCallBack(me->turnOn.param);
|
||||
break;
|
||||
|
||||
case STBL_OFF:
|
||||
if(me->turnOff.fCallBack != NULL) me->turnOff.fCallBack(me->turnOff.param);
|
||||
break;
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
|
||||
void BLINKER_endBlink(BLINKER* me) {
|
||||
me->remainBlinks = 0;
|
||||
}
|
||||
|
||||
void BLINKER_toggle(BLINKER* me){
|
||||
switch(me->state) {
|
||||
case STBL_WAIT:
|
||||
BLINKER_blink(me);
|
||||
break;
|
||||
case STBL_OFF:
|
||||
BLINKER_endBlink(me);
|
||||
break;
|
||||
case STBL_ON:
|
||||
BLINKER_endBlink(me);
|
||||
break;
|
||||
}
|
||||
}
|
||||
135
03-software/ch/kb28/blinkerProject/middleware/blinker.h
Normal file
135
03-software/ch/kb28/blinkerProject/middleware/blinker.h
Normal file
@@ -0,0 +1,135 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#ifndef BLINKER_H
|
||||
#define BLINKER_H
|
||||
|
||||
#include "../xf/xf.h"
|
||||
|
||||
typedef enum {
|
||||
STBL_INIT,
|
||||
STBL_WAIT,
|
||||
STBL_ON,
|
||||
STBL_OFF
|
||||
} BLINKER_STATES;
|
||||
|
||||
typedef enum {
|
||||
evBLinit = 200,
|
||||
evBLblink,
|
||||
evBLblinkN,
|
||||
evBLtimer,
|
||||
evEndBlink
|
||||
} BLINKER_EVENTS;
|
||||
|
||||
typedef void (*fBlinkerCallBack)(void*);
|
||||
typedef struct {
|
||||
fBlinkerCallBack fCallBack;
|
||||
void* param;
|
||||
} blinkerCallBack;
|
||||
|
||||
typedef struct {
|
||||
BLINKER_STATES state; // Actual state
|
||||
uint16_t tON; // Time on
|
||||
uint16_t tOFF; // Time off
|
||||
uint8_t nBlink; // Number of blink for this blinker when start with blinkN
|
||||
bool nBlinkIsOn; // If the nBlink way is enable
|
||||
uint8_t remainBlinks; // Actual remain blink
|
||||
blinkerCallBack turnOn; // Callback for turnOn
|
||||
blinkerCallBack turnOff; // Calbback for turnOff
|
||||
blinkerCallBack finished; // Callback for finish n blink
|
||||
}BLINKER;
|
||||
|
||||
/**
|
||||
* Initialize the blinker
|
||||
* @param me blinker itself
|
||||
*/
|
||||
void BLINKER_init(BLINKER* me);
|
||||
|
||||
/**
|
||||
* Define a callback for BLINKER
|
||||
* @param f callback for BLINKER
|
||||
* @param param callback paramater for ther function
|
||||
* @return the callback struct
|
||||
*/
|
||||
blinkerCallBack BLINKER_defineCallBack(fBlinkerCallBack f, void* param);
|
||||
|
||||
/**
|
||||
* Start state machine of the BLINKER
|
||||
* @param me the blinker itself
|
||||
*/
|
||||
void BLINKER_starBehaviour(BLINKER* me);
|
||||
|
||||
/**
|
||||
* Set callback event functions for turn on
|
||||
* @param me the blinker itself
|
||||
* @param callBack function when the blinker is on
|
||||
*/
|
||||
void BLINKER_setTurnOn(BLINKER* me, blinkerCallBack callBack);
|
||||
|
||||
/**
|
||||
* Set callback event functions for turn off
|
||||
* @param me the blinker itself
|
||||
* @param callBack function when the blinker is off
|
||||
*/
|
||||
void BLINKER_setTurnOff(BLINKER* me, blinkerCallBack callBack);
|
||||
|
||||
/**
|
||||
* Set callback event functions for when the blinker has blink n times
|
||||
* @param me the blinker itseld
|
||||
* @param callBack callBack function when the blinker has blink n times
|
||||
*/
|
||||
void BLINKER_setFinished(BLINKER* me, blinkerCallBack callBack);
|
||||
|
||||
/**
|
||||
* define number of time the Blinker have to blink
|
||||
* @param me the blinker itself
|
||||
* @param n number of blink
|
||||
*/
|
||||
void BLINKER_defineNblink(BLINKER* me, uint8_t n);
|
||||
|
||||
/**
|
||||
* define time to stay ON
|
||||
* @param me the blinker itself
|
||||
* @param t the time to stay ON
|
||||
*/
|
||||
void BLINKER_setTimeOn(BLINKER*me, uint16_t t);
|
||||
|
||||
/**
|
||||
* define time to stay OFF
|
||||
* @param me the blinker itself
|
||||
* @param t the time to stay OFF
|
||||
*/
|
||||
void BLINKER_setTimeOff(BLINKER*me, uint16_t t);
|
||||
|
||||
/**
|
||||
* Start to blink n time
|
||||
* @param me the blinker itself
|
||||
*/
|
||||
void BLINKER_blinkN(BLINKER* me);
|
||||
|
||||
/**
|
||||
* Start to blink indefinitely
|
||||
* @param me the blinker itself
|
||||
*/
|
||||
void BLINKER_blink(BLINKER* me);
|
||||
|
||||
/**
|
||||
* State machine of the BUTTON
|
||||
* @param ev event to process on the state machine
|
||||
*/
|
||||
bool BLINKER_processEvent(Event* ev);
|
||||
|
||||
/**
|
||||
* Stop to blink if it was indefinitely blinking
|
||||
* @param me the blinker itself
|
||||
*/
|
||||
void BLINKER_endBlink(BLINKER* me);
|
||||
|
||||
void BLINKER_toggle(BLINKER* me);
|
||||
|
||||
|
||||
#endif /* BLINKER_H */
|
||||
|
||||
153
03-software/ch/kb28/blinkerProject/middleware/clickHandler.c
Normal file
153
03-software/ch/kb28/blinkerProject/middleware/clickHandler.c
Normal file
@@ -0,0 +1,153 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#include "clickHandler.h"
|
||||
|
||||
void CLICK_HANDLER_BUTTON_PRESS(CLICK_HANDLER* me){
|
||||
POST(me, &CLICK_HANDLER_processEvent, evCHpbPress, 0, 0);
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_BUTTON_RELEASE(CLICK_HANDLER * me) {
|
||||
POST(me, &CLICK_HANDLER_processEvent, evCHpbRelease, 0, 0);
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_init(CLICK_HANDLER* me, BUTTON* b){
|
||||
me->button = b;
|
||||
me->state = STCH_INIT;
|
||||
me->longClick.fCallBack = NULL;
|
||||
me->singleClick.fCallBack = NULL;
|
||||
me->doubleClick.fCallBack = NULL;
|
||||
|
||||
buttonCallBack pbPressCallBack;
|
||||
pbPressCallBack.fCallBack = CLICK_HANDLER_BUTTON_PRESS;
|
||||
pbPressCallBack.param = me;
|
||||
|
||||
buttonCallBack pbReleaseCallBack;
|
||||
pbReleaseCallBack.fCallBack = CLICK_HANDLER_BUTTON_RELEASE;
|
||||
pbReleaseCallBack.param = me;
|
||||
|
||||
BUTTON_setEventFunctions(b, pbPressCallBack, pbReleaseCallBack);
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_startBehaviour(CLICK_HANDLER* me){
|
||||
POST(me, &CLICK_HANDLER_processEvent, evCHinit, 0, 0);
|
||||
}
|
||||
|
||||
clickHandlerCallBack CLICK_HANDLER_defineCallBack(fClickHandlerCallBack f, void* param) {
|
||||
clickHandlerCallBack c;
|
||||
c.fCallBack = f;
|
||||
c.param = param;
|
||||
return c;
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_setLongClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack) {
|
||||
me->longClick = callBack;
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_setSingleClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack) {
|
||||
me->singleClick = callBack;
|
||||
}
|
||||
|
||||
void CLICK_HANDLER_setDoubleClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack) {
|
||||
me->doubleClick = callBack;
|
||||
}
|
||||
|
||||
bool CLICK_HANDLER_processEvent(Event* ev) {
|
||||
bool processed = false;
|
||||
CLICK_HANDLER* me = (CLICK_HANDLER*)Event_getTarget(ev);
|
||||
CLICK_HANDLER_STATES oldState = me->state;
|
||||
evIDT evid = Event_getId(ev);
|
||||
|
||||
switch(me->state) {
|
||||
case STCH_INIT:
|
||||
if(evid == evCHinit) {
|
||||
me->state = STCH_WAIT;
|
||||
}
|
||||
break;
|
||||
|
||||
case STCH_WAIT:
|
||||
|
||||
if(evid == evCHpbPress) {
|
||||
me->state = STCH_LONG_CLICK;
|
||||
POST(me, &CLICK_HANDLER_processEvent, evCHtimer, CH_CLICK_TIMER, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case STCH_LONG_CLICK:
|
||||
|
||||
if(evid == evCHpbRelease) {
|
||||
me->state = STCH_SINGLE_CLICK;
|
||||
}
|
||||
|
||||
if(evid == evCHtimer) {
|
||||
me->state = STCH_WAIT;
|
||||
if(me->longClick.fCallBack != NULL) {
|
||||
me->longClick.fCallBack(me->longClick.param);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case STCH_SINGLE_CLICK:
|
||||
|
||||
if(evid == evCHpbPress) {
|
||||
me->state = STCH_DOUBLE_CLICK;
|
||||
}
|
||||
|
||||
if(evid == evCHtimer) {
|
||||
me->state = STCH_WAIT;
|
||||
if(me->singleClick.fCallBack != NULL) {
|
||||
me->singleClick.fCallBack(me->singleClick.param);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case STCH_DOUBLE_CLICK:
|
||||
|
||||
if(evid == evCHpbRelease){
|
||||
me->state = STCH_WAIT;
|
||||
if(me->doubleClick.fCallBack != NULL){
|
||||
me->doubleClick.fCallBack(me->doubleClick.param);
|
||||
}
|
||||
}
|
||||
|
||||
if(evid == evCHtimer) {
|
||||
me->state = STCH_WAIT;
|
||||
if(me->doubleClick.fCallBack != NULL) {
|
||||
me->doubleClick.fCallBack(me->doubleClick.param);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if(oldState != me->state) {
|
||||
switch(oldState) {
|
||||
case STCH_INIT:
|
||||
break;
|
||||
|
||||
case STCH_WAIT:
|
||||
break;
|
||||
|
||||
case STCH_LONG_CLICK:
|
||||
break;
|
||||
|
||||
case STCH_SINGLE_CLICK:
|
||||
break;
|
||||
|
||||
case STCH_DOUBLE_CLICK:
|
||||
break;
|
||||
}
|
||||
processed = true;
|
||||
}
|
||||
return processed;
|
||||
}
|
||||
94
03-software/ch/kb28/blinkerProject/middleware/clickHandler.h
Normal file
94
03-software/ch/kb28/blinkerProject/middleware/clickHandler.h
Normal file
@@ -0,0 +1,94 @@
|
||||
/**
|
||||
* @author R<>mi Heredero (remi@heredero.ch)
|
||||
* @version. 1.0.0
|
||||
* @date 2023-06-15
|
||||
*/
|
||||
|
||||
#ifndef CLICKHANDLER_H
|
||||
#define CLICKHANDLER_H
|
||||
|
||||
#include "../xf/xf.h"
|
||||
#include "../board/button/button.h"
|
||||
|
||||
#define CH_CLICK_TIMER 250
|
||||
|
||||
typedef enum {
|
||||
STCH_INIT,
|
||||
STCH_WAIT,
|
||||
STCH_LONG_CLICK,
|
||||
STCH_SINGLE_CLICK,
|
||||
STCH_DOUBLE_CLICK
|
||||
} CLICK_HANDLER_STATES;
|
||||
|
||||
typedef enum {
|
||||
evCHinit = 100,
|
||||
evCHtimer,
|
||||
evCHpbPress,
|
||||
evCHpbRelease
|
||||
} CLICK_HANDLER_EVENTS;
|
||||
|
||||
typedef void (*fClickHandlerCallBack)(void*);
|
||||
typedef struct {
|
||||
fClickHandlerCallBack fCallBack;
|
||||
void* param;
|
||||
} clickHandlerCallBack;
|
||||
|
||||
typedef struct {
|
||||
BUTTON* button; // The button connected to the clickHandler
|
||||
CLICK_HANDLER_STATES state; // The actual state
|
||||
clickHandlerCallBack longClick; // Callback for longClick
|
||||
clickHandlerCallBack singleClick; // Callback for singleClick
|
||||
clickHandlerCallBack doubleClick; // Callback for doubleClick
|
||||
}CLICK_HANDLER;
|
||||
|
||||
/**
|
||||
* Initialize the clickHandler
|
||||
* @param me the clickHandler itself
|
||||
* @param b the button to connect on the clickHandler
|
||||
*/
|
||||
void CLICK_HANDLER_init(CLICK_HANDLER* me, BUTTON* b);
|
||||
|
||||
/**
|
||||
* Define a callback for CLICKHANDLER
|
||||
* @param f callback function for CLICKHANDLER
|
||||
* @param param callback parameter for the function
|
||||
* @return the callback struct
|
||||
*/
|
||||
clickHandlerCallBack CLICK_HANDLER_defineCallBack(fClickHandlerCallBack f, void* param);
|
||||
|
||||
/**
|
||||
* Start state machine of the CLICKHANDLER
|
||||
* @param me the clickHandler itself
|
||||
*/
|
||||
void CLICK_HANDLER_startBehaviour(CLICK_HANDLER* me);
|
||||
|
||||
/**
|
||||
* Set Callback eventfunction for long click
|
||||
* @param me the clickHandler itself
|
||||
* @param callBack callback function when the click handler have a long click
|
||||
*/
|
||||
void CLICK_HANDLER_setLongClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack);
|
||||
|
||||
/**
|
||||
* Set Callback event function for single click
|
||||
* @param me the clickHandler itself
|
||||
* @param callBack callback function when the click handler have a single click
|
||||
*/
|
||||
void CLICK_HANDLER_setSingleClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack);
|
||||
|
||||
/**
|
||||
* Set Callback evenet function for double click
|
||||
* @param me the clickHandler itself
|
||||
* @param callBack callback function when the click handler have a double click
|
||||
*/
|
||||
void CLICK_HANDLER_setDoubleClickCallback(CLICK_HANDLER* me, clickHandlerCallBack callBack);
|
||||
|
||||
/**
|
||||
* State machine of the CLICKHANDLER
|
||||
* @param ev event to process on the state machine
|
||||
*/
|
||||
bool CLICK_HANDLER_processEvent(Event* ev);
|
||||
|
||||
|
||||
#endif /* CLICKHANDLER_H */
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<logicalFolder name="factory" displayName="factory" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/app/factory/factory.h</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>ch/kb28/blinkerProject/app/ledblinker.h</itemPath>
|
||||
<itemPath>ch/kb28/blinkerProject/app/app.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="board" displayName="board" projectFiles="true">
|
||||
<logicalFolder name="button" displayName="button" projectFiles="true">
|
||||
@@ -28,6 +28,8 @@
|
||||
<itemPath>ch/kb28/blinkerProject/mcc_generated_files/device_config.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="middleware" displayName="middleware" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/middleware/clickHandler.h</itemPath>
|
||||
<itemPath>ch/kb28/blinkerProject/middleware/blinker.h</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="xf" displayName="xf" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/xf/ireactive.h</itemPath>
|
||||
@@ -46,8 +48,8 @@
|
||||
<logicalFolder name="factory" displayName="factory" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/app/factory/factory.c</itemPath>
|
||||
</logicalFolder>
|
||||
<itemPath>ch/kb28/blinkerProject/app/lebblinker.c</itemPath>
|
||||
<itemPath>ch/kb28/blinkerProject/app/main.c</itemPath>
|
||||
<itemPath>ch/kb28/blinkerProject/app/app.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="board" displayName="board" projectFiles="true">
|
||||
<logicalFolder name="button" displayName="button" projectFiles="true">
|
||||
@@ -67,6 +69,8 @@
|
||||
<itemPath>ch/kb28/blinkerProject/mcc_generated_files/tmr0.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="middleware" displayName="middleware" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/middleware/clickHandler.c</itemPath>
|
||||
<itemPath>ch/kb28/blinkerProject/middleware/blinker.c</itemPath>
|
||||
</logicalFolder>
|
||||
<logicalFolder name="xf" displayName="xf" projectFiles="true">
|
||||
<itemPath>ch/kb28/blinkerProject/xf/xf.c</itemPath>
|
||||
@@ -215,6 +219,7 @@
|
||||
<property key="debugoptions.debug-startup" value="Use system settings"/>
|
||||
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
|
||||
<property key="debugoptions.useswbreakpoints" value="false"/>
|
||||
<property key="firmware.download.all" value="false"/>
|
||||
<property key="hwtoolclock.frcindebug" value="false"/>
|
||||
<property key="memories.aux" value="false"/>
|
||||
<property key="memories.bootflash" value="true"/>
|
||||
@@ -259,6 +264,7 @@
|
||||
<property key="debugoptions.debug-startup" value="Use system settings"/>
|
||||
<property key="debugoptions.reset-behaviour" value="Use system settings"/>
|
||||
<property key="debugoptions.useswbreakpoints" value="false"/>
|
||||
<property key="firmware.download.all" value="false"/>
|
||||
<property key="hwtoolclock.frcindebug" value="false"/>
|
||||
<property key="memories.aux" value="false"/>
|
||||
<property key="memories.bootflash" value="true"/>
|
||||
|
||||
BIN
HerederoRemiSemProj.zip
Normal file
BIN
HerederoRemiSemProj.zip
Normal file
Binary file not shown.
23
README.md
23
README.md
@@ -1,2 +1,25 @@
|
||||
# blinkerProject
|
||||
## Purpose
|
||||
This project is made during the 4th semester of study in Industrial Systems at the University of Engineering in Sion, Wallis, Switzerland. It is used to learn the basics of software design and c on a PIC18F.
|
||||
|
||||
## Description
|
||||
The project is a simple blinker with two buttons and two leds
|
||||
- Click the first button: led1 starts blinking
|
||||
- Click the first button again: led1 stops blinking
|
||||
- Click the second button: led10 starts blinking
|
||||
- Click the second button again: led10 stops blinking
|
||||
- Double click the first button: led1 blinks three times
|
||||
- Double click the second button: led10 blinks three times
|
||||
- Long click either the first or the second button: led1 and led10 start blinking
|
||||
- Long click either the first or the second button again: led1 and led10 stop
|
||||
blinking
|
||||
|
||||
You'll find complet description of the project in the folder "01-task_description".
|
||||
You'll find all the diagrams description in UML in the folder "02-UML".
|
||||
Finally you'll find all the code in the folder "03-software".
|
||||
|
||||
A test diagram as been made and no error has been found.
|
||||
|
||||
## TODO
|
||||
- [ ] change the button class for add callback method like other class
|
||||
- [ ] change all "defineCallBack" method and define it directly in the setter
|
||||
Reference in New Issue
Block a user