change text locations

This commit is contained in:
Jannik Beyerstedt 2023-04-17 21:30:21 +02:00
parent c48c01f575
commit 10c9c20b77
2 changed files with 35 additions and 35 deletions

View file

@ -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,42 @@ 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 -- draw text on left and right dark grey area
local size, k_x, v_x, y local fontsize = 30
local offset = fontsize+10
size = math.floor(HEIGHT/20) local x_left = 90
y = 30+size*6 local x_right = 1400
k_x, v_x = 30, 30+font:width("XXXXXXXXXXXXXXXX", size) local y_start = 500
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
local y = y_start
if v.network then if v.network then
key "Network config" font:write(x_left, y, "Mode: " .. v.network, fontsize, 1,1,1,1)
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 end
y = y + offset
if v.gw then if v.gw then
key "Gateway" font:write(x_left, y, "GW: " .. v.gw, fontsize, 1,1,1,1)
val(v.gw)
end end
y = y + offset
if v.online then if v.online then
key "Online status"
local col = {1,0,0,1} local col = {1,0,0,1}
if v.online == "online" then if v.online == "online" then
col = {0,1,0,1} col = {0,1,0,1}
end end
val(v.online, col) font:write(x_left, y, v.online, fontsize, unpack(col))
end end
-- right side: IP address
y = y_start
if v.ethip then
font:write(x_right, y, "Eth: " .. v.ethip, fontsize, 1,1,1,1)
end
y = y + offset
if v.wlanip then
font:write(x_right, y, "WiFi: " .. v.wlanip, fontsize, 1,1,1,1)
end
end end

View file

@ -111,8 +111,8 @@ if __name__ == "__main__":
try: try:
fetch_info() fetch_info()
if not run_next_test(): if not run_next_test():
time.sleep(0.2) time.sleep(5)
except: except:
traceback.print_exc() traceback.print_exc()
finally: # finally:
time.sleep(15) # time.sleep(1)