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:
@@ -16,6 +16,7 @@ static constexpr int SD_MISO = 19;
|
||||
static constexpr int TOUCH_CS = 33;
|
||||
|
||||
static const char* LAUNCHER = "/apps/launcher/main.lua";
|
||||
static constexpr uint32_t ERROR_HOLD_MS = 5000;
|
||||
|
||||
// Arduino's default 8KB loop stack is not enough once a TLS handshake runs inside a
|
||||
// Lua binding: the first HTTPS download tripped the stack canary. Everything the VM
|
||||
@@ -79,6 +80,10 @@ void loop() {
|
||||
return;
|
||||
}
|
||||
|
||||
// An app that died left its message on screen, and the launcher is about to paint
|
||||
// over it. Serial alone is no help to anyone holding the device.
|
||||
if (app.takeFailure()) delay(ERROR_HOLD_MS);
|
||||
|
||||
String path = nextApp.length() > 0 ? nextApp : String(LAUNCHER);
|
||||
nextApp = "";
|
||||
startApp(path);
|
||||
|
||||
Reference in New Issue
Block a user