Commit Graph

240 Commits

Author SHA1 Message Date
David Montero Crespo f5ef107eaa feat: implement asyncio exception handler and update entrypoint script for process management 2026-04-16 00:57:30 -03:00
David Montero Crespo df37fdf6a4 feat: add 40 circuit examples + matching SPICE tests
Adds frontend/src/data/examples-circuits.ts with 40 new examples organized
into 6 categories, each demonstrating a specific analog/digital/electromech
concept that the SPICE engine can simulate end-to-end:

PASSIVE / ANALOG (10):
  voltage-divider, rc-low-pass-filter, wheatstone-bridge,
  ntc-temperature, led-current-limiting, parallel-resistors,
  pot-adc-reader, photoresistor-light, multi-led-bar,
  capacitor-charge-curve

TRANSISTOR / SEMICONDUCTOR (8):
  npn-led-switch, pnp-high-side-switch, mosfet-pwm-led,
  diode-rectifier, zener-regulator, schottky-reverse-protection,
  bjt-common-emitter, darlington-high-current

OP-AMP (5):
  opamp-inverting, opamp-voltage-follower, opamp-comparator,
  opamp-difference, opamp-schmitt-trigger

LOGIC GATES (6):
  and-gate-alarm, xor-toggle-detector, nand-sr-latch,
  full-adder, binary-counter-leds, logic-probe

ELECTROMECHANICAL (4):
  relay-led-switch, optocoupler-signal,
  l293d-motor-control, l293d-speed-pwm

POWER / REGULATOR (3):
  power-supply-7805, lm317-adjustable-psu, battery-voltage-monitor

BOARD-SPECIFIC (4):
  esp32-dual-adc, mega-multi-led, nano-sensor-station,
  esp32-pwm-led-rgb (uses ESP32 LEDC peripheral)

The new examples are appended to exampleProjects[] in examples.ts so the
existing gallery and category filters pick them up automatically.

test/test_circuit/test/spice_examples.test.js validates each example's
analog topology in ngspice — 45 individual assertions covering all 40
examples (plus extra cases for NTC/Zener sweeps and L293D direction).

Sandbox tally: 164 -> 209 tests, 7.9s runtime, all green.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 00:52:51 -03:00
David Montero Crespo 04d14a74b2 feat: always-on SPICE mode, full board ADC integration, LED brightness from current
Electrical simulation is now active by default (mode='spice' instead of
'off') — users no longer need to toggle the mode on manually. The engine
lazy-loads on first solve, so there is no startup cost penalty.

Changes:
- useElectricalStore: default mode = 'spice' when ELECTRICAL_SIM_ENABLED
- subscribeToStore: ADC_PIN_MAP expanded to all 18 board types (Uno, Nano,
  Mega with 16 ADC channels, ATtiny85, RP2040 GP26-29, ESP32/S3/C3 GPIO
  ADCs). Voltages from SPICE solutions now inject into MCU ADC peripherals
  for all boards.
- BasicParts LED: reads branchCurrents from useElectricalStore when SPICE
  is active. Brightness = clamp(|I_led| / 20mA, 0, 1) instead of boolean.
  Subscribes to store changes to update in real time.
- ElectricalOverlay: shows per-wire voltage labels (gold monospace on dark
  pill) using buildWireNetMap() which replicates the NetlistBuilder's
  Union-Find to map wireId -> netName -> nodeVoltage. Summary pill shows
  net count + solve time.
- NetlistBuilder: new export buildWireNetMap() for lightweight wire-to-net
  resolution without running ngspice.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 22:59:22 -03:00
David Montero Crespo 36543e2479 feat: expand SPICE component catalog (fases 9 + 10)
Adds 44 SPICE mappers, 58 custom metadata entries, and 12 visual
Web Components covering logic gates, transistors, op-amps, regulators,
sources, electromechanical parts and integrated-circuit packaging.

