2023-04-17 18:49:53 +00:00
|
|
|
node.alias "testcard"
|
2023-03-14 08:55:54 +00:00
|
|
|
util.init_hosted()
|
|
|
|
|
|
|
|
local json = require "json"
|
|
|
|
|
|
|
|
local serial = sys.get_env "SERIAL"
|
2023-03-14 12:40:56 +00:00
|
|
|
local location = ""
|
2023-03-14 08:55:54 +00:00
|
|
|
local description = "<please wait>"
|
|
|
|
|
|
|
|
util.data_mapper{
|
|
|
|
["device_info"] = function(info)
|
|
|
|
info = json.decode(info)
|
|
|
|
location = info.location
|
|
|
|
description = info.description
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
|
|
|
|
|
|
|
|
card = resource.load_image("testcard.png")
|
|
|
|
font = resource.load_font("vera.ttf")
|
|
|
|
|
2023-04-17 18:49:53 +00:00
|
|
|
local v = {}
|
|
|
|
|
|
|
|
util.data_mapper{
|
|
|
|
["update/(.*)"] = function(key, val)
|
|
|
|
v[key] = val
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2023-03-14 08:55:54 +00:00
|
|
|
function node.render()
|
|
|
|
gl.clear(0,0,0,1)
|
|
|
|
|
|
|
|
card:draw(0, 0, 1920, 1080)
|
|
|
|
|
|
|
|
-- upper: 623
|
|
|
|
-- lower: 707
|
|
|
|
|
2023-04-17 18:49:53 +00:00
|
|
|
upper_text = "CCC: " .. description
|
2023-03-14 12:40:56 +00:00
|
|
|
|
|
|
|
if location == nil or location == '' then
|
|
|
|
lower_text = "Serial " .. serial
|
|
|
|
else
|
|
|
|
lower_text = location .. " - Serial " .. serial
|
|
|
|
end
|
2023-03-14 08:55:54 +00:00
|
|
|
|
|
|
|
upper_width = font:width(upper_text, 40)
|
2023-03-14 11:58:52 +00:00
|
|
|
font:write(960-(upper_width/2), 631, upper_text, 40, 1,1,1,1)
|
2023-03-14 08:55:54 +00:00
|
|
|
|
|
|
|
lower_width = font:width(lower_text, 20)
|
2023-03-14 11:58:52 +00:00
|
|
|
font:write(960-(lower_width/2), 679, lower_text, 20, 1,1,1,1)
|
2023-04-17 18:49:53 +00:00
|
|
|
|
2023-04-17 19:30:21 +00:00
|
|
|
-- available space y: 400 to 700
|
|
|
|
-- left x: 50
|
|
|
|
-- right x: TODO
|
|
|
|
local size = 40
|
|
|
|
local x_left = 50
|
|
|
|
local x_right = 1000
|
|
|
|
|
|
|
|
-- left side: network config, online status
|
2023-04-17 18:49:53 +00:00
|
|
|
if v.network then
|
2023-04-17 19:30:21 +00:00
|
|
|
font:write(50, 400, "Mode: " .. v.network, size, 1,1,1,1)
|
2023-04-17 18:49:53 +00:00
|
|
|
end
|
2023-04-17 19:30:21 +00:00
|
|
|
|
|
|
|
if v.online then
|
|
|
|
local col = {1,0,0,1}
|
|
|
|
if v.online == "online" then
|
|
|
|
col = {0,1,0,1}
|
|
|
|
end
|
|
|
|
font:write(50, 450, v.online, size, col)
|
|
|
|
end
|
|
|
|
|
|
|
|
-- right side: IP address
|
2023-04-17 18:49:53 +00:00
|
|
|
if v.ethip then
|
2023-04-17 19:30:21 +00:00
|
|
|
font:write(1000, 400, "Eth IPv4: " .. v.ethip, size, 1,1,1,1)
|
2023-04-17 18:49:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if v.wlanip then
|
2023-04-17 19:30:21 +00:00
|
|
|
font:write(1000, 450, "WiFi IPv4: " .. v.wlanip, size, 1,1,1,1)
|
2023-04-17 18:49:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
if v.gw then
|
2023-04-17 19:30:21 +00:00
|
|
|
font:write(1000, 500, "Gateway: " .. v.gw, size, 1,1,1,1)
|
2023-04-17 18:49:53 +00:00
|
|
|
end
|
|
|
|
|
2023-03-14 08:55:54 +00:00
|
|
|
end
|