forked from info-beamer/package-screen-info
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.lua
50 lines (39 loc) · 1.31 KB
/
node.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
local font = resource.load_font "Ubuntu-C.ttf"
local json = require "json"
local serial = sys.get_env "SERIAL"
local location = "Yhdistetään…"
local description = "…"
local res = util.resource_loader{
"device_details.png";
}
local logo = resource.create_colored_texture(0,0,0,0)
local white = resource.create_colored_texture(1,1,1,1)
util.file_watch("config.json", function(raw)
local config = json.decode(raw)
logo = resource.load_image(config.logo.asset_name)
end)
util.data_mapper{
["device_info"] = function(info)
info = json.decode(info)
location = info.location
description = info.description
end
}
local function draw_info()
local s = HEIGHT/10
font:write(s, s*0.5, "Bom Screen Player", s, 1,1,1,1)
white:draw(0, s*1.6-2, WIDTH, s*1.6+2, 0.2)
local width_of_player_number = font:width(description, s)
font:write(WIDTH-width_of_player_number-s, s*0.5, description, s, 1,1,.5,1)
font:write(s, s*1.75, "S/N "..serial, s, 1,1,1,1)
font:write(s, s*3.75, location, s, 1,1,1,1)
if res.device_details then
res.device_details:draw(s, s*5, s*5.5, s*9.5)
end
util.draw_correct(logo, WIDTH-s*5.5, s*5, WIDTH-s, s*9.5)
end
function node.render()
gl.clear(0,0,0,1)
draw_info()
end