Commit Graph

118 Commits

Author SHA1 Message Date
davidmonterocrespo24 ed9911dcc3 feat: electrical simulation via ngspice-WASM (eecircuit-engine)
Adds full SPICE-accurate electrical simulation to Velxio, behind a lazy-
loaded  toolbar toggle. Arduino / ESP32 / RP2040 sketches now co-simulate
with real analog behaviour: correct voltages on wires, real I–V curves on
LEDs, working potentiometers, NTC thermistors read by analogRead(), PWM
driving RC filters, transistors, op-amps, diodes, MOSFETs, etc.

Engine: eecircuit-engine (ngspice compiled to WebAssembly). Main bundle
stays at 2.4 MB; the 20 MB SPICE chunk only loads when the user activates
electrical mode. Disabled at build time via VITE_ELECTRICAL_SIM=false.

Frontend additions:
- simulation/spice/: SpiceEngine wrapper + lazy entry, NetlistBuilder with
  UnionFind over wires, componentToSpice mapping (24 metadataIds incl.
  real part numbers: 2N2222, 2N3055, BC547, IRF540, 2N7000, 1N4148,
  1N4007, 1N4733, LEDs, NTC, op-amp ideal), CircuitScheduler with
  debounced coalescing, AVRSpiceBridge for quasi-static co-simulation.
- store/useElectricalStore: Zustand slice, feature-flag aware.
- components/analog-ui/:  toolbar toggle + SVG voltage overlay.
- components/components-instruments/: Voltmeter, Ammeter probes.
- 62 tests (spice-*, netlist-builder, component-to-spice, instruments).

Sandbox (test/test_circuit/): 47-test validation sandbox that proved
the approach (hand-rolled MNA baseline + ngspice pipeline) before
porting to the app. Kept as reference.

Docs: docs/wiki/circuit-emulation-*.md (13 engineering pages covering
architecture, solvers, components, AVR bridge, gotchas, performance,
integration plan, API reference, appendix) + electrical-simulation-
user-guide.md (end-user facing).

Reference plan: test/test_circuit/plan/phase_8_velxio_implementation.md

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 12:11:54 +00:00
David Montero Crespo c65acdb1dc Add end-to-end test for MicroPython on Raspberry Pi Pico using rp2040js
- Implemented a comprehensive test script (test_micropython_pico.mjs) that performs the following:
  - Part 1: Checks backend compilation of a simple Arduino sketch for the rp2040:rp2040:rpipico board.
  - Part 2: Downloads MicroPython v1.20.0 UF2 firmware and loads it into a rp2040js simulator.
  - Part 3: Simulates the Pico, verifies REPL output, and checks execution of injected Python code.
