75b3a2c490
Namespaces were shared across features: `settings` was written by core, the
panel and touch, and `input` by touch and buttons. That made "does this
firmware implement the whole feature?" a question no pointer could answer.
Each namespace now belongs to exactly one feature or to core, so a feature is
a provider pointer and the compiler validates completeness:
gui, node -> screen, tree, under the screen feature
settings -> screen (rotation, theme), sys (timezone),
touch (calibration)
input -> touch, buttons
Runtime::open() no longer requires a GuiProvider; a firmware without one runs
with no screen/tree globals and reports sys.hasFeature("screen") false.
Rotation is one value again: GuiProvider::setRotation applies and persists, so
an app rotating the panel transiently puts the old value back itself.
55 lines
1.4 KiB
Lua
55 lines
1.4 KiB
Lua
package.path = "./lua/lib/?.lua;" .. package.path
|
|
|
|
local drawn = {}
|
|
local roles = { "confirm", "back", "right" }
|
|
|
|
screen = {
|
|
FONT_SMALL = 0,
|
|
STYLE_NORMAL = 0,
|
|
color = function(r, g, b)
|
|
return r * 65536 + g * 256 + b
|
|
end,
|
|
getWidth = function()
|
|
return 300
|
|
end,
|
|
getHeight = function()
|
|
return 240
|
|
end,
|
|
getFontHeight = function()
|
|
return 8
|
|
end,
|
|
getTextWidth = function(_, text)
|
|
return #text * 6
|
|
end,
|
|
fillRect = function(x, y, w, h)
|
|
drawn.strip = { x, y, w, h }
|
|
end,
|
|
drawText = function(_, x, _, text)
|
|
drawn[#drawn + 1] = { text = text, x = x }
|
|
end,
|
|
}
|
|
|
|
buttons = {
|
|
getAll = function()
|
|
return roles
|
|
end,
|
|
}
|
|
|
|
local hints = require "hints"
|
|
|
|
local height = hints.draw { back = "Close", confirm = "Select", up = "Scroll" }
|
|
assert(height == 14, "height covers the font plus padding")
|
|
assert(drawn.strip[2] == 226, "the strip sits at the bottom by default")
|
|
|
|
-- "up" is labelled but this device lacks it, so it never reaches the strip.
|
|
assert(#drawn == 2, "only labelled roles the device reports are drawn")
|
|
assert(drawn[1].text == "Close" and drawn[2].text == "Select", "reading order, not action order")
|
|
assert(drawn[1].x == 60 and drawn[2].x == 207, "each label centres in its slot")
|
|
|
|
drawn = {}
|
|
roles = {}
|
|
assert(hints.draw { confirm = "Select" } == 14, "a device with no buttons still clears the strip")
|
|
assert(#drawn == 0 and drawn.strip, "nothing is labelled, but the strip is cleared")
|
|
|
|
print "ok"
|