Fase 9 — component catalog expansion
------------------------------------
- 7 logic gates (AND/OR/NAND/NOR/XOR/XNOR + NOT) as SPICE B-sources
- 8 multi-input gates (AND/OR/NAND/NOR with 3 and 4 inputs)
- 9 transistors: 5 BJTs (incl. PNP 2N3906/BC557) + 4 MOSFETs (incl.
  P-channel IRF9540/FQP27P06). NMOS refactored from Level=3 W=0.1
  (hangs ngspice) to Level=1 with sane W/L
- 5 op-amps: LM358, LM741, TL072, LM324 with per-chip saturation
  rails + opamp-ideal
- 4 linear regulators (7805, 7812, 7905, LM317) with dropout
- 3 batteries (9V, AA, coin-cell) with realistic ESR
- Signal generator (sine / square / DC)
- 2 Schottky diodes (1N5817, 1N5819) + photodiode (lux-driven
  current source)

Fase 10 — electromechanical + ICs
---------------------------------
- Relay (SPDT): coil + L + S-switch with native hysteresis +
  flyback diode, inverted-control trick for the NC contact
- Optocouplers 4N25 and PC817 (LED + CCCS with CTR=0.5 / 1.0)
- 7 74HC ICs as DIP-14 packages emitting 4 or 6 B-sources per
  component (first mapper pattern emitting multiple device cards)
- 3 flip-flops (D, T, JK) — digital-sim only (edge detection is
  not representable in ngspice .op)
- L293D dual H-bridge motor driver

Infrastructure
--------------
- scripts/component-overrides.json gains a _customComponents[] array
  that lets new Velxio-only parts survive metadata regeneration
  (previously applyOverrides() could only patch wokwi-elements
  components that had already been scanned)
- scripts/generate-component-metadata.ts injects custom entries
  before the patch loop
- New ComponentCategory values: 'logic', 'analog', 'electromech'
- frontend/src/components/DynamicComponent.tsx PASSIVE tracing
  extended from just ['resistor','resistor-us'] to 9 two-terminal
  passives with per-part pin name maps
- New CI workflow test-circuit.yml runs the sandbox on push/PR
- frontend-tests.yml regenerates metadata and fails if committed
  JSON is stale
- Documented 2 new ngspice gotchas in circuit-emulation-gotchas.md:
  unicode in netlist titles silently hangs the parser, and
  MOSFET Level=3 + W=0.1m causes .op to hang
- 164/164 sandbox tests passing in ~9 s (was 88 pre-fase-9)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-15 22:41:26 -03:00
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 5202bdae7f feat: refactor CircuitPreview component and implement ShareModal using createPortal; mark subproject commits as dirty 2026-04-14 17:32:28 -03:00
David Montero Crespo 4d6dc25ec7 feat: add BMP280 sensor component and circuit preview
- Implemented Bmp280Element as a custom web component for the BMP280 barometric sensor, including SVG representation and pin configuration.
- Created CircuitPreview component to render circuit thumbnails using SVGs of components, including support for various boards and components.
- Added a script to generate SVG files from wokwi-elements, ensuring proper formatting and structure for reliable rendering.
- Introduced a test HTML generation script to visualize component SVGs.
2026-04-14 17:27:30 -03:00
David Montero Crespo 12343075d8 feat: add example detail pages and SEO improvements
- Implemented ExampleDetailPage for individual example projects with SEO metadata.
- Updated routing to use ExampleDetailPage instead of ExampleLoaderPage.
- Enhanced sitemap generation to include example project URLs.
- Added prerendering support for example detail pages in the server entry.
- Improved SEO handling in ProjectByIdPage to dynamically set metadata based on project visibility.
- Refactored example ID extraction from examples.ts for sitemap generation.
- Updated console logs to reflect total URLs generated in sitemap.
2026-04-13 15:22:08 -03:00
David Montero Crespo a9fbe8b3dc feat: Activate default file group in useSimulatorStore; mark subproject commits as dirty in rp2040js and wokwi-elements 2026-04-13 11:16:43 -03:00
David Montero Crespo 67a8373c80 feat: Enhance Arduino pin tracing in DynamicComponent; update LittleFS WASM initialization; mark subproject commits as dirty 2026-04-13 11:06:03 -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 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 d2e1e04def Add comprehensive documentation for ESP32 GPIO sensor simulation
This commit introduces a detailed markdown document outlining the process of simulating DHT22 and HC-SR04 sensors on the ESP32 platform using Velxio's QEMU fork. The documentation covers the context of the simulation, key callbacks, problems encountered, and solutions implemented for both sensors. It includes architectural details, end-to-end testing procedures, and guidelines for adding new GPIO-timed sensors. The aim is to provide maintainers with a thorough understanding of the GPIO logic and the challenges faced during development.
2026-04-10 22:51:56 -03:00
David Montero Crespo 46e459f51b Refactor I2C slave tests for ESP32: update event handling and improve accuracy of ACK/NACK responses; add full end-to-end test for MPU-6050 I2C simulation; update components metadata timestamp; mark subproject commits as dirty for wokwi-libs. 2026-04-09 15:06:39 -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 75c4ead6de Merge remote-tracking branch 'origin/master' 2026-04-09 02:36:06 +02:00
David Montero 6c95013f24 fix: prevent save to /api/projects/none when project ID is invalid
Two bugs causing "can't save project" reports:

