velxio/examples
David Montero Crespo a20b10a252 perf(esp32-cam-lcd-preview): 4x faster preview by shrinking SPI traffic
User reported the live preview "looks slow" after the JPEG decode fix.
Diagnosis: each tft.drawRGBBitmap pushes width × height × 2 bytes over
SPI, and every byte takes a full QEMU → worker → backend (WS) → frontend
round-trip. At 160×120 that's 38 400 messages per frame; the bus
saturates at ~0.2 fps perceived.

Two changes shrink the per-frame SPI bandwidth:

1. Preview 160×120 → 80×60 (and JPG_SCALE_2X → JPG_SCALE_4X).
   38 400 bytes/frame → 9 600 bytes/frame. Already 4× faster.

2. Status bar redraw throttled to every 10th frame instead of every
   frame. The text writes (printf, fillRect, fillCircle) account for
   another ~1-2 KB of SPI traffic per loop iteration. Skipping 9 of
   every 10 redraws frees up a chunk more bandwidth without losing
   the headline numbers (fps, frame counter) — they just refresh
   once a second instead of 5x/sec.

Also dropped the trailing `delay(20)` — we don't need an artificial
throttle, the SPI bus is the throttle.

Real-hardware effect: zero. ESP32 SPI runs at 80 MHz; a full
160×120 bitmap pushes in ~4 ms either way.

Applied in two places:
- examples/esp32-cam-lcd-preview/esp32-cam-lcd-preview.ino
- frontend/src/data/examples.ts (in-app gallery copy)

Long-term plan: batch SPI bytes at the worker level (one WS message
per N bytes instead of per byte) — that's a deeper change in
qemu-lcgamboa + Esp32Bridge.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:15:06 -03:00
..
esp32-cam-lcd-preview perf(esp32-cam-lcd-preview): 4x faster preview by shrinking SPI traffic 2026-05-03 00:15:06 -03:00
README.md docs(examples): add ESP32-CAM + ILI9341 live preview example 2026-05-02 22:14:42 -03:00

README.md

Velxio examples

Ready-to-run sketches that exercise specific Velxio features end-to-end. Each subdirectory ships:

  • *.ino — the sketch (paste into Velxio's editor)
  • diagram.json — wiring layout (parts + connections, Wokwi-compatible format)
  • libraries.txt — Arduino libraries to install via Library Manager
  • README.md — wiring picture, run instructions, what to expect

Index

Folder Board Demonstrates
esp32-cam-lcd-preview/ ESP32-CAM + ILI9341 Live webcam preview decoded with jpg2rgb565 and rendered to a 320×240 SPI TFT

Adding a new example

  1. Create a folder named after the demo (e.g. arduino-uno-pong-rgb/).
  2. Drop in the four files above.
  3. Wire diagram.json using the velxio/wokwi part types — see existing examples for naming. Velxio-specific boards use the velxio- prefix (velxio-esp32-cam); generic Wokwi parts use wokwi- (wokwi-ili9341, wokwi-led, etc.).
  4. Add a row to the table above.

If your example needs more than the standard libraries, list every required library in libraries.txt (one per line, # for comments).