node.alias "testcard" util.init_hosted() local json = require "json" local serial = sys.get_env "SERIAL" local location = "" local description = "" 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") local v = {} util.data_mapper{ ["update/(.*)"] = function(key, val) v[key] = val end } function node.render() gl.clear(0,0,0,1) card:draw(0, 0, 1920, 1080) -- upper: 623 -- lower: 707 upper_text = "CCC: " .. description if location == nil or location == '' then lower_text = "Serial " .. serial else lower_text = location .. " - Serial " .. serial end upper_width = font:width(upper_text, 40) font:write(960-(upper_width/2), 631, upper_text, 40, 1,1,1,1) lower_width = font:width(lower_text, 20) font:write(960-(lower_width/2), 679, lower_text, 20, 1,1,1,1) -- TODO local size, k_x, v_x, y size = math.floor(HEIGHT/20) y = 30+size*6 k_x, v_x = 30, 30+font:width("XXXXXXXXXXXXXXXX", size) local function key(str) font:write(k_x, y, str, size, 1,1,1,.5) end local function val(str, col) col = col or {1,1,1,.5} font:write(v_x, y, str, size, unpack(col)) y = y + size*1.1 end if v.network then key "Network config" val(v.network) end if v.ethip then key "Ethernet IPv4" val(v.ethip) end if v.wlanip then key "WiFi IPv4" val(v.wlanip) end if v.gw then key "Gateway" val(v.gw) end if v.online then key "Online status" local col = {1,0,0,1} if v.online == "online" then col = {0,1,0,1} end val(v.online, col) end end