1. SaveProjectModal: validate currentProject.id is a real UUID before
   calling updateProject. If id is "none" or any non-UUID string, fall
   through to createProject instead, avoiding PUT /api/projects/none.

2. ProjectByIdPage: call clearCurrentProject() when the project fetch
   fails (404/403/error). Prevents stale project IDs from a previous
   session polluting the store and triggering spurious update calls.
2026-04-09 02:34:43 +02:00
David Montero Crespo a64b14c94e Merge branch 'master' into feature/micropython-rp2040
# Conflicts:
#	.gitignore
#	frontend/src/components/editor/EditorToolbar.tsx
#	frontend/src/components/simulator/SerialMonitor.tsx
#	frontend/src/types/board.ts
2026-04-08 00:11:23 -03:00
David Montero Crespo 71fa6eae4a Merge branch 'master' into feature/shareable-urls
# Conflicts:
#	.gitignore
2026-04-08 00:03:59 -03:00
David Montero Crespo ca6520e48d feat: Update I2C event handling and improve MPU-6050 slave emulation; enhance README and tests 2026-04-08 00:02:54 -03:00
David Montero Crespo 0f2c39f23b feat: Add I2C sensor support and implement ESP32 I2C slave emulation
- Introduced I2C_SENSOR_MAP for pre-registering I2C sensors in the simulator store.
- Implemented I2C slave state machines for MPU6050, BMP280, DS1307, and DS3231 sensors in esp32_i2c_slaves.py.
- Added unit tests for I2C slave functionality covering BMP280, DS1307, DS3231, and I2CWriteSink.
- Updated the simulator store to handle I2C address resolution and sensor data management.
- Marked submodules as dirty in wokwi-libs for rp2040js and wokwi-elements.
2026-04-08 00:02:43 -03:00
David Montero Crespo 689f8e71db feat: Add I2C slave emulation for MPU-6050 and BMP280 sensors
- Implemented _MPU6050Slave and _BMP280Slave classes for I2C communication.
- Enhanced main function to register these sensors and handle I2C events.
- Updated sensor management to support MPU-6050, BMP280, DS1307, DS3231, SSD1306, and PCF8574.
- Added frontend examples for BMP280 weather station and SSD1306 OLED display.
- Modified Esp32Bridge to handle new I2C transaction events.
- Updated ProtocolParts to support ESP32 path for I2C devices.
- Enhanced useSimulatorStore to manage I2C transaction listeners.
2026-04-07 15:43:09 -03:00
David Montero Crespo 9761aad0be feat: enhance Arduino library handling by detecting external libraries and creating IDF components, add tests for library resolution logic 2026-04-07 14:59:51 -03:00
David Montero Crespo d789a2c7e2 fix: update version to 2.0.1, enhance Discord release notification workflow, and mark subproject commits as dirty 2026-04-07 14:12:10 -03:00
David Montero Crespo f43c9d019d fix: update generatedAt timestamp, improve wire properties, and mark subproject commits as dirty 2026-04-07 13:27:54 -03:00
David Montero Crespo 9e117ee5c7 feat: enhance wire connection handling and GND checks for components 2026-04-07 13:08:15 -03:00
David Montero Crespo 4f3236437a feat: implement component metadata overrides and enhance property controls 2026-04-07 11:33:34 -03:00
David Montero Crespo e489a10255 fix: update generatedAt timestamp and clean up component metadata defaults
feat: enhance wire tracking in DynamicComponent for better event handling
chore: mark subproject commits as dirty for rp2040js and wokwi-elements
2026-04-07 11:19:48 -03:00
David Montero Crespo a3db014d2d feat: multi-arch Docker (amd64+arm64) and fix LED ground check
Docker multi-arch:
- Dockerfile downloads arch-specific QEMU .so via TARGETARCH
- docker-publish.yml adds setup-qemu-action and platforms: linux/amd64,linux/arm64
- qemu-lcgamboa submodule updated (matrix build for both architectures)

