Split the sketch into a device-agnostic renderer core (RoomViewCore.h: RGB565 rasterizer, camera, world sim — no emulator dependencies) plus a thin emulator shell (keyboard pump + the 565-to-8888 presentation blit). Add fw/ as a self-contained PlatformIO project (own platformio.ini pointing at the shared boards/, lib/ and src/netdeck headers — per-env src_dir is not supported by PlatformIO, so NetDeck's top-level config stays untouched). fw/RoomViewHW.ino is the firmware twin: the core rasterizes directly into a TFT_eSprite's frameBuffer() (16-bit, PSRAM) and presents with the proven NetDeck startWrite/pushSprite/endWrite pattern. The loop free-runs and reports true throughput over USB serial every 2 s: fps + average render vs. push split. Verified: emulator render unchanged (smoke frame identical), pio RoomViewHW env builds clean for ESP32-S3 (346 KB flash), make netdeck dual build green.
113 lines
4.2 KiB
Markdown
113 lines
4.2 KiB
Markdown
# tron-room-demo — RoomView
|
|
|
|
A top-down "3D" flythrough of **NetDeck's demo map**, built on the same
|
|
emulator-only template as `tron-demo` (SDL3 host, 320x240 ABGR8888
|
|
framebuffer, `setup()`/`loop()` sketch contract — see the original
|
|
template README below).
|
|
|
|
What makes this one different: the sketch renders the **real** Breach &
|
|
Board demo floorplan from the firmware tree (`src/netdeck/nd_demomap.h`,
|
|
consumed through the generic `MapSource` interface). There is no local
|
|
copy of the map — edit the demo map in `src/netdeck` and this view
|
|
follows it.
|
|
|
|
The whole render pipeline runs in **RGB565** — the ST7789 panel's native
|
|
format — with the palette taken directly from `nd_layout.h`. Shading and
|
|
fog are integer fixed-point on the 5/6/5 channels, so the visible color
|
|
banding is exactly what real hardware would produce. Only the final
|
|
blit expands 565→8888 for the desktop window (the stand-in for the SPI
|
|
push, which on the device ships the 565 buffer as-is).
|
|
|
|
## What you see
|
|
|
|
- A true 3D orbiting camera (position + look-at basis, perspective
|
|
divide) drifting over the deck on a slow orbit with breathing
|
|
radius/height.
|
|
- `#` walls, `o` cover crates, the `+` blast door and the `T` terminal
|
|
as solid shaded boxes: backface culling, painter's-algorithm depth
|
|
sort, lambert lighting from above, distance fog, bright top rims.
|
|
- Floor tiles as lit quads with a subtle checker.
|
|
- The demo map's **network graph** as glowing pylons with teal link
|
|
lines and cyan packets traveling along the edges.
|
|
- Every entity from the demo spawn list walking its patrol route
|
|
(marines cyan, droids orange, heavy red, turrets magenta), plus a
|
|
pulsing halo over the airlock.
|
|
|
|
## Keys
|
|
|
|
| Key | Action |
|
|
|-----|--------|
|
|
| `a` / `d` | orbit faster / slower (or reverse) |
|
|
| `w` / `s` | zoom in / out |
|
|
| `r` / `f` | raise / lower the camera |
|
|
| `space` | pause the camera drift + patrols |
|
|
| `q` / ESC | quit |
|
|
|
|
## Build & Run
|
|
|
|
```bash
|
|
make run # build + open a window
|
|
make smoke # headless: 240 frames -> smoke_frame.bmp
|
|
make clean
|
|
```
|
|
|
|
The Makefile is the template's, with two changes: `APP ?= RoomView`
|
|
and `-I ../src/netdeck` on the include path.
|
|
|
|
## On the real T-Deck (ESP32-S3) — free-running benchmark
|
|
|
|
The renderer lives in `RoomViewCore.h`, device-agnostic and shared 1:1
|
|
between the emulator sketch and the firmware twin
|
|
`fw/RoomViewHW.ino`. On hardware the core draws straight into a
|
|
`TFT_eSprite`'s `frameBuffer()` (16-bit RGB565, PSRAM — the same
|
|
full-frame pipeline as NetDeck's M1 anti-flicker pattern) and pushes
|
|
with `startWrite()/pushSprite(0,0)/endWrite()`.
|
|
|
|
The loop is deliberately **free-running** — no pacing — and prints a
|
|
report over USB serial every 2 s:
|
|
|
|
```
|
|
RoomViewHW: 120 frames in 2001ms = 60.0 fps | render 12.3 ms, push 14.8 ms
|
|
```
|
|
|
|
That `render` / `push` split is the answer to "how quickly does this
|
|
run on real hardware": render is the software rasterizer, push is the
|
|
SPI transfer to the panel.
|
|
|
|
Build, flash and watch:
|
|
|
|
```bash
|
|
pio run -d tron-room-demo/fw -t upload
|
|
pio device monitor # 115200 baud
|
|
```
|
|
|
|
(The demo has its own `fw/platformio.ini` pointing at the shared
|
|
`boards/`, `lib/` and `src/netdeck` headers — NetDeck's own builds are
|
|
untouched. Keyboard input is emulator-only; on hardware the camera
|
|
drifts on its own orbit.)
|
|
|
|
## Safety hatch / CLI options
|
|
|
|
Same as the template: `--user-run` (run indefinitely), `--timeout MS`,
|
|
`--frames N`, `--dump PATH`. By default the emulator exits after 10 s;
|
|
use `./RoomView-emu --user-run` for interactive viewing.
|
|
|
|
---
|
|
|
|
# T-Deck Emulator-Only Template (original README)
|
|
|
|
A minimal, self-contained SDL3 emulator template for prototyping 320x240
|
|
graphics/engine experiments without any hardware. No TFT_eSPI, no SPI,
|
|
no I2S, no GPIO — just SDL3 and a framebuffer.
|
|
|
|
**Do not** edit `src/main.cpp` or `shim.h` — they are the host and are
|
|
app-agnostic. The sketch lives in `examples/$(APP)/$(APP).cpp` and is
|
|
compiled as a single translation unit with the host via `-DAPP_SRC=…`.
|
|
|
|
| Flag | Description |
|
|
|------|-------------|
|
|
| `--user-run` | Disable the 10 s auto-exit (interactive use) |
|
|
| `--timeout MS` | Auto-exit after MS milliseconds (default 10000) |
|
|
| `--frames N` | Exit after N frames instead |
|
|
| `--dump PATH` | Save the last frame to PATH (BMP) |
|