velxio/backend/app
David Montero Crespo 977308ef80 fix(spi-batch): add 50ms safety flush so frames keep arriving
User reported only 2 frames rendering after the SPI batching change.

Diagnosis: the previous flush triggers (CS-line HIGH, buffer >=4096)
were both event-driven. Adafruit_ILI9341's ESP32 backend manages CS
via digitalWrite — i.e. through the GPIO peripheral, NOT the SPI
peripheral's hardware CS pin. So the CS-line-HIGH event from
picsimlab_spi_event NEVER fires for this driver. The buffer only
flushes when it hits 4096 bytes.

Frame 1: 38 400 bytes from drawRGBBitmap → 9 flushes at 4096-byte
boundaries → last 192 bytes stay in the buffer. Status bar adds
some bytes too → maybe one more flush.

Frame 2: same. But by frame 3 the firmware is running ahead of the
flush rhythm and somehow the buffer pattern wedges in a state where
no flush completes (likely a partial buffer that sits between
transactions while the firmware briefly waits on the next fb_get).
Hard to reproduce deterministically — but the symptom matches.

Fix: add a 50 ms periodic flush thread. Independent of any event,
it acquires the lock and flushes whatever's pending. Bounds the
worst-case latency at 50 ms (= 20 fps ceiling, more than enough for
the emulator).

Triple-trigger now:
  1. CS HIGH (fast path for hardware-CS drivers)
  2. Buffer >= 4096 (safety for big transactions)
  3. 50 ms timer (catches GPIO-CS drivers, prevents stalls)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-03 00:31:16 -03:00
..
api Merge pull request #137 from davidmonterocrespo24/esp32-cam 2026-05-02 22:40:06 -03:00
core feat: add admin management features and user role handling 2026-03-06 23:46:36 -03:00
database feat: implement user authentication and project management features 2026-03-06 10:14:50 -03:00
mcp feat: integrate MCP (Model Context Protocol) for agent compatibility 2026-03-11 15:29:55 +00:00
models feat: persist multi-board projects + add auto-save 2026-05-01 13:43:33 -03:00
schemas feat: persist multi-board projects + add auto-save 2026-05-01 13:43:33 -03:00
services fix(spi-batch): add 50ms safety flush so frames keep arriving 2026-05-03 00:31:16 -03:00
utils feat(metrics): add usage analytics dashboard with country tracking 2026-04-25 19:47:40 -03:00
__init__.py
main.py feat: persist multi-board projects + add auto-save 2026-05-01 13:43:33 -03:00