LED fix:
- LEDs now require cathode wired to GND (or LOW GPIO) to light up
- Previously LEDs turned on with anode HIGH regardless of cathode connection
- Updated tests to verify anode+cathode behavior
2026-04-07 03:58:52 -03:00
David Montero Crespo 97f8f6cd52 feat: add protocol selection and editable properties in component dialogs 2026-04-07 03:58:17 -03:00
David Montero Crespo c697aa261d
Merge pull request #102 from davidmonterocrespo24/feature/load-precompiled-firmware
Feature/load precompiled firmware
2026-04-06 23:04:01 -03:00
David Montero 2a386f99b0 fix: SaveProjectModal uses active board files/kind and better error messages
Two bugs fixed:
1. SaveProjectModal was reading from the legacy global `files` array instead
   of the active board's file group, causing projects to be saved with the
   wrong board_type (e.g. 'arduino-uno' for ESP32 projects).
   Now reads from fileGroups[activeBoard.activeFileGroupId] and uses
   activeBoard.boardKind for board_type.

2. Error handling was always showing "Save failed." — now shows:
   - "Server unreachable. Check your connection and try again." for network errors
   - "Not authenticated. Please log in and try again." for 401 responses
   - The server's detail message (with status code) for other errors

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 22:27:17 +02:00
David Montero 32acf80e0d fix: propagate has_wifi from compiler to startBoard for reliable WiFi detection
Frontend WiFi detection via file-content scanning was unreliable because
fileGroups[board.activeFileGroupId] could be an empty array (not null),
bypassing the ?? fallback to editorState.files.

Fix: the ESP-IDF compiler now returns has_wifi:bool in its compile response.
The frontend stores this on the BoardInstance and uses it in startBoard()
instead of scanning file contents. The file-content scan is kept as a
fallback for boards that haven't been compiled in this session.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 22:14:40 +02:00
David Montero 7c755ca3d1 fix: use board's file group for WiFi auto-detection instead of legacy global files
startBoard() was reading useEditorStore.getState().files (the legacy global
array with the default Arduino sketch) instead of the board's specific file
group. This caused hasWifi to always be false for ESP32 boards, so QEMU
never received the -nic flag and WiFi never connected.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-05 21:36:04 +02:00
David Montero Crespo f495a2ce3a feat: implement ESP32 QEMU backend manager and frontend simulation interface 2026-04-01 22:41:52 -03:00
David Montero 69aaa070f2 chore: update sitemap.xml with current date
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 19:30:28 +02:00
David Montero f29e964e91 fix: ESP32 Run button auto-compiles and recovers firmware after page refresh
- handleRun now auto-compiles for ESP32/QEMU boards when no firmware is
  available (same behavior as AVR/RP2040 boards)
- startBoard now reloads compiledProgram into the bridge if _pendingFirmware
  was lost (e.g. after a page refresh between compile and run)
