Files
car-radio/car-radio/fusion/README.md
T
2026-10-27 21:13:36 -05:00

3.7 KiB
Raw Blame History

Fusion Audio — controller software and hardware emulator

Implements the Fusion Audio UI & Software Specification (draft v0.2) in Go: a pure UI core, drivers behind generic interfaces, and two terminal emulators (FDIM display, FCIM buttons) so the whole system runs on a laptop.

Status: written without compiling or running anything. First thing to do: go vet ./... && go test ./... and fix whatever the compiler finds.

Three terminals

# terminal 1 – the front display (listens on :7002)
go run ./cmd/fdim

# terminal 2 – the core software (listens for buttons on :7001, dials the display)
go run ./cmd/fusiond

# terminal 3 – the buttons (raw keyboard; `-line` for typed button names)
go run ./cmd/fcim

Start order does not matter: the core reconnects to the display with backoff (0.5 s → 10 s) and replays its full state when the link comes back.

FCIM keys: [/] or -/= or ↑/↓ volume · ←/→ tune · Enter/Space OK · m MENU · p POWER · c CLOCK · a AUX · s SIRIUS · h PHONE · o SOUND · ,/. seek · 0–9 digits · l e d n f t r v u j the unused buttons · q quit.

The core terminal also takes simulated-hardware commands (help lists them): connect Pixel, media Title|Artist|Album, ring Alice, pair X, dsp fail, … Pair a phone: Menu → Bluetooth → Pair New, then type pair MyPhone.

Generic hardware APIs (dependency injection)

Everything the core talks to is injected through app.Deps:

Peripheral Interface Implementations
FDIM fdim.Display – DisplayText(row1,row2), SetSourceLabel, SetClock, KeepAlive fdim.NetDisplay (to the emulator), fdim.Memory (tests)
FCIM fcim.Source – Pulses() <-chan string (button names) fcim.NetSource (from the emulator), fcim.Chan (tests)
DSP dsp.Device dsp.Sim
Bluetooth bt.Module bt.Sim
Clock / settings platform.Clock, platform.Store SysClock, FileStore, MemStore

A real CAN-backed FDIM/FCIM only needs to implement those two small interfaces.

Layout

core/       pure UI core: handle(state,event) -> commands + frame (no I/O, no clock)
  script.go   plain-text test-script runner (shared acceptance suite, SDS §14.11)
tests/      *.test scripts run by core/script_test.go
fdim/ fcim/ dsp/ bt/ platform/   drivers, fakes, simulators
app/        wiring + main loop (events in, commands/frames out, DSP health probing)
cmd/        fdim, fcim, fusiond binaries

Tests

go test ./... runs: the script suite (tests/*.test, covering boot, standby, volume, menus, source select, Now Playing paging, Bluetooth, pairing, clock editor, phone, health, reboot), unit tests for paging, character mapping, loudness table vs. the 10·log2(p) formula, the frame-diff driver and keep-alive, the network links, key mapping, settings store, and a 100 000-step randomised invariant test of the core.

Decisions where the SDS was open or ambiguous

  • Items tagged Proposed are implemented (wrapping lists, restoring the selection on back, Bluetooth pairing 120 s, reboot prompt, phone overlay).
  • Open character-set question: the core emits › · █ ░; fdim.Charset maps them to > - # - for ASCII-only displays (fusiond -ascii).
  • Boot volume cap (open question 3): core.Config.BootVolumeCap, default off.
  • Minute first digit 6–9: ignored (the SDS's safe default).
  • When the two Now Playing lines have different page counts the shorter one holds its last page while the other continues.
  • A page break at a space renders word ›; a break at column 19 or inside a word renders word› (so every page is ≤ 20 columns including the marker).
  • Not built (per SDS "Future"): Sound menu, S/PDIF, System Info.