7bc9afae33
Follows lib/esp32-lua-api: gui -> screen, node -> tree, settings and input split into screen/sys/touch/buttons. Settings is one provider lighter, with timezone on Sys and rotation and theme on Gui, which now applies and persists a rotation in one call. The calibration screen stashes the rotation it borrows rather than relying on a transient setter.
48 lines
1.1 KiB
Lua
48 lines
1.1 KiB
Lua
local ui = require "ui"
|
|
|
|
local FONT = screen.FONT_UI
|
|
|
|
local M = {}
|
|
local seconds = 0
|
|
local uptime
|
|
|
|
local function text()
|
|
return "uptime: " .. seconds .. "s"
|
|
end
|
|
|
|
function M.init()
|
|
timer.every(1000, function()
|
|
seconds = seconds + 1
|
|
ui.setText(uptime, text())
|
|
end)
|
|
log.info("hello app started, screen " .. screen.getWidth() .. "x" .. screen.getHeight())
|
|
end
|
|
|
|
function M.node()
|
|
-- A fixed slot for the clock, because a node keeps the box it was measured with and the
|
|
-- text grows a digit at a time.
|
|
uptime = ui.text(text(), {
|
|
w = screen.getTextWidth(FONT, "uptime: 00000s"),
|
|
h = screen.getFontHeight(FONT),
|
|
font = FONT,
|
|
})
|
|
return ui.box {
|
|
w = "fill",
|
|
h = "fill",
|
|
pad = 10,
|
|
gap = 20,
|
|
ui.text("hello from sd card", { font = FONT }),
|
|
ui.text("touch the screen", { font = FONT, color = ui.theme.muted }),
|
|
uptime,
|
|
}
|
|
end
|
|
|
|
-- Painted straight to the panel rather than as nodes: the dots are a scribble, and the
|
|
-- tree would need one node each to remember them.
|
|
function M.on_touch(x, y)
|
|
log.info("touch at " .. x .. ", " .. y)
|
|
screen.fillCircle(x, y, 6, ui.theme.accent)
|
|
end
|
|
|
|
return M
|