- Adds Esp32Bridge.hasFirmware() helper used by the store check

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-01 18:47:15 +02:00
David Montero Crespo 4b8e342a71
Merge pull request #88 from davidmonterocrespo24/feature/wifi-esp32
Feature/wifi esp32
2026-04-01 01:40:09 -03:00
David Montero Crespo e8511f2257
Merge pull request #84 from davidmonterocrespo24/feature/remove-board-from-workspace
feat: allow removing boards from workspace
2026-03-31 23:11:27 -03:00
David Montero Crespo 54f8f2782b feat: add ESP32 WiFi/BLE emulation with ESP-IDF compilation pipeline
Replace arduino-cli with ESP-IDF 4.4.7 for ESP32 compilation — Arduino-compiled
firmware crashes in QEMU (9-28 reboots) while ESP-IDF boots cleanly (0 reboots).
The new espidf_compiler translates Arduino WiFi/WebServer sketches to native
ESP-IDF C code, compiles with cmake+ninja, and merges into 4MB flash images.

Key changes:
- ESP-IDF compiler: translates WiFi.begin/WebServer to esp_wifi/esp_http_server
- ESP-IDF project template with QEMU-optimized sdkconfig (DIO, 40MHz, no WDT)
- WiFi status parser for ESP-IDF serial logs (wifi_status, ble_status events)
- IoT Gateway HTTP reverse proxy for ESP32 web servers
- WiFi/BLE auto-detection from sketch content + visual status icons
- Static IP 192.168.4.15 matching slirp DHCP first-client range
- Docker: new espidf-builder stage with ESP-IDF 4.4.7 toolchain
- 157 tests covering WiFi/BLE for both ESP32 (Xtensa) and ESP32-C3 (RISC-V)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-31 20:53:56 -03:00
David Montero Crespo 8c68879ce7 feat: add share functionality for projects and examples
- Implemented ExampleLoaderPage to load examples by ID from the URL.
- Added ExampleLoaderPage route to App component.
- Created ShareModal for sharing project links with visibility toggle.
- Updated UserProfilePage to include share button for user projects.
- Enhanced ExamplesGallery with a copy link button for examples.
- Introduced utility function loadExample to streamline example loading and library installation.
- Updated project visibility management in useProjectStore.
- Added styles for new components and buttons.
- Updated .gitignore to include Arduino compilation byproducts.
2026-03-30 19:00:33 -03:00
David Montero Crespo 0bc4c031d1 feat: add MicroPython support for ESP32-C3 (RISC-V) boards
ESP32-C3 already uses the QEMU backend via Esp32Bridge, not browser-side
emulation. This adds MicroPython support by including C3 in the supported
set, adding the C3 firmware variant to the loader, and bundling the
fallback firmware binary.

Also fixes misleading type comments that said "browser emulation" for C3
boards — they actually use QEMU backend.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 23:40:05 -03:00
David Montero Crespo 7c9fd0bf2b feat: add MicroPython support for ESP32/ESP32-S3 boards via QEMU bridge
Extends MicroPython support (Phase 2) to ESP32 Xtensa boards running on
QEMU. Firmware is downloaded from micropython.org, cached in IndexedDB,
and loaded into QEMU. User code is injected via the raw-paste REPL
protocol after the MicroPython REPL boots.

- Create Esp32MicroPythonLoader.ts for firmware download/cache
- Add raw-paste REPL injection (Ctrl+A → Ctrl+E → code → Ctrl+D) to Esp32Bridge
- Extend loadMicroPythonProgram in store for ESP32 path
- Add ESP32 default MicroPython content (GPIO 2 blink)
- Simplify SerialMonitor Ctrl+C/D to work for all MicroPython boards
- Bundle fallback firmware for ESP32 and ESP32-S3
- Add all ESP32 board variants to SerialMonitor tab maps

Closes #3 (Phase 2)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 23:12:24 -03:00
David Montero Crespo 990ae4be8c feat: add MicroPython support for RP2040 boards (Pico / Pico W)
Implements MicroPython emulation for Raspberry Pi Pico boards running
entirely in the browser using rp2040js. Users can toggle between
Arduino C++ and MicroPython modes via a language selector dropdown.

