Initial commit with strict idiomatic rust enforcement
@@ -0,0 +1,79 @@
|
||||
<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"/>
|
||||
|
||||
<!-- Background grid decoration -->
|
||||
<g opacity="0.06">
|
||||
<line x1="0" y1="100" x2="1200" y2="100" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="200" x2="1200" y2="200" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="300" x2="1200" y2="300" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="400" x2="1200" y2="400" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="500" x2="1200" y2="500" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="600" x2="1200" y2="600" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="0" y1="700" x2="1200" y2="700" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="200" y1="0" x2="200" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="400" y1="0" x2="400" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="600" y1="0" x2="600" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="800" y1="0" x2="800" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
<line x1="1000" y1="0" x2="1000" y2="800" stroke="#00ff41" stroke-width="1"/>
|
||||
</g>
|
||||
|
||||
<!-- Hex rain decoration -->
|
||||
<g opacity="0.04" font-family="'Courier New',monospace" font-size="14" fill="#00ff41">
|
||||
<text x="50" y="80">4F 70 65 6E 4F 43 44</text>
|
||||
<text x="900" y="120">10 00 02 34 08 B5 01</text>
|
||||
<text x="150" y="180">47 44 42 20 52 45 56</text>
|
||||
<text x="800" y="240">20 08 20 00 FF AA 00</text>
|
||||
<text x="80" y="350">52 50 32 33 35 30 00</text>
|
||||
<text x="950" y="380">0A 0A 0F 12 12 1A 1A</text>
|
||||
<text x="100" y="520">41 52 4D 76 38 2D 4D</text>
|
||||
<text x="870" y="560">00 FF 41 00 D4 FF 88</text>
|
||||
<text x="60" y="680">47 48 49 44 52 41 00</text>
|
||||
<text x="920" y="720">FF 00 40 C0 C0 C0 00</text>
|
||||
</g>
|
||||
|
||||
<!-- Corner accents -->
|
||||
<polyline points="30,30 30,80 80,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,30 1170,80 1120,80" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="30,770 30,720 80,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
<polyline points="1170,770 1170,720 1120,720" fill="none" stroke="#00ff41" stroke-width="2" opacity="0.3"/>
|
||||
|
||||
<!-- Top accent line -->
|
||||
<rect x="100" y="140" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- Course Title -->
|
||||
<text x="600" y="210" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Embedded Systems</text>
|
||||
<text x="600" y="278" text-anchor="middle" font-family="'Courier New',monospace" font-size="56" font-weight="bold" fill="#00ff41">Reverse Engineering</text>
|
||||
|
||||
<!-- Divider -->
|
||||
<rect x="300" y="310" width="600" height="2" fill="#00d4ff" opacity="0.6"/>
|
||||
|
||||
<!-- Week Number -->
|
||||
<text x="600" y="380" text-anchor="middle" font-family="'Courier New',monospace" font-size="42" font-weight="bold" fill="#00d4ff">// WEEK 10</text>
|
||||
|
||||
<!-- Week Topic -->
|
||||
<text x="600" y="440" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Conditionals in Embedded Systems:</text>
|
||||
<text x="600" y="478" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Debugging and Hacking Static & Dynamic</text>
|
||||
<text x="600" y="516" text-anchor="middle" font-family="'Courier New',monospace" font-size="28" fill="#c0c0c0">Conditionals w/ SG90 Servo Motor PWM</text>
|
||||
|
||||
<!-- Bottom accent line -->
|
||||
<rect x="100" y="570" width="1000" height="2" fill="#00ff41" opacity="0.4"/>
|
||||
|
||||
<!-- University -->
|
||||
<text x="600" y="635" text-anchor="middle" font-family="'Courier New',monospace" font-size="36" font-weight="bold" fill="#ffaa00">George Mason University</text>
|
||||
|
||||
<!-- Bottom badge -->
|
||||
<rect x="400" y="670" width="400" height="40" rx="20" fill="none" stroke="#00ff41" stroke-width="1.5" opacity="0.5"/>
|
||||
<text x="600" y="697" text-anchor="middle" font-family="'Courier New',monospace" font-size="20" fill="#00ff41" opacity="0.7">RP2350 // ARM Cortex-M33</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,82 @@
|
||||
<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">Conditionals Overview</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Static vs Dynamic Decision Making</text>
|
||||
|
||||
<!-- What Are Conditionals -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="150">What Are Conditionals?</text>
|
||||
<text class="txt" x="50" y="185">Structures that let programs choose</text>
|
||||
<text class="txt" x="50" y="215">different paths based on conditions</text>
|
||||
|
||||
<!-- Static -->
|
||||
<rect class="pnl" x="30" y="250" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="290">Static Conditional</text>
|
||||
<text class="dim" x="50" y="320">Value fixed at compile time</text>
|
||||
|
||||
<rect x="50" y="340" width="515" height="150" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="370">int choice = 1;</text>
|
||||
<text class="dim" x="370" y="370">// never changes</text>
|
||||
<text class="txt" x="70" y="400">if (choice == 1)</text>
|
||||
<text class="grn" x="100" y="430">printf("1");</text>
|
||||
<text class="dim" x="370" y="430">// always runs</text>
|
||||
<text class="red" x="70" y="460">else printf("2");</text>
|
||||
<text class="dim" x="370" y="460">// never runs</text>
|
||||
|
||||
<!-- Dynamic -->
|
||||
<rect class="pnl" x="615" y="250" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="635" y="290">Dynamic Conditional</text>
|
||||
<text class="dim" x="635" y="320">Value changes at runtime</text>
|
||||
|
||||
<rect x="635" y="340" width="515" height="150" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="655" y="370">choice = getchar();</text>
|
||||
<text class="dim" x="655" y="398">// user types a key</text>
|
||||
<text class="txt" x="655" y="428">if (choice == '1')</text>
|
||||
<text class="grn" x="685" y="458">printf("1");</text>
|
||||
<text class="dim" x="895" y="458">// maybe runs</text>
|
||||
|
||||
<!-- Two Control Structures -->
|
||||
<rect class="pnl" x="30" y="530" width="555" height="230" rx="8"/>
|
||||
<text class="sub" x="50" y="570">if/else</text>
|
||||
|
||||
<text class="amb" x="50" y="605">Feature</text>
|
||||
<text class="amb" x="280" y="605">Description</text>
|
||||
<line x1="50" y1="615" x2="565" y2="615" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="645">Condition</text>
|
||||
<text class="dim" x="280" y="645">Any boolean expr</text>
|
||||
<text class="txt" x="50" y="675">Values</text>
|
||||
<text class="dim" x="280" y="675">Ranges, complex logic</text>
|
||||
<text class="txt" x="50" y="705">Fall-through</text>
|
||||
<text class="dim" x="280" y="705">No</text>
|
||||
<text class="txt" x="50" y="735">Best for</text>
|
||||
<text class="dim" x="280" y="735">2-3 conditions</text>
|
||||
|
||||
<!-- switch/case -->
|
||||
<rect class="pnl" x="615" y="530" width="555" height="230" rx="8"/>
|
||||
<text class="sub" x="635" y="570">switch/case</text>
|
||||
|
||||
<text class="amb" x="635" y="605">Feature</text>
|
||||
<text class="amb" x="865" y="605">Description</text>
|
||||
<line x1="635" y1="615" x2="1150" y2="615" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="635" y="645">Condition</text>
|
||||
<text class="dim" x="865" y="645">Single variable</text>
|
||||
<text class="txt" x="635" y="675">Values</text>
|
||||
<text class="dim" x="865" y="675">Discrete only</text>
|
||||
<text class="txt" x="635" y="705">Fall-through</text>
|
||||
<text class="dim" x="865" y="705">Yes (no break)</text>
|
||||
<text class="txt" x="635" y="735">Best for</text>
|
||||
<text class="dim" x="865" y="735">Many conditions</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,89 @@
|
||||
<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">Static Conditionals</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Fixed Outcome -- Same Path Every Time</text>
|
||||
|
||||
<!-- Code -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="320" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Static Code Pattern</text>
|
||||
<rect x="50" y="170" width="515" height="240" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="70" y="200">int choice = 1;</text>
|
||||
<text class="dim" x="370" y="200">// NEVER changes</text>
|
||||
<text class="txt" x="70" y="235">while (true) {</text>
|
||||
<text class="txt" x="100" y="270">if (choice == 1)</text>
|
||||
<text class="grn" x="130" y="300">printf("1");</text>
|
||||
<text class="txt" x="100" y="330">else if (choice == 2)</text>
|
||||
<text class="red" x="130" y="360">printf("2");</text>
|
||||
<text class="dim" x="370" y="360">// dead code</text>
|
||||
<text class="txt" x="100" y="390">else</text>
|
||||
|
||||
<!-- Flow Diagram -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="320" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Execution Flow</text>
|
||||
|
||||
<rect x="680" y="175" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="690" y="202">choice == 1?</text>
|
||||
|
||||
<line x1="870" y1="195" x2="910" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="grn" x="915" y="202">YES</text>
|
||||
|
||||
<rect x="980" y="175" width="150" height="40" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="1055" y="202" text-anchor="middle">print "1"</text>
|
||||
|
||||
<text class="red" x="790" y="245">NO (never taken)</text>
|
||||
<line x1="775" y1="215" x2="775" y2="255" stroke="#ff0040" stroke-width="1" stroke-dasharray="4"/>
|
||||
|
||||
<rect x="680" y="260" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#1a1a2e" stroke-dasharray="4"/>
|
||||
<text class="dim" x="710" y="287">choice == 2?</text>
|
||||
|
||||
<text class="dim" x="700" y="330">NO (never reached)</text>
|
||||
|
||||
<rect x="680" y="345" width="190" height="40" rx="6" fill="#0a0a0f" stroke="#1a1a2e" stroke-dasharray="4"/>
|
||||
<text class="dim" x="710" y="372">print "?"</text>
|
||||
|
||||
<text class="dim" x="635" y="415">Only ONE path ever executes!</text>
|
||||
|
||||
<!-- Execution Trace -->
|
||||
<rect class="pnl" x="30" y="450" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="490">Every Loop Iteration (Always the Same)</text>
|
||||
<text class="grn" x="50" y="525">1. if(1==1) --> TRUE</text>
|
||||
<text class="grn" x="450" y="525">2. print "1"</text>
|
||||
<text class="grn" x="720" y="525">3. switch(1) case 1</text>
|
||||
<text class="grn" x="50" y="555">4. print "one"</text>
|
||||
<text class="grn" x="350" y="555">5. servo 0deg</text>
|
||||
<text class="grn" x="620" y="555">6. sleep 500ms</text>
|
||||
<text class="grn" x="900" y="555">7. servo 180deg</text>
|
||||
|
||||
<!-- Serial Output -->
|
||||
<rect class="pnl" x="30" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="630">Serial Output (Forever)</text>
|
||||
<rect x="50" y="645" width="515" height="95" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="grn" x="70" y="675">1</text>
|
||||
<text class="grn" x="70" y="700">one</text>
|
||||
<text class="grn" x="70" y="725">1</text>
|
||||
<text class="dim" x="150" y="700">// repeats forever</text>
|
||||
|
||||
<!-- Servo -->
|
||||
<rect class="pnl" x="615" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="635" y="630">Servo Motion (Forever)</text>
|
||||
<text class="txt" x="635" y="670">0deg</text>
|
||||
<text class="amb" x="730" y="670">--></text>
|
||||
<text class="txt" x="800" y="670">180deg</text>
|
||||
<text class="amb" x="920" y="670">--></text>
|
||||
<text class="txt" x="990" y="670">0deg</text>
|
||||
<text class="dim" x="635" y="705">Sweeps back and forth, 500ms each</text>
|
||||
<text class="dim" x="635" y="735">Continuous, predictable motion</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.3 KiB |
@@ -0,0 +1,95 @@
|
||||
<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>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,96 @@
|
||||
<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">PWM Basics</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Pulse Width Modulation for Servo Control</text>
|
||||
|
||||
<!-- What is PWM -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="150">What is PWM?</text>
|
||||
<text class="txt" x="50" y="185">Rapidly switching a signal ON and OFF</text>
|
||||
<text class="dim" x="50" y="213">Ratio of on-time to off-time controls power</text>
|
||||
|
||||
<!-- PWM waveform diagram -->
|
||||
<text class="grn" x="650" y="155">HIGH</text>
|
||||
<line x1="700" y1="165" x2="700" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="700" y1="165" x2="830" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="830" y1="165" x2="830" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="830" y1="195" x2="920" y2="195" stroke="#888" stroke-width="2"/>
|
||||
<line x1="920" y1="195" x2="920" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="920" y1="165" x2="1050" y2="165" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="1050" y1="165" x2="1050" y2="195" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="1050" y1="195" x2="1140" y2="195" stroke="#888" stroke-width="2"/>
|
||||
<text class="dim" x="650" y="230">ON</text>
|
||||
<text class="dim" x="750" y="230">OFF</text>
|
||||
<text class="dim" x="850" y="230">ON</text>
|
||||
<text class="dim" x="990" y="230">OFF</text>
|
||||
|
||||
<!-- Servo Pulse Widths -->
|
||||
<rect class="pnl" x="30" y="290" width="1140" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="330">Servo PWM (50Hz = 20ms period)</text>
|
||||
|
||||
<!-- 0 degrees -->
|
||||
<text class="amb" x="50" y="370">0deg (1ms pulse):</text>
|
||||
<line x1="330" y1="355" x2="380" y2="355" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="380" y1="355" x2="380" y2="375" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="380" y1="375" x2="900" y2="375" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="400" y="370">1ms HIGH</text>
|
||||
<text class="dim" x="700" y="370">19ms LOW</text>
|
||||
|
||||
<!-- 90 degrees -->
|
||||
<text class="amb" x="50" y="420">90deg (1.5ms pulse):</text>
|
||||
<line x1="330" y1="405" x2="410" y2="405" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="410" y1="405" x2="410" y2="425" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="410" y1="425" x2="900" y2="425" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="430" y="420">1.5ms HIGH</text>
|
||||
<text class="dim" x="700" y="420">18.5ms LOW</text>
|
||||
|
||||
<!-- 180 degrees -->
|
||||
<text class="amb" x="50" y="470">180deg (2ms pulse):</text>
|
||||
<line x1="330" y1="455" x2="440" y2="455" stroke="#00ff41" stroke-width="3"/>
|
||||
<line x1="440" y1="455" x2="440" y2="475" stroke="#00ff41" stroke-width="2"/>
|
||||
<line x1="440" y1="475" x2="900" y2="475" stroke="#888" stroke-width="1" stroke-dasharray="3"/>
|
||||
<text class="dim" x="460" y="470">2ms HIGH</text>
|
||||
<text class="dim" x="700" y="470">18ms LOW</text>
|
||||
|
||||
<text class="dim" x="50" y="510">Pulse WIDTH determines angle, not duty cycle</text>
|
||||
<text class="dim" x="50" y="535">Total period always 20ms (50Hz)</text>
|
||||
|
||||
<!-- Angle Table -->
|
||||
<rect class="pnl" x="30" y="570" width="555" height="190" rx="8"/>
|
||||
<text class="sub" x="50" y="610">Angle to Pulse Width</text>
|
||||
|
||||
<text class="amb" x="50" y="645">Angle</text>
|
||||
<text class="amb" x="180" y="645">Pulse</text>
|
||||
<text class="amb" x="340" y="645">Ticks (1MHz)</text>
|
||||
<line x1="50" y1="655" x2="565" y2="655" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="685">0deg</text>
|
||||
<text class="grn" x="180" y="685">1000us</text>
|
||||
<text class="dim" x="340" y="685">1000</text>
|
||||
<text class="txt" x="50" y="715">90deg</text>
|
||||
<text class="grn" x="180" y="715">1500us</text>
|
||||
<text class="dim" x="340" y="715">1500</text>
|
||||
<text class="txt" x="50" y="745">180deg</text>
|
||||
<text class="grn" x="180" y="745">2000us</text>
|
||||
<text class="dim" x="340" y="745">2000</text>
|
||||
|
||||
<!-- Formula -->
|
||||
<rect class="pnl" x="615" y="570" width="555" height="190" rx="8"/>
|
||||
<text class="sub" x="635" y="610">Formula</text>
|
||||
<text class="cyn" x="635" y="650">pulse = 1000 + (angle/180) x 1000</text>
|
||||
<text class="dim" x="635" y="685">Example for 90deg:</text>
|
||||
<text class="txt" x="635" y="715">1000 + (90/180) x 1000</text>
|
||||
<text class="grn" x="635" y="745">= 1500us = 1500 ticks</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.8 KiB |
@@ -0,0 +1,83 @@
|
||||
<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">PWM Timing Chain</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">150MHz System Clock to 50Hz Servo Signal</text>
|
||||
|
||||
<!-- Clock Division Chain -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="230" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Clock Division</text>
|
||||
|
||||
<rect x="50" y="175" width="250" height="50" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="95" y="207">150 MHz Clock</text>
|
||||
|
||||
<text class="amb" x="320" y="207">/ 150</text>
|
||||
<line x1="300" y1="200" x2="315" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
<line x1="395" y1="200" x2="415" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
|
||||
<rect x="420" y="175" width="250" height="50" rx="6" fill="#0a0a0f" stroke="#00ff41"/>
|
||||
<text class="grn" x="475" y="207">1 MHz PWM</text>
|
||||
|
||||
<text class="dim" x="690" y="207">1 tick = 1us</text>
|
||||
|
||||
<line x1="670" y1="200" x2="685" y2="200" stroke="#ffaa00" stroke-width="2"/>
|
||||
|
||||
<text class="txt" x="50" y="260">Step 1: 150,000,000 / 150 = 1,000,000 Hz</text>
|
||||
<text class="dim" x="50" y="290">Each PWM tick = exactly 1 microsecond</text>
|
||||
|
||||
<text class="txt" x="50" y="320">Step 2: Wrap at 20,000 ticks = 20ms = 50Hz</text>
|
||||
<text class="dim" x="680" y="320">Wrap value = 19,999</text>
|
||||
|
||||
<!-- SG90 Specs -->
|
||||
<rect class="pnl" x="30" y="360" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="50" y="400">SG90 Servo Motor</text>
|
||||
|
||||
<text class="amb" x="50" y="435">Parameter</text>
|
||||
<text class="amb" x="300" y="435">Value</text>
|
||||
<line x1="50" y1="445" x2="565" y2="445" stroke="#1a1a2e" stroke-width="1"/>
|
||||
<text class="txt" x="50" y="475">Voltage</text>
|
||||
<text class="dim" x="300" y="475">4.8V - 6V (use 5V)</text>
|
||||
<text class="txt" x="50" y="505">Rotation</text>
|
||||
<text class="dim" x="300" y="505">0deg to 180deg</text>
|
||||
<text class="txt" x="50" y="535">Pulse Width</text>
|
||||
<text class="dim" x="300" y="535">1000us - 2000us</text>
|
||||
<text class="txt" x="50" y="565">Frequency</text>
|
||||
<text class="dim" x="300" y="565">50Hz (20ms period)</text>
|
||||
|
||||
<!-- Wiring -->
|
||||
<rect class="pnl" x="615" y="360" width="555" height="220" rx="8"/>
|
||||
<text class="sub" x="635" y="400">Wiring to Pico 2</text>
|
||||
|
||||
<rect x="635" y="425" width="100" height="45" rx="4" fill="#0a0a0f" stroke="#00d4ff" stroke-width="1"/>
|
||||
<text class="cyn" x="655" y="454">Pico</text>
|
||||
|
||||
<rect x="1040" y="425" width="100" height="45" rx="4" fill="#0a0a0f" stroke="#ffaa00" stroke-width="1"/>
|
||||
<text class="amb" x="1060" y="454">SG90</text>
|
||||
|
||||
<line x1="735" y1="438" x2="1040" y2="438" stroke="#ffaa00" stroke-width="2"/>
|
||||
<line x1="735" y1="458" x2="1040" y2="458" stroke="#ff0040" stroke-width="2"/>
|
||||
|
||||
<text class="dim" x="635" y="495">GPIO 6 = Signal (Orange)</text>
|
||||
<text class="dim" x="635" y="520">VBUS 5V = VCC (Red)</text>
|
||||
<text class="dim" x="635" y="545">GND = GND (Brown)</text>
|
||||
<text class="red" x="635" y="570">Add 1000uF capacitor on power!</text>
|
||||
|
||||
<!-- Power Warning -->
|
||||
<rect class="pnl" x="30" y="600" width="1140" height="160" rx="8"/>
|
||||
<text class="sub" x="50" y="640">Power Safety</text>
|
||||
<text class="red" x="50" y="675">NEVER use 3.3V pin for servo!</text>
|
||||
<text class="txt" x="50" y="710">Servos draw 650mA+ (spikes to 1A)</text>
|
||||
<text class="dim" x="50" y="740">Use VBUS (5V from USB) with 1000uF 25V capacitor</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.9 KiB |
@@ -0,0 +1,55 @@
|
||||
<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">Static Source Code</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">0x001d_static-conditionals.c</text>
|
||||
|
||||
<!-- Source Code -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="490" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Full Source</text>
|
||||
<rect x="50" y="170" width="1100" height="410" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
|
||||
<text class="dim" x="70" y="200">#include <stdio.h></text>
|
||||
<text class="dim" x="70" y="225">#include "pico/stdlib.h"</text>
|
||||
<text class="dim" x="70" y="250">#include "servo.h"</text>
|
||||
<text class="cyn" x="70" y="280">#define SERVO_GPIO 6</text>
|
||||
|
||||
<text class="cyn" x="70" y="315">int main(void) {</text>
|
||||
<text class="txt" x="100" y="345">stdio_init_all();</text>
|
||||
<text class="amb" x="100" y="375">int choice = 1;</text>
|
||||
<text class="dim" x="430" y="375">// STATIC!</text>
|
||||
<text class="txt" x="100" y="405">servo_init(SERVO_GPIO);</text>
|
||||
|
||||
<text class="txt" x="100" y="440">while (true) {</text>
|
||||
<text class="txt" x="130" y="470">if (choice == 1)</text>
|
||||
<text class="grn" x="160" y="500">printf("1\r\n");</text>
|
||||
<text class="txt" x="130" y="530">else if (choice == 2)</text>
|
||||
<text class="dim" x="160" y="560">printf("2\r\n");</text>
|
||||
<text class="dim" x="430" y="560">// dead code</text>
|
||||
|
||||
<!-- Bottom section: switch + servo -->
|
||||
<rect class="pnl" x="30" y="610" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="650">switch Block</text>
|
||||
<rect x="50" y="665" width="515" height="75" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="70" y="693">switch(choice) {</text>
|
||||
<text class="txt" x="100" y="718">case 1: puts("one"); break;</text>
|
||||
|
||||
<rect class="pnl" x="615" y="610" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="650">Servo Loop</text>
|
||||
<rect x="635" y="665" width="515" height="75" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="655" y="693">servo_set_angle(0.0f);</text>
|
||||
<text class="txt" x="655" y="718">sleep_ms(500);</text>
|
||||
<text class="dim" x="900" y="718">// then 180</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.7 KiB |
@@ -0,0 +1,50 @@
|
||||
<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 Source Code</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">0x0020_dynamic-conditionals.c</text>
|
||||
|
||||
<!-- Source Code -->
|
||||
<rect class="pnl" x="30" y="110" width="1140" height="530" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Full Source</text>
|
||||
<rect x="50" y="170" width="1100" height="450" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
|
||||
<text class="dim" x="70" y="200">#include <stdio.h></text>
|
||||
<text class="dim" x="70" y="225">#include "pico/stdlib.h"</text>
|
||||
<text class="dim" x="70" y="250">#include "servo.h"</text>
|
||||
<text class="cyn" x="70" y="280">#define SERVO_GPIO 6</text>
|
||||
|
||||
<text class="cyn" x="70" y="315">int main(void) {</text>
|
||||
<text class="txt" x="100" y="345">stdio_init_all();</text>
|
||||
<text class="amb" x="100" y="375">uint8_t choice = 0;</text>
|
||||
<text class="dim" x="430" y="375">// DYNAMIC!</text>
|
||||
<text class="txt" x="100" y="405">servo_init(SERVO_GPIO);</text>
|
||||
|
||||
<text class="txt" x="100" y="440">while (true) {</text>
|
||||
<text class="amb" x="130" y="470">choice = getchar();</text>
|
||||
<text class="dim" x="430" y="470">// wait for input</text>
|
||||
<text class="txt" x="130" y="500">if (choice == 0x31)</text>
|
||||
<text class="dim" x="430" y="500">// '1'</text>
|
||||
<text class="grn" x="160" y="530">printf("1\r\n");</text>
|
||||
<text class="txt" x="130" y="560">else if (choice == 0x32)</text>
|
||||
<text class="dim" x="430" y="560">// '2'</text>
|
||||
<text class="grn" x="160" y="590">printf("2\r\n");</text>
|
||||
|
||||
<!-- switch block with servo -->
|
||||
<rect class="pnl" x="30" y="660" width="1140" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="695">switch Block (with servo control)</text>
|
||||
<text class="txt" x="50" y="730">case '1': print "one", servo 0-->180, sleep 500ms</text>
|
||||
<text class="txt" x="50" y="750">case '2': print "two", servo 180-->0, sleep 500ms</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 2.5 KiB |
@@ -0,0 +1,101 @@
|
||||
<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">Branch Instructions</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">How Conditionals Become Assembly</text>
|
||||
|
||||
<!-- Branch Instruction Table -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="50" y="150">ARM Branch Instructions</text>
|
||||
|
||||
<text class="amb" x="50" y="190">Instr</text>
|
||||
<text class="amb" x="170" y="190">Meaning</text>
|
||||
<text class="amb" x="440" y="190">Condition</text>
|
||||
<line x1="50" y1="200" x2="565" y2="200" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="grn" x="50" y="230">b</text>
|
||||
<text class="txt" x="170" y="230">Branch always</text>
|
||||
<text class="dim" x="440" y="230">Always</text>
|
||||
|
||||
<text class="grn" x="50" y="260">beq</text>
|
||||
<text class="txt" x="170" y="260">Branch if Equal</text>
|
||||
<text class="dim" x="440" y="260">Z flag set</text>
|
||||
|
||||
<text class="grn" x="50" y="290">bne</text>
|
||||
<text class="txt" x="170" y="290">Branch if !=</text>
|
||||
<text class="dim" x="440" y="290">Z flag clear</text>
|
||||
|
||||
<text class="grn" x="50" y="320">bgt</text>
|
||||
<text class="txt" x="170" y="320">Branch if ></text>
|
||||
<text class="dim" x="440" y="320">Signed ></text>
|
||||
|
||||
<text class="grn" x="50" y="350">blt</text>
|
||||
<text class="txt" x="170" y="350">Branch if <</text>
|
||||
<text class="dim" x="440" y="350">Signed <</text>
|
||||
|
||||
<!-- C to Assembly -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="260" rx="8"/>
|
||||
<text class="sub" x="635" y="150">C --> Assembly</text>
|
||||
|
||||
<text class="dim" x="635" y="182">C code:</text>
|
||||
<rect x="635" y="192" width="515" height="60" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="txt" x="655" y="218">if (choice == 0x31)</text>
|
||||
<text class="grn" x="675" y="243">printf("1");</text>
|
||||
|
||||
<text class="dim" x="635" y="280">Assembly:</text>
|
||||
<rect x="635" y="290" width="515" height="70" rx="6" fill="#0a0a0f" stroke="#1a1a2e"/>
|
||||
<text class="cyn" x="655" y="318">cmp r4, #0x31</text>
|
||||
<text class="dim" x="900" y="318">// compare</text>
|
||||
<text class="cyn" x="655" y="346">bne skip_printf</text>
|
||||
<text class="dim" x="900" y="346">// skip if !=</text>
|
||||
|
||||
<!-- Flow Diagram -->
|
||||
<rect class="pnl" x="30" y="390" width="1140" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="430">Conditional Branch Flow</text>
|
||||
|
||||
<rect x="50" y="450" width="230" height="42" rx="6" fill="#0a0a0f" stroke="#00d4ff"/>
|
||||
<text class="cyn" x="165" y="478" text-anchor="middle">cmp r4, #0x31</text>
|
||||
|
||||
<line x1="280" y1="471" x2="320" y2="471" stroke="#888" stroke-width="2"/>
|
||||
|
||||
<rect x="325" y="450" width="270" height="42" rx="6" fill="#0a0a0f" stroke="#ffaa00"/>
|
||||
<text class="amb" x="460" y="478" text-anchor="middle">beq target_addr</text>
|
||||
|
||||
<line x1="595" y1="460" x2="650" y2="460" stroke="#00ff41" stroke-width="2"/>
|
||||
<text class="grn" x="660" y="464">r4==0x31: JUMP</text>
|
||||
|
||||
<line x1="440" y1="492" x2="440" y2="515" stroke="#ff0040" stroke-width="2"/>
|
||||
<text class="red" x="465" y="515">r4!=0x31: continue next</text>
|
||||
|
||||
<text class="dim" x="50" y="548">cmp sets CPU flags, branch reads them</text>
|
||||
|
||||
<!-- NOP Encoding -->
|
||||
<rect class="pnl" x="30" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="50" y="630">NOP (No Operation)</text>
|
||||
<text class="txt" x="50" y="665">ARM Thumb NOP:</text>
|
||||
<text class="grn" x="320" y="665">00 bf</text>
|
||||
<text class="dim" x="420" y="665">2 bytes</text>
|
||||
<text class="txt" x="50" y="700">Wide NOP:</text>
|
||||
<text class="grn" x="320" y="700">00 f0 00 80</text>
|
||||
<text class="dim" x="50" y="730">Replaces 4-byte bl instruction</text>
|
||||
|
||||
<!-- Hacking Branches -->
|
||||
<rect class="pnl" x="615" y="590" width="555" height="170" rx="8"/>
|
||||
<text class="sub" x="635" y="630">Hacking Branches</text>
|
||||
<text class="txt" x="635" y="665">Change branch target addr</text>
|
||||
<text class="dim" x="635" y="690">Redirect program flow</text>
|
||||
<text class="txt" x="635" y="715">NOP out instructions</text>
|
||||
<text class="dim" x="635" y="740">Erase code silently</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
@@ -0,0 +1,83 @@
|
||||
<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">Hacking Conditionals</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Strings, Timing, Stealth Commands</text>
|
||||
|
||||
<!-- Hack 1: String -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Hack 1: Change Strings</text>
|
||||
<text class="txt" x="50" y="185">Change "1" to "2":</text>
|
||||
<text class="red" x="340" y="185">0x31</text>
|
||||
<text class="amb" x="420" y="185">--></text>
|
||||
<text class="grn" x="480" y="185">0x32</text>
|
||||
<text class="txt" x="50" y="220">"one" to "fun":</text>
|
||||
<text class="red" x="280" y="220">6f 6e 65</text>
|
||||
<text class="amb" x="410" y="220">--></text>
|
||||
<text class="grn" x="460" y="220">66 75 6e</text>
|
||||
|
||||
<!-- Hack 2: Timing -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="150" rx="8"/>
|
||||
<text class="sub" x="635" y="150">Hack 2: Speed Up Servo</text>
|
||||
<text class="txt" x="635" y="185">Change sleep_ms delay:</text>
|
||||
<text class="red" x="635" y="220">0x1F4 (500ms)</text>
|
||||
<text class="amb" x="860" y="220">--></text>
|
||||
<text class="grn" x="920" y="220">0x064 (100ms)</text>
|
||||
|
||||
<!-- Hack 3: Stealth -->
|
||||
<rect class="pnl" x="30" y="280" width="1140" height="240" rx="8"/>
|
||||
<text class="sub" x="50" y="320">Hack 3: Stealth Commands</text>
|
||||
<text class="dim" x="50" y="348">Hidden keys move servo with NO output</text>
|
||||
|
||||
<text class="amb" x="50" y="383">Patch</text>
|
||||
<text class="amb" x="280" y="383">Original</text>
|
||||
<text class="amb" x="530" y="383">Hacked</text>
|
||||
<text class="amb" x="800" y="383">Purpose</text>
|
||||
<line x1="50" y1="393" x2="1140" y2="393" stroke="#1a1a2e" stroke-width="1"/>
|
||||
|
||||
<text class="txt" x="50" y="423">Compare 1</text>
|
||||
<text class="red" x="280" y="423">#0x31 ('1')</text>
|
||||
<text class="grn" x="530" y="423">#0x78 ('x')</text>
|
||||
<text class="dim" x="800" y="423">New trigger key</text>
|
||||
|
||||
<text class="txt" x="50" y="453">Compare 2</text>
|
||||
<text class="red" x="280" y="453">#0x32 ('2')</text>
|
||||
<text class="grn" x="530" y="453">#0x79 ('y')</text>
|
||||
<text class="dim" x="800" y="453">New trigger key</text>
|
||||
|
||||
<text class="txt" x="50" y="483">puts calls</text>
|
||||
<text class="red" x="280" y="483">bl puts</text>
|
||||
<text class="grn" x="530" y="483">00 bf 00 bf</text>
|
||||
<text class="dim" x="800" y="483">NOP out prints</text>
|
||||
|
||||
<!-- Hack 4: Angle -->
|
||||
<rect class="pnl" x="30" y="540" width="555" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="575">Hack 4: Change Angle</text>
|
||||
<text class="txt" x="50" y="610">180.0f --> 30.0f:</text>
|
||||
<text class="red" x="50" y="640">00 00 34 43</text>
|
||||
<text class="amb" x="260" y="640">--></text>
|
||||
<text class="grn" x="320" y="640">00 00 f0 41</text>
|
||||
|
||||
<!-- Result -->
|
||||
<rect class="pnl" x="615" y="540" width="555" height="120" rx="8"/>
|
||||
<text class="sub" x="635" y="575">Stealth Result</text>
|
||||
<text class="txt" x="635" y="610">'1','2': normal output + servo</text>
|
||||
<text class="cyn" x="635" y="640">'x','y': NO output, servo moves</text>
|
||||
|
||||
<!-- Bottom summary -->
|
||||
<rect class="pnl" x="30" y="680" width="1140" height="80" rx="8"/>
|
||||
<text class="sub" x="50" y="715">Workflow</text>
|
||||
<text class="dim" x="50" y="740">Patch bytes in Ghidra --> export .bin --> convert to UF2 --> flash to Pico</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 3.8 KiB |
@@ -0,0 +1,85 @@
|
||||
<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">PWM & Servo Hacking</text>
|
||||
<text class="dim" x="600" y="88" text-anchor="middle">Conditionals, PWM, Servo, and Hacking</text>
|
||||
|
||||
<!-- Static vs Dynamic -->
|
||||
<rect class="pnl" x="30" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="50" y="150">Static vs Dynamic</text>
|
||||
|
||||
<text class="grn" x="50" y="185">Static</text>
|
||||
<text class="dim" x="200" y="185">choice = 1 (fixed)</text>
|
||||
<text class="dim" x="200" y="210">Same path every iteration</text>
|
||||
<text class="dim" x="200" y="235">Compiler may optimize</text>
|
||||
|
||||
<text class="cyn" x="50" y="270">Dynamic</text>
|
||||
<text class="dim" x="200" y="270">choice = getchar()</text>
|
||||
<text class="dim" x="200" y="295">Different paths at runtime</text>
|
||||
|
||||
<!-- PWM -->
|
||||
<rect class="pnl" x="615" y="110" width="555" height="200" rx="8"/>
|
||||
<text class="sub" x="635" y="150">PWM for Servos</text>
|
||||
<text class="txt" x="635" y="185">150MHz / 150 = 1MHz tick</text>
|
||||
<text class="txt" x="635" y="220">Wrap 20000 = 50Hz (20ms)</text>
|
||||
<text class="dim" x="635" y="255">0deg=1000us 90deg=1500us 180deg=2000us</text>
|
||||
<text class="cyn" x="635" y="290">pulse = 1000 + (angle/180) x 1000</text>
|
||||
|
||||
<!-- Branch Instructions -->
|
||||
<rect class="pnl" x="30" y="330" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="50" y="370">Branch Instructions</text>
|
||||
<text class="grn" x="50" y="405">cmp r4, #0x31</text>
|
||||
<text class="dim" x="350" y="405">Compare</text>
|
||||
<text class="grn" x="50" y="435">beq target</text>
|
||||
<text class="dim" x="350" y="435">Jump if equal</text>
|
||||
<text class="grn" x="50" y="465">bne target</text>
|
||||
<text class="dim" x="350" y="465">Jump if not equal</text>
|
||||
<text class="dim" x="50" y="495">NOP = 00 bf (erase code)</text>
|
||||
|
||||
<!-- Key Addresses -->
|
||||
<rect class="pnl" x="615" y="330" width="555" height="180" rx="8"/>
|
||||
<text class="sub" x="635" y="370">Key Values</text>
|
||||
<text class="cyn" x="635" y="405">0x10000234</text>
|
||||
<text class="dim" x="870" y="405">main()</text>
|
||||
<text class="cyn" x="635" y="435">0x40070000</text>
|
||||
<text class="dim" x="870" y="435">UART0</text>
|
||||
<text class="cyn" x="635" y="465">0x1F4</text>
|
||||
<text class="dim" x="870" y="465">500 (sleep_ms)</text>
|
||||
<text class="cyn" x="635" y="495">0x43340000</text>
|
||||
<text class="dim" x="870" y="495">180.0f IEEE-754</text>
|
||||
|
||||
<!-- Hacking Techniques -->
|
||||
<rect class="pnl" x="30" y="530" width="1140" height="120" rx="8"/>
|
||||
<text class="sub" x="50" y="570">4 Hack Types Applied</text>
|
||||
<text class="amb" x="50" y="600">String</text>
|
||||
<text class="dim" x="180" y="600">"one"-->"fun"</text>
|
||||
<text class="amb" x="420" y="600">Timing</text>
|
||||
<text class="dim" x="550" y="600">500ms-->100ms</text>
|
||||
<text class="amb" x="50" y="625">Stealth</text>
|
||||
<text class="dim" x="180" y="625">NOP out prints</text>
|
||||
<text class="amb" x="420" y="625">Angle</text>
|
||||
<text class="dim" x="550" y="625">180.0f-->30.0f</text>
|
||||
|
||||
<!-- Projects and IEEE -->
|
||||
<rect class="pnl" x="30" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="50" y="692">Projects</text>
|
||||
<text class="dim" x="50" y="718">0x001d_static-conditionals</text>
|
||||
<text class="dim" x="50" y="740">0x0020_dynamic-conditionals</text>
|
||||
|
||||
<rect class="pnl" x="615" y="660" width="555" height="100" rx="8"/>
|
||||
<text class="sub" x="635" y="692">IEEE-754 Angles</text>
|
||||
<text class="dim" x="635" y="718">0.0f=00000000 90.0f=42b40000</text>
|
||||
<text class="dim" x="635" y="740">180.0f=43340000 30.0f=41f00000</text>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |