Files
slate32/sdcard/apps/hello/main.lua
T
evan d338dfe3e8 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.
2026-08-01 17:52:32 -04:00

26 lines
696 B
Lua

local ui = require("ui")
TICK_MS = 1000
local seconds = 0
-- Draws straight to the panel rather than through components, so it reads the theme.
local theme = ui.theme
function init()
gui.clear(theme.bg)
gui.drawText("hello from sd card", 10, 10, theme.fg, theme.bg)
gui.drawText("touch the screen", 10, 30, theme.muted, theme.bg)
log.info("hello app started, screen " .. gui.width() .. "x" .. gui.height())
end
function on_tick()
seconds = seconds + 1
gui.fillRect(10, 50, 120, 20, theme.bg)
gui.drawText("uptime: " .. seconds .. "s", 10, 50, theme.fg, theme.bg)
end
function on_touch(x, y)
log.info("touch at " .. x .. ", " .. y)
gui.fillCircle(x, y, 6, theme.accent)
end