Complete an embedded systems lab assignment — produces working PlatformIO code, a LaTeX report, and a Wokwi simulation following all project conventions. Invoke with the lab conditions as arguments, or paste them after invoking.
Complete the following embedded systems lab assignment, following ALL rules in this skill strictly.
Lab conditions / task statement: $ARGUMENTS
When the user denies a tool call (e.g. dismisses a Bash command), IMMEDIATELY STOP and ask what to do next using the AskUserQuestion tool. Do not continue.
"Denied" means the user explicitly rejected the tool execution. Treat the command as not executed — never assume it ran.
For every CLI command:
Violations:
All lab reports should prioritize readability and clarity. Use paragraphs for conceptual explanations, workflows, and detailed descriptions. Use bulleted or numbered lists only when strictly necessary (e.g., for step-by-step procedures, simple enumerations, or dense reference material). Avoid over-listing; convert multi-item lists into prose when they form a coherent narrative.
See the CRITICAL RULES section above for the full denied-command policy. Additional rules:
If a CLI command fails, attempt to resolve it autonomously with safe, non-destructive steps. Limit troubleshooting to at most 3 follow-up attempts; after each, briefly state what changed and why. If it still fails, stop and use AskUserQuestion to determine the next step. Never run destructive commands (delete/format/flash erase) without explicit user approval.
If latexmk fails, check the .log file for the error (search for lines starting with ! or containing Error). Common causes: missing \end{...}, unescaped special characters (#, %, &, _ in text), or undefined control sequences. Fix the offending .tex file and retry. The same 3-attempt limit applies — if still broken, use AskUserQuestion.
latexmk -pdf -interaction=nonstopmode main.tex from inside the report folder. This always uses the pdflatex engine.diagram.json and wokwi.toml with correct pin mapping.The following require human actions and should only be requested (with exact specifications):
\begin{figure}...\end{figure} block in the report at the correct location. Never comment out figure blocks. The figure must be unconditionally included so it appears in the final PDF when the image is placed.\includegraphics in \IfFileExists:\begin{figure}[H]
\centering
\IfFileExists{resources/ObtainedResults/screenshot.png}{%
\includegraphics[width=0.75\textwidth]{resources/ObtainedResults/screenshot.png}%
}{%
\fbox{\parbox{0.73\textwidth}{\centering\color{gray}\small
[Screenshot pending — save to resources/ObtainedResults/screenshot.png]}}%
}
\caption{Description of what the screenshot shows}
\label{fig:screenshot_label}
\end{figure}
es-labslabs/ (this is the active PlatformIO project)For every lab, produce ALL of the following:
latexmk)All three must match each other: same features, same behavior, same pin mapping, same module structure.
labs/Recommended structure:
labs/
src/
main.cpp
lab/
lab1_1/
lab1_1_main.cpp
lab1_2/
lab1_2_main.cpp
lab2_1/
lab2_1_main.cpp
lib/
drivers/
hal/
utils/
protocols/
include/ (if needed)
platformio.ini
Each lab must have a dedicated file, for example:
labs/lab/lab1_1/lab1_1_main.cpplabs/lab/lab1_2/lab1_2_main.cpplabs/src/main.cpp must only select and run ONE lab at a time.
#ifdef guards: #ifdef LAB2_1, #elif defined(LAB1_2), etc.platformio.ini sets the corresponding flag via build_flags = -DLAB2_1.labs/lib/.labs/lib/ first. If a library component already exists (e.g., LcdDisplay, KeypadInput, Led, StdioSerial, TaskScheduler), use it directly — do not reimplement it.labs/lib/. Direct register manipulation, raw digitalWrite/analogRead calls, protocol handling (UART, I2C, SPI), and hardware initialization must all live in library modules under labs/lib/ — never inline in the lab entry point, main.cpp, or any lab task/module file.main.cpp.labs/lib/ as a library:
.cpp.stuff.cpp).diagram.jsonEach lab must have its own Wokwi folder:
labs/wokwi/lab1.1/diagram.jsonlabs/wokwi/lab1.2/diagram.jsonlabs/wokwi/lab2.1/diagram.jsonThe simulation should be reproducible by opening the lab in VS Code and starting Wokwi.
If a lab cannot be fully simulated: clearly state what is not supported and why, and provide a workaround.
Every lab report's Design section must include a screenshot of the running Wokwi simulation. This is a manual action — Claude cannot take the screenshot autonomously.
After setting up the Wokwi simulation, always ask the user to:
wokwi.toml in VS Code and start the Wokwi simulation.reports/<lab>/resources/Design/ElectricalSchematics/wokwi_circuit.png.In the report, add a live, uncommented \begin{figure}...\end{figure} block using \IfFileExists so the report compiles cleanly before the image is provided. Never comment out the figure block.
template/reports/lab1.1/), copy/adapt the template instead of starting from scratch.reports/lab1.1/, reports/lab1.2/, etc.Each report folder should contain:
main.texresources/ (organized subdirectories for screenshots, photos, and other external images).tex sections if needed⛔ HARD RULE — Enforced without exception: When writing or updating any lab report, you are only permitted to read two sources for report context:
template/— primary reference for ALL formatting, structure, package setup, and diagram style.reports/lab1.1/— secondary reference only for gauging prose depth (Domain Analysis, Design, Results).Reading any other completed lab report (
reports/lab1.2/,reports/lab2.1/,reports/lab2.2/, etc.) is strictly forbidden. Do not open, read, grep, or search those folders when creating or editing a report.If you find yourself about to read a file from
reports/lab1.2/or later, stop and redirect totemplate/instead.
Important about Lab 1.1: Lab 1.1 used Mermaid diagrams (.mmd files) which are now obsolete. All post-1.1 labs use TikZ / CircuiTikZ drawn directly in LaTeX. Never copy diagram code from Lab 1.1.
Sole exception — images only: You may search completed lab folders exclusively to locate reusable image files (.png, .jpg, .pdf) for copying into the new lab's resources/ folder. Only inspect resources/ subdirectories, never .tex files.
reports/<lab>/resources/
├── DomainAnalysis/
│ ├── UsedTechnologies/
│ ├── HardwareComponents/
│ └── SoftwareComponents/
├── Design/
│ ├── SystemArchitectureDiagrams/
│ ├── BlockDiagrams/
│ ├── ElectricalSchematics/
│ └── ModularImplementation/
└── ObtainedResults/
HardwareComponents/ — For every lab, always ask the user to provide a photo or product image for each hardware component introduced. Insert a live \IfFileExists figure placeholder immediately and ask the user to supply the image.
Always request photos for:
arduino_mega_2560.png. If this image already exists in a previous lab, copy it — never reference across labs.SoftwareComponents/ — For each software tool used (PlatformIO IDE, Wokwi simulator), ask the user to provide a screenshot showing the tool in use for this lab. These are manual actions — insert a live \IfFileExists figure placeholder.
platformio.png — show the project open in VS Code with the PlatformIO sidebar visible.wokwi.png — show the Wokwi simulator running the lab's circuit.All images in HardwareComponents and SoftwareComponents MUST be referenced in the report. If an image exists but is not referenced with a \begin{figure}...\end{figure} block, either remove or include it.
Reusing images: Each lab report must use only its own local resources/ folder — never reference images with paths like ../lab1.1/resources/.... Copy reusable images into the current lab's resources folder.
uart_frame.png, i2c_protocol.png, arduino_mega_2560.png, lcd_1602_i2c.pngsystem_structural_diagram.png, fsm_state_diagram.png, app_flowchart.png, electric_schema.pngbuild_results.png, simulation_start.png, test_<scenario>.png, test_report.pngInclude the lab number only for lab-specific screenshots; omit it for reusable technology/component diagrams.
All diagrams must be drawn directly in LaTeX — no external tools, no PNG exports. Use TikZ (flowcharts, FSM state diagrams, block/architecture diagrams) and CircuiTikZ (electrical schematics). Both are loaded in settings.tex.
\tikzset{
startstop/.style={rectangle, rounded corners, minimum width=2.5cm,
minimum height=0.7cm, text centered, align=center, draw=black, fill=gray!15},
process/.style={rectangle, minimum width=2.5cm,
minimum height=0.7cm, text centered, align=center, draw=black, fill=blue!10},
decision/.style={diamond, aspect=2.5, minimum width=2cm,
minimum height=0.7cm, text centered, align=center, draw=black, fill=orange!15},
arrow/.style={thick,->,>=Stealth}
}
\begin{figure}[H]
\centering
\begin{tikzpicture}
\node (start) [startstop] at (0, 0.0) {Start};
\node (proc1) [process] at (0, -1.8) {Process 1};
\node (dec1) [decision] at (0, -4.3) {Condition?};
\node (proc2) [process] at (0, -6.8) {Process 2};
\node (stop) [startstop] at (0, -8.6) {End};
\draw [arrow] (start) -- (proc1);
\draw [arrow] (proc1) -- (dec1);
\draw [arrow] (dec1) -- node[anchor=east]{Yes} (proc2);
\draw [arrow] (proc2) -- (stop);
\end{tikzpicture}
\caption{Flowchart of the application logic}
\label{fig:app_flowchart}
\end{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}[>=Stealth, auto, node distance=2.8cm,
every state/.style={draw, circle, minimum size=1.2cm}]
\node[state, initial] (idle) {IDLE};
\node[state] (menu) [right of=idle] {MENU};
\node[state] (confirm) [right of=menu] {CONFIRM};
\node[state, accepting] (result) [below of=menu] {RESULT};
\path[->]
(idle) edge node {*} (menu)
(menu) edge node {0} (confirm)
(confirm) edge node {\#} (result)
(result) edge [bend right] node {auto} (idle);
\end{tikzpicture}
\caption{FSM state diagram}
\label{fig:fsm_state_diagram}
\end{figure}
\begin{figure}[H]
\centering
\begin{tikzpicture}[
box/.style={draw, rectangle, minimum width=5cm, minimum height=0.8cm,
text centered, fill=blue!10},
node distance=0.5cm]
\node[box] (app) {Application Layer (APP)};
\node[box] (srv) [below=of app] {Service Layer (SRV)};
\node[box] (ecal) [below=of srv] {MCU Abstraction (ECAL)};
\node[box] (mcal) [below=of ecal] {Driver Layer (MCAL)};
\node[box] (hw) [below=of mcal] {Hardware (HW)};
\foreach \a/\b in {app/srv, srv/ecal, ecal/mcal, mcal/hw}
\draw[->] (\a) -- (\b);
\end{tikzpicture}
\caption{Layered software architecture}
\label{fig:layered_architecture}
\end{figure}
\begin{figure}[H]
\centering
\begin{circuitikz}
\draw (0,0) node[anchor=east]{Pin 7}
to[R, l=220\,\si{\ohm}] (2,0)
to[leD*, color=red] (4,0)
node[ground] {};
\draw (0,-1.5) node[anchor=east]{SDA (Pin 20)}
to[short] (4,-1.5) node[anchor=west]{LCD SDA};
\end{circuitikz}
\caption{Circuit schematic}
\label{fig:circuit_schematic}
\end{figure}
tikzpicture. Split into logical groups if more.\textwidth; simplify by grouping subsystems if needed.Rule 1 — Always use explicit at (x,y) coordinates. Never use node distance with below of= / right of= for flowcharts or structural diagrams. Place every node with an explicit coordinate.
Rule 2 — Minimum vertical gap between nodes:
Rule 3 — Right-column nodes at same y as left-column decisions. Return arrows MUST NOT use |- routing through that y-level.
Rule 4 — Route return arrows BETWEEN columns, not around the outside.
% RIGHT: route via midpoint between columns
\draw [arrow] (rightNode.west) -- (2.5, -6.2) -- (2.5, -8.7) -- (nextDecision);
% WRONG: |- routing passes through right-column node
% \draw [arrow] (rightNode.east) -- ++(1.0,0) |- (nextDecision.east);
Use slightly different x-values (e.g. 2.5, 3.0, 3.5) for multiple return arrows to prevent shared segments.
Rule 5 — Back-edges in loops must avoid the loop body. Route via the LEFT side:
\draw [arrow] (inc.west) -- ++(-2.0,0) |- (loopHead.west);
Rule 6 — Use calc library for sublayer positioning.
Before finalising any diagram: mentally trace each node's bounding box and every arrow segment. Confirm: no two boxes overlap, and no arrow segment passes through any node body.
All lab reports must cover: technology analysis → design → implementation → testing/results.
Include:
Include:
\IfFileExists placeholder pointing to resources/Design/ElectricalSchematics/wokwi_circuit.png)..h and .cpp files.h files define the interface and explain available methods.cpp files contain implementation and explanation of critical code sectionsInclude:
Minimum screenshot coverage — at least the following must be provided for every lab:
[SUCCESS], RAM/Flash usage). Save as resources/ObtainedResults/build_results.png.resources/ObtainedResults/simulation_start.png.test_<scenario>.png.resources/ObtainedResults/test_report.png.Before finalising the report, ask the user for all missing screenshots. Insert \IfFileExists-wrapped figure blocks for each — never leave screenshot sections without a figure block.
Include:
If AI tools were used, explicitly mention it in the report.
Recommended text: "During the writing of this report, the author used [AI TOOL NAME] to generate/consolidate content. The results were reviewed, validated, and adjusted according to the lab requirements."
.cpp and .h modules.After each completed task, you MUST:
Do not push without user confirmation. Multiple commits can accumulate locally before pushing.
Code Implementation / Fixes
Lab X.Y: <functionality description>Lab 1.2: fix Wokwi keypad layoutDocumentation and Diagrams
Lab X.Y: <documentation update>Lab 1.2: add report (LaTeX) + Domain Analysis imagesMultiple Changes in One Prompt
Always include:
.cpp, .h files)platformio.ini)diagram.json, wokwi.toml).tex files)resources/ foldersmain.pdf)Never commit:
.pio/, build/, .vscode/)*.o, *.a)*.aux, *.fdb_latexmk, *.fls, *.log, *.out, *.synctex.gz, *.toc, *.blg, *.bbl, *.xdv)Lab X.Y: <component/feature> — <brief description>
Optional body:
- Key design decisions
- Dependency updates
- Integration with previous lab components
Examples:
Lab 1.1: STDIO serial LED controlLab 1.2: LCD + Keypad lock system with 10-state FSMLab 1.2: add report (LaTeX) + Domain Analysis imagesAlways ask before pushing. After committing changes locally:
git push origin mainBefore pushing:
\IfFileExists).Never push broken builds or LaTeX compile errors to the main branch.
After each lab is fully complete and pushed, optionally create a Git tag:
git tag lab1.1
git push origin --tags
GitHub Repository: https://github.com/<owner>/es-labs