render pads and add ux to scroll through them

This commit is contained in:
Travis Shears 2026-02-02 12:21:13 +01:00
parent eb4dc47f35
commit 9624962bb4
Signed by: travisshears
GPG key ID: CB9BF1910F3F7469
5 changed files with 54 additions and 2 deletions

Binary file not shown.

BIN
l5-mockup/images/bg.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

View file

@ -1,14 +1,66 @@
require("L5") require("L5")
local bgImg
local pads = {
["S1"] = { 98, 25, 68, 48, img = 1 },
["S2"] = { 175, 25, 68, 48, img = 1 },
["S3"] = { 98, 83, 68, 48, img = 1 },
["S4"] = { 175, 83, 68, 48, img = 1 },
["C1"] = { 262, 23, 71, 110, img = 1 },
["W1"] = { 346, 60, 79, 84, img = 1 },
["F1"] = { 0, 0, 47, 159, img = 1 },
["F2"] = { 0, 162, 129, 29, img = 1 },
["A1"] = { 282, 202, 90, 58, img = 1 },
["A2"] = { 376, 202, 90, 58, img = 1 },
["A3"] = { 284, 262, 90, 58, img = 1 },
["A4"] = { 413, 260, 67, 60, img = 1 },
}
local selectedKeyPad = "S1"
local padScrollOrder = {}
-- TODO: replace this with ideal scroll order
for key, _ in pairs(pads) do
table.insert(padScrollOrder, key)
end
function setup() function setup()
size(480, 320) -- the size of the LCD screen size(480, 320) -- the size of the LCD screen
windowTitle("Kitchen Timer Mockup") windowTitle("Kitchen Timer Mockup")
-- Sets print command output to display in window -- Sets print command output to display in window
printToScreen() printToScreen()
describe('Draws a yellow background!!!!') describe('Draws a yellow background!!!!')
bgImg = loadImage('images/bg.png')
local padsImg1 = loadImage('images/pads_001.png')
local padsImg2 = loadImage('images/pads_002.png')
for _, pad in pairs(pads) do
if pad.img == 1 then
pad.img = padsImg1
elseif pad.img == 2 then
pad.img = padsImg2
end
end
end
local function drawPad(padId)
local pad = pads[padId]
if pad then
copy(pad.img, pad[1], pad[2], pad[3], pad[4], pad[1], pad[2], pad[3], pad[4])
end
end end
function draw() function draw()
-- Fills the background with the color yellow image(bgImg, 0, 0)
background(255, 215, 0) drawPad(selectedKeyPad)
end
local padScrollIndex = 1
function mouseWheel(upDown)
local scrollDirection = upDown == 1 and "up" or "down"
if scrollDirection == "up" and padScrollIndex == #padScrollOrder then
padScrollIndex = 1
elseif scrollDirection == "down" and padScrollIndex == 1 then
padScrollIndex = #padScrollOrder
else
padScrollIndex = padScrollIndex + (scrollDirection == "up" and 1 or -1)
end
selectedKeyPad = padScrollOrder[padScrollIndex]
end end