Files
slate32/sdcard/apps/hello/main.lua
T
evan b5146b8642 refactor(lua): give the status bar its own dirty tracking and split settings out of sys
The bar repainted itself whole every second. It now compares each field against what
it last painted, adds seconds and a memory percentage, and keys the cache on
gui.getRotation() and ui.themeName so rotation and theme changes still repaint it.
Invalidation lives entirely in Lua; the firmware's push flag and gfx/statusbar.h are gone.

Bindings follow getName/setName/isName, persisted preferences move from sys to a settings
table, and gui.setRotation takes degrees like settings does. A bar that dies mid-run now
keeps its rows reserved rather than silently resizing the running app.
2026-08-02 10:49:01 -04:00

25 lines
714 B
Lua

local ui = require("ui")
local seconds = 0
-- Draws straight to the panel rather than through components, so it reads the theme.
local theme = ui.theme
function init()
sys.setTickInterval(1000)
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.getWidth() .. "x" .. gui.getHeight())
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