- Includes detailed logging and error handling for each step of the process.
2026-04-13 10:02:21 -03:00
David Montero Crespo 74e25eb4b2 feat: Update MicroPython firmware handling for ESP32; add end-to-end test and mark subproject commits as dirty 2026-04-12 23:55:11 -03:00
David Montero Crespo d4a48e6e1e feat: Skip real paths test in CI; mark subproject commits as dirty 2026-04-11 15:49:32 -03:00
David Montero Crespo 382e13cfe7 feat: Update components metadata timestamp and mark subproject commits as dirty; add diagnostic test for real library paths 2026-04-11 15:42:38 -03:00
David Montero Crespo 2ba8020438 feat: Enhance ESPIDFCompiler library resolution logic; add support for dynamic library detection and patching in CMakeLists.txt
refactor: Update wiring examples for E32 OLED integration; correct pin mappings for VCC, GND, DATA, and CLK
test: Improve unit tests for ESPIDFCompiler; add scenarios for library resolution and CMake patching
chore: Mark subproject commits as dirty for wokwi-libs
2026-04-11 15:25:40 -03:00
David Montero Crespo 6b161eab34 feat: Enhance CI workflows for backend unit and e2e tests; add environment setup and skip timing-sensitive tests in CI 2026-04-10 23:47:25 -03:00
David Montero Crespo 7971743174 Add unit tests for I2C slave devices, MCP tools, and WiFi/BLE status parser
- Implement tests for BMP280, DS1307, DS3231, I2CWriteSink, and MPU6050 slaves in test_i2c_slaves.py.
- Create test suite for Velxio MCP server tools in test_mcp_tools.py, covering Wokwi utilities and circuit management functions.
- Add tests for parsing WiFi and BLE serial output in test_wifi_status_parser.py, ensuring correct status events are captured.
2026-04-10 23:39:51 -03:00
David Montero Crespo 5795b1d506 Fix MPU6050Slave I2C handling and add comprehensive tests
- Updated the threshold for switching to data mode in MPU6050Slave from 2 to 3 WHO_AM_I reads to ensure correct chip identification.
- Enhanced comments in the code to clarify the sequence of I2C events during initialization.
- Added a new test file `test_mpu6050_emulation.py` to validate the MPU6050Slave state machine and ensure it handles the full Adafruit_MPU6050::begin() event sequence correctly.
- Updated existing tests to reflect the changes in the I2C handling logic.
- Modified `components-metadata.json` to update the generated timestamp.
- Marked submodules `rp2040js` and `wokwi-elements` as dirty to reflect local changes.
2026-04-09 02:04:41 -03:00
David Montero Crespo 01f75cf313 feat: implement eager scan for LEDC GPIO mapping and add tests for race condition fix 2026-03-24 13:54:44 -03:00
David Montero Crespo b166b8de37 feat: add ESP32 lcgamboa test suite, sketches and firmware binaries
- test/esp32/test_esp32_lib_bridge.py: 28-test suite for ESP32 emulation
  via libqemu-xtensa.dll (GPIO, UART, ADC, pinmap, DLL symbols, manager API)
- test/esp32/test_arduino_esp32_integration.py: 13-test integration suite
  simulating Arduino Uno ↔ ESP32 serial communication (LED_ON/OFF, PING/PONG,
  GPIO transitions, rapid burst, unknown command resilience)
- sketches/blink_lcgamboa/: IRAM/DRAM-safe blink firmware (5× GPIO2 toggle)
- sketches/serial_led/: ESP32 firmware responding to serial commands over UART0
- sketches/arduino_serial_controller/: Arduino Uno sketch for serial LED control
- sketches/blink_qemu.ino: reference blink sketch for stock QEMU
- binaries_lcgamboa/: pre-compiled 4 MB merged flash images for QEMU
  (blink_lcgamboa + serial_led, arduino-esp32 2.0.17 + FlashMode=dio)
- .gitignore: exclude DLL/ROM binaries (too large) and .elf/.map build artifacts

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-14 12:28:40 -03:00
David Montero Crespo c957190061 feat: implement ESP32 emulation support via libqemu-xtensa.dll and enhance simulation API 2026-03-14 02:32:48 -03:00
David Montero Crespo 1bbb1ad4d2 feat: add initial ESP32 test module 2026-03-13 22:55:45 -03:00
David Montero Crespo dc03c28fff feat: Enhance ESP32 support in simulator and QEMU management 2026-03-13 22:55:37 -03:00
David Montero Crespo cc3030200c feat: add multi-board integration tests for Raspberry Pi 3B and backend functionality 2026-03-13 00:15:14 -03:00
David Montero Crespo a07c76470e feat: enhance AVR USART RX handling with software queue and improve logging 2026-03-12 22:11:06 -03:00
David Montero Crespo 13997ff491 feat: add documentation page and Arduino serial integration test
- Created a new DocsPage component for project documentation with links to GitHub and Discord.
- Added Arduino sketch for serial communication test between Raspberry Pi and Arduino.
- Implemented avr_runner.js to emulate ATmega328P and bridge serial communication over TCP.
- Developed a Python test script to validate the serial integration between the emulated Raspberry Pi and Arduino.
2026-03-12 08:17:29 -03:00
David Montero Crespo 02c69c23f6 feat: add ESP32 emulator with QEMU WebAssembly integration and basic GPIO functionality tests 2026-03-10 18:01:05 -03:00