Repository navigation
Adding a Part Kind
Check first: most new hardware needs no Rust. The four kinds (
led,pixels,servo_part,button) plus a shim cover lights, strips, anything a servo turns and any input. See Adding new hardware.
Only an output none of them can show, such as a display, needs a simulator change.
-
simulator/src/hw.rs: add a field toHwStatefor the new output, and reset it inreset_for_run. -
simulator/src/pyhost.rs: add a#[pyfunction]to thesimhwmodule that writes the field, likeset_pcaorset_part. Check every argument (type, NaN, size) and log a[sim]warning rather than raising or panicking. -
simulator/src/scene.rs(orparts.rsfor something part-like): draw it.ui.rs: add a readout if useful. -
simulator/tests/simhw.py: add the same function to the pure-Pythonsimhw, so the headless test keeps passing. - Write the shim that calls it.
Do Option A's steps where needed, plus:
-
simulator/src/config.rs: add a variant toenum PartKind, its name inname(), parsing and validation of any new fields, and a unit test. -
simulator/src/parts.rs: spawn and update it (see howPartKind::Buttonis handled), and add it to the kindsshim_targetaccepts for the rightsimhwcalls. -
simulator/src/part_edit.rs: add it to the Parts panel's kinds (the Add … buttons), its description, default name, and its settings. -
simulator/src/ui.rs: its value in the PCA9685 panel and Droid status.
-
Build and test:
.\simulator\build.ps1 -Test -
Keep
cargo fmtandcargo clippyclean (they run in CI). -
Check it in the app: add the part with the mouse and the keyboard, save, restart, drive it from a shim, undo and redo.
-
Update the README's Parts file table, the shim guide and Adding new hardware.
See Simulator architecture for how the pieces fit.
DD-L0-LA59 Animatronics · Project on GitHub · Report a problem with this page · Edit these pages in the wiki/ folder
Start here
Using the simulator
- Get the simulator
- A tour of the window
- Make her breathe, boop and more
- Camera, overlays and recording
- Speed, scenarios and panels
- Layouts, themes and shortcuts
- Accessibility
- Troubleshooting and FAQ
Building the robot
- Safety first
- Parts list
- Wiring
- Install CircuitPython
- Copy the firmware
- Calibrate the wings
- Test it and read the log
Changing how she behaves
Adding new hardware
For developers
- Building the simulator
- Project layout
- CI and releases
- Contributing and branching
- Simulator architecture
- Adding a part kind
Reference