change text locations
This commit is contained in:
parent
c48c01f575
commit
8a96cf24f8
59
node.lua
59
node.lua
|
@ -20,7 +20,13 @@ gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
|
||||||
card = resource.load_image("testcard.png")
|
card = resource.load_image("testcard.png")
|
||||||
font = resource.load_font("vera.ttf")
|
font = resource.load_font("vera.ttf")
|
||||||
|
|
||||||
local v = {}
|
local v = {
|
||||||
|
network = "<unkown>",
|
||||||
|
online = "<unkown>",
|
||||||
|
ethip = "<unkown>",
|
||||||
|
wlanip = "<unkown>",
|
||||||
|
gw = "<unkown>"
|
||||||
|
}
|
||||||
|
|
||||||
util.data_mapper{
|
util.data_mapper{
|
||||||
["update/(.*)"] = function(key, val)
|
["update/(.*)"] = function(key, val)
|
||||||
|
@ -50,48 +56,37 @@ function node.render()
|
||||||
lower_width = font:width(lower_text, 20)
|
lower_width = font:width(lower_text, 20)
|
||||||
font:write(960-(lower_width/2), 679, lower_text, 20, 1,1,1,1)
|
font:write(960-(lower_width/2), 679, lower_text, 20, 1,1,1,1)
|
||||||
|
|
||||||
-- TODO
|
-- available space y: 450 to 700
|
||||||
local size, k_x, v_x, y
|
local fontsize = 40
|
||||||
|
local x_left = 90
|
||||||
size = math.floor(HEIGHT/20)
|
local x_right = 1400
|
||||||
y = 30+size*6
|
local y_start = 500
|
||||||
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
|
|
||||||
|
|
||||||
|
-- left side: network config, online status
|
||||||
if v.network then
|
if v.network then
|
||||||
key "Network config"
|
font:write(x_left, y_start, "Mode: " .. v.network, fontsize, 1,1,1,1)
|
||||||
val(v.network)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
font:write(x_left, y_start+50, "online", fontsize, 1,1,1,1)
|
||||||
|
-- if v.online then
|
||||||
|
-- local col = {1,0,0,1}
|
||||||
|
-- if v.online == "online" then
|
||||||
|
-- col = {0,1,0,1}
|
||||||
|
-- end
|
||||||
|
-- font:write(x_left, y_start+50, v.online, fontsize, col)
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- right side: IP address
|
||||||
if v.ethip then
|
if v.ethip then
|
||||||
key "Ethernet IPv4"
|
font:write(x_right, y_start, "Eth: " .. v.ethip, fontsize, 1,1,1,1)
|
||||||
val(v.ethip)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if v.wlanip then
|
if v.wlanip then
|
||||||
key "WiFi IPv4"
|
font:write(x_right, y_start+50, "WiFi: " .. v.wlanip, fontsize, 1,1,1,1)
|
||||||
val(v.wlanip)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if v.gw then
|
if v.gw then
|
||||||
key "Gateway"
|
font:write(x_right, y_start+100, "GW: " .. v.gw, fontsize, 1,1,1,1)
|
||||||
val(v.gw)
|
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in a new issue