Files
Embedded-Hacking/WEEK10/slides/WEEK10-IMG03.svg
T
Kevin Thomas 6a9090915b Initial commit
2026-07-06 21:23:12 -04:00

96 lines
4.5 KiB
XML

<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1200 800">
<style>
.bg{fill:#0a0a0f}.pnl{fill:#12121a;stroke:#1a1a2e}.hdr{fill:#12121a}
.title{font:bold 42px 'Courier New',monospace;fill:#00ff41}
.sub{font:bold 28px 'Courier New',monospace;fill:#00d4ff}
.txt{font:24px 'Courier New',monospace;fill:#c0c0c0}
.dim{font:20px 'Courier New',monospace;fill:#888}
.grn{font:bold 24px 'Courier New',monospace;fill:#00ff41}
.red{font:bold 24px 'Courier New',monospace;fill:#ff0040}
.cyn{font:bold 24px 'Courier New',monospace;fill:#00d4ff}
.amb{font:bold 24px 'Courier New',monospace;fill:#ffaa00}
.badge{stroke:#00ff41;rx:14}
</style>
<rect class="bg" width="1200" height="800"/>
<rect class="hdr" x="0" y="0" width="1200" height="100" rx="0"/>
<text class="title" x="600" y="52" text-anchor="middle">Dynamic Conditionals</text>
<text class="dim" x="600" y="88" text-anchor="middle">Runtime Input Changes the Path</text>
<!-- Code -->
<rect class="pnl" x="30" y="110" width="555" height="340" rx="8"/>
<text class="sub" x="50" y="150">Dynamic Code Pattern</text>
<rect x="50" y="170" width="515" height="260" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
<text class="cyn" x="70" y="200">uint8_t choice = 0;</text>
<text class="txt" x="70" y="235">while (true) {</text>
<text class="amb" x="100" y="270">choice = getchar();</text>
<text class="dim" x="100" y="300">// waits for keyboard input</text>
<text class="txt" x="100" y="330">if (choice == 0x31)</text>
<text class="grn" x="130" y="360">printf("1");</text>
<text class="txt" x="100" y="390">else if (choice == 0x32)</text>
<text class="grn" x="130" y="420">printf("2");</text>
<!-- Flow Diagram -->
<rect class="pnl" x="615" y="110" width="555" height="340" rx="8"/>
<text class="sub" x="635" y="150">Execution Flow</text>
<rect x="720" y="170" width="280" height="40" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
<text class="amb" x="740" y="197">choice = getchar()</text>
<line x1="860" y1="210" x2="860" y2="240" stroke="#888" stroke-width="2"/>
<rect x="720" y="245" width="200" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
<text class="cyn" x="820" y="272" text-anchor="middle">choice=='1'?</text>
<text class="grn" x="960" y="272">YES</text>
<line x1="920" y1="265" x2="955" y2="265" stroke="#00ff41" stroke-width="2"/>
<text class="dim" x="1030" y="272">servo 0-180</text>
<line x1="820" y1="285" x2="820" y2="310" stroke="#888" stroke-width="2"/>
<text class="red" x="840" y="307">NO</text>
<rect x="720" y="315" width="200" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
<text class="cyn" x="820" y="342" text-anchor="middle">choice=='2'?</text>
<text class="grn" x="960" y="342">YES</text>
<line x1="920" y1="335" x2="955" y2="335" stroke="#00ff41" stroke-width="2"/>
<text class="dim" x="1030" y="342">servo 180-0</text>
<line x1="820" y1="355" x2="820" y2="380" stroke="#888" stroke-width="2"/>
<text class="red" x="740" y="400">print "??"</text>
<text class="dim" x="635" y="435">Each iteration can take a DIFFERENT path</text>
<!-- getchar ASCII -->
<rect class="pnl" x="30" y="470" width="555" height="150" rx="8"/>
<text class="sub" x="50" y="510">getchar() Returns ASCII</text>
<text class="txt" x="50" y="545">'1' = 0x31</text>
<text class="txt" x="240" y="545">'2' = 0x32</text>
<text class="txt" x="50" y="580">'x' = 0x78</text>
<text class="txt" x="240" y="580">'y' = 0x79</text>
<text class="dim" x="410" y="545">Blocks until</text>
<text class="dim" x="410" y="580">keypress</text>
<!-- Behavior Table -->
<rect class="pnl" x="615" y="470" width="555" height="150" rx="8"/>
<text class="sub" x="635" y="510">Input --> Behavior</text>
<text class="amb" x="635" y="545">Key</text>
<text class="amb" x="740" y="545">Output</text>
<text class="amb" x="920" y="545">Servo</text>
<line x1="635" y1="555" x2="1150" y2="555" stroke="#1a1a2e" stroke-width="1"/>
<text class="txt" x="635" y="580">'1'</text>
<text class="grn" x="740" y="580">"1" + "one"</text>
<text class="dim" x="920" y="580">0deg --> 180deg</text>
<text class="txt" x="635" y="605">'2'</text>
<text class="grn" x="740" y="605">"2" + "two"</text>
<text class="dim" x="920" y="605">180deg --> 0deg</text>
<!-- Project Info -->
<rect class="pnl" x="30" y="640" width="1140" height="120" rx="8"/>
<text class="sub" x="50" y="680">Two Projects</text>
<text class="cyn" x="50" y="715">0x001d_static-conditionals</text>
<text class="dim" x="530" y="715">choice = 1 (fixed)</text>
<text class="cyn" x="50" y="745">0x0020_dynamic-conditionals</text>
<text class="dim" x="530" y="745">choice = getchar() (user input)</text>
</svg>