refactor: rename the app entry point to init() and require it

crosspoint-reader calls it init() and requires it; this called it setup() and treated
it as optional. Same concept, two spellings, so an app could not move between the two
firmwares for no reason worth defending. init() wins because it is also the stricter
contract: a misspelled entry point is now an error instead of an app that starts,
draws nothing, and explains nothing.

Requiring it exposed that error screens were unreadable. fail() painted the message
and the host relaunched the launcher over it on the very next frame, so every Lua
error was serial-only -- which would have made "Missing init()" useless to anyone
holding the device rather than a console.
This commit is contained in:
2026-08-01 17:52:32 -04:00
parent 6f2d618b8d
commit d338dfe3e8
11 changed files with 37 additions and 16 deletions
+2 -2
View File
@@ -12,7 +12,8 @@ Compared against crosspoint-reader at `src/util/lua/LuaBindings*.cpp`.
`fs.listDirs`, `fs.listFiles`, `fs.exists`, `fs.readFile`, `fs.writeFile`,
`gui.width`, `gui.height`, `gui.fillRect`, `gui.drawRect`, `gui.drawLine`,
`sys.millis`, `sys.delay`, `sys.exit`, `log.debug/info/error`, the whole `http` table,
and the `draw()` / `on_tick()` callbacks.
and the `init()` / `draw()` / `on_tick()` callbacks. `init()` is required in both, so a
misspelled entry point is an error rather than an app that quietly draws nothing.
## Deliberate differences
@@ -37,7 +38,6 @@ Each of these is the same concept spelled two ways. Fixing them means changing o
| Concern | crosspoint-reader | esp32-lcd | Suggested resolution |
|---|---|---|---|
| Entry callback | `init()`, required | `setup()`, optional | Pick one name. Neither is better. |
| Tick interval | `app.setTickInterval(ms)` | global `TICK_MS` | Pick one mechanism. |
| `wifi.status()` | returns a **string** | returns a **table** of state/ssid/ip/rssi | Same name, incompatible types — the sharpest edge here. This repo added `isConnected()` and `localIP()` so the crosspoint idioms work either way. |
| `wifi.connect()` | no arguments, uses stored credentials | `(ssid, password)`, saves them | Both are wanted: a no-argument reconnect and an explicit join. |