Key changes:
- Add LanguageMode type and BOARD_SUPPORTS_MICROPYTHON to board types
- Create MicroPythonLoader.ts: UF2 firmware parser, LittleFS filesystem
  builder (via littlefs-wasm), IndexedDB firmware caching
- Extend RP2040Simulator with loadMicroPython() method using USBCDC for
  serial REPL instead of UART
- Add setBoardLanguageMode and loadMicroPythonProgram store actions
- Update EditorToolbar with language toggle and MicroPython compile flow
- Enhance SerialMonitor with REPL label, Ctrl+C/D support
- Bundle MicroPython v1.20.0 UF2 firmware as fallback in public/firmware/
- Update useEditorStore to create main.py default for MicroPython mode

Closes #3

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 21:27:41 -03:00
David Montero Crespo 558525b4b2 test: add firmware loader tests with real compiled binaries
Tests for firmwareLoader.ts utility covering:

Unit tests (44 tests):
- Format detection (.hex, .bin, .elf by magic bytes and extension)
- ELF architecture detection (AVR, ARM, RISC-V, Xtensa, big/little endian)
- binaryToIntelHex round-trip through hexParser
- ELF PT_LOAD segment extraction with synthetic and real ELF files
- readFirmwareFile for all formats and board types

Integration tests with arduino-cli compiled firmware:
- AVR: .hex and .elf loaded into AVRSimulator, start/stop verified
- RP2040: .bin and .elf loaded, base64 encoding verified
- ESP32-C3: existing fixture .bin and .elf, RISC-V detection verified

Cross-format compatibility:
- .hex → AVR, .bin → RP2040, architecture mismatch warnings
- File size limit enforcement (16MB max)

All 663 tests pass (25 test files).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 13:01:34 -03:00
David Montero Crespo 4e9bf09e65 feat: load precompiled firmware files (.hex, .bin, .elf) directly
Closes #1

Add the ability to upload precompiled firmware files directly into the
emulator, bypassing the built-in compilation step. This enables users
with custom toolchains (ESP-IDF, PlatformIO, ASM workflows) to use
Velxio purely as an emulation/debugging environment.

New features:
- "Upload firmware" option in the overflow menu (accepts .hex, .bin, .elf)
- Automatic format detection from file extension and magic bytes
- ELF parser extracts PT_LOAD segments and detects target architecture
  (AVR, ARM, RISC-V, Xtensa) from ELF e_machine header
- Architecture mismatch warnings logged when ELF target differs from
  current board (non-blocking — upload proceeds anyway)
- Firmware routed to the correct simulator loader via existing
  compileBoardProgram() — no simulator changes needed

Supported formats per board:
- AVR (Uno/Nano/Mega/ATtiny85): .hex (direct), .elf (parsed → HEX)
- RP2040 (Pico): .bin (direct), .elf (parsed → binary)
- ESP32-C3: .bin (direct), .hex, .elf (parsed → binary)
- ESP32/S3 (QEMU): .bin (direct), .elf (parsed → binary)

New file: frontend/src/utils/firmwareLoader.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 02:08:11 -03:00
David Montero Crespo 5dac9bca5c feat: allow removing boards from workspace
Closes #14

- Right-click context menu on boards with "Remove board" option
- Delete/Backspace key removes the active board (when no component selected)
- Confirmation dialog before removal showing connected wire count
- Removing a board also removes all connected wires and cleans up
  file groups, simulators, bridges, and VFS
- Cannot remove the last remaining board (button disabled + guard)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 01:55:10 -03:00
David Montero Crespo 67f9bc70c6 feat: auto-compile when pressing Play if code changed or no hex loaded
Closes #81

- Add `codeChangedSinceLastCompile` dirty flag to useEditorStore
- Play button now triggers compilation automatically when no compiled
  program exists or code has changed since last compile
- Show compilation progress during auto-compile before run
- If compilation fails, show errors instead of running stale code
- Keep separate Compile button for manual compile-only workflow
- Play button always enabled (disabled only while running/compiling)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-29 01:46:07 -03:00
David Montero Crespo e99ded70b5 feat: update AboutPage with new external links and improve press section 2026-03-28 23:11:57 -03:00