Expand browser editor runtime and LED simulation workflows.

Add Docker deployment support, richer Selenium/LED pattern tests, in-browser diagnostics, responsive UI improvements, and 16x16 panel simulation tooling to speed iteration and hardware-style prototyping.

Made-with: Cursor
This commit is contained in:
2026-05-01 20:24:05 +12:00
parent f204109a84
commit e4c811f51d
30 changed files with 1478 additions and 60 deletions

View File

@@ -48,6 +48,24 @@ If nothing is listening, the smoke test **skips** with a short message instead o
Open [http://localhost:8080](http://localhost:8080).
## Deploy with Docker
Build and run with Docker Compose:
```bash
cp .env.example .env
mkdir -p data
docker compose up --build
```
Then open [http://localhost:8080](http://localhost:8080).
Notes:
- `workspace/` is mounted to `/app/workspace` so your code persists locally.
- `data/` is mounted to `/app/data` for the SQLite auth DB.
- In container mode, `WORKSPACE_ROOT` and `AUTH_DATABASE_PATH` are set by `docker-compose.yml`.
**User accounts** — Set `AUTH_ENABLED=true` in `.env` to require sign-in for workspace APIs. Users live in a SQLite file (`AUTH_DATABASE_PATH`, default `./data/editor.db`). Use `/register` (if `AUTH_REGISTER_OPEN=true`) or `BOOTSTRAP_ADMIN_USERNAME` / `BOOTSTRAP_ADMIN_PASSWORD` for the first superuser. Superusers can **GET/POST/DELETE `/api/users`** to list, create, or remove accounts.
**API key** — If `EDITOR_API_KEY` is set, requests may use `Authorization: Bearer …` instead of a session (useful for automation). When `AUTH_ENABLED=true`, a valid session *or* API key is accepted.
@@ -58,3 +76,46 @@ The home page can store the API key in `sessionStorage` when you are not using c
- `src/` — FastAPI app and static UI (`src/static/`)
- `workspace/` — default tree: `code/` (editable), `lib/` (read-only via API)
## ESP32 / NeoPixel mock
The browser runtime now includes MicroPython-style mocks in `workspace/lib`:
- `machine.Pin`
- `neopixel.NeoPixel`
Use them from scripts in `workspace/code` exactly like ESP32 examples:
```python
from machine import Pin
import neopixel
np = neopixel.NeoPixel(Pin(4), 8)
np[0] = (255, 0, 0)
np.write()
```
`write()` updates the NeoPixel simulator window so you can verify behavior visually.
Tutorial files:
- `LED_TUTORIAL.md` - step-by-step NeoPixel tutorial
- `workspace/code/led_tutorial.py` - runnable guided LED example
- `workspace/code/led_patterns.py` - reusable pattern helpers (`rainbow_frame`, `chase_frame`, `twinkle_frame`)
- `workspace/code/pattern_rainbow_demo.py` - rainbow animation demo
- `workspace/code/pattern_chase_demo.py` - chase animation demo
- `workspace/code/pattern_twinkle_demo.py` - twinkle animation demo
- `workspace/code/panel16_utils.py` - helpers for 16x16 serpentine mapping
- `workspace/code/panel16_rainbow_wave.py` - 16x16 rainbow wave
- `workspace/code/panel16_bounce.py` - 16x16 bouncing pixel with trail
- `workspace/code/panel16_matrix_rain.py` - 16x16 matrix rain effect
## Dev auto-reload hook
Project hook files are included in `.cursor/`:
- `.cursor/hooks.json`
- `.cursor/hooks/dev-reload-touch.sh`
When files are edited through Cursor tools, the hook updates `src/static/.reload-token`.
The editor (on localhost) polls that token and auto-reloads the browser when it changes.