projects
/
weathermon.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
df46c1d
)
Динамическое определение свободного места под графики
author
Roman Bazalevsky
<rvb@rvb.name>
Tue, 21 Jan 2020 13:07:54 +0000
(16:07 +0300)
committer
Roman Bazalevsky
<rvb@rvb.name>
Tue, 21 Jan 2020 13:07:54 +0000
(16:07 +0300)
bin/weather-lcd
patch
|
blob
|
history
diff --git
a/bin/weather-lcd
b/bin/weather-lcd
index 49fd5e37c7fdc3a454f2f0ed67bbd9eaa918b16e..779bc496cb3e64f37d77849d07cea77b062932b2 100755
(executable)
--- a/
bin/weather-lcd
+++ b/
bin/weather-lcd
@@
-153,15
+153,17
@@
function setup_pages(conn)
pageid = def["sensor"].."."..def["param"]
pagetitle = trim(def["label"])..", "..def["unit"]
write_command(conn,"screen_add "..pageid)
pageid = def["sensor"].."."..def["param"]
pagetitle = trim(def["label"])..", "..def["unit"]
write_command(conn,"screen_add "..pageid)
- write_command(conn,"screen_set "..pageid.." -cursor off")
- write_command(conn,"screen_set "..pageid.." -name "..pagetitle.." -duration "..graph_duration)
+ write_command(conn,"screen_set "..pageid.." -cursor off -name "..pagetitle.." -duration "..graph_duration)
write_command(conn,"widget_add "..pageid.." "..pageid..".title title")
write_command(conn,"widget_add "..pageid.." "..pageid..".title title")
- write_command(conn,"widget_set "..pageid.." "..pageid..".title \"".. pagetitle.."\"")
write_command(conn,"widget_add "..pageid.." "..pageid..".max string")
write_command(conn,"widget_add "..pageid.." "..pageid..".min string")
write_command(conn,"widget_add "..pageid.." "..pageid..".max string")
write_command(conn,"widget_add "..pageid.." "..pageid..".min string")
- for k=1,width-def["pos"] do
+ for k = 3,height-1 do
+ write_command(conn,"widget_add "..pageid.." "..pageid..".place"..trim(tostring(k)).." string")
+ end
+ for k=1,width do
write_command(conn,"widget_add "..pageid.." "..pageid..".bar"..trim(tostring(k)).." vbar")
end
write_command(conn,"widget_add "..pageid.." "..pageid..".bar"..trim(tostring(k)).." vbar")
end
+ write_command(conn,"widget_set "..pageid.." "..pageid..".title \"".. pagetitle.."\"")
end
end
end
end
end
end
@@
-197,7
+199,7
@@
function process_graphs()
local vals = {}
local maxval = -99999999
local minval = 99999999
local vals = {}
local maxval = -99999999
local minval = 99999999
- for k=width
-def["pos"]
,1,-1 do
+ for k=width,1,-1 do
if row then
val = row["val"]
row = cur:fetch ({}, "a")
if row then
val = row["val"]
row = cur:fetch ({}, "a")
@@
-209,19
+211,28
@@
function process_graphs()
if val and (val < minval) then minval = val; end
end
minval = math.floor(minval)
if val and (val < minval) then minval = val; end
end
minval = math.floor(minval)
- minvalstr = trim(tostring(minval))
+
local
minvalstr = trim(tostring(minval))
maxval = math.ceil(maxval)
maxval = math.ceil(maxval)
- maxvalstr = trim(tostring(maxval))
+ local maxvalstr = trim(tostring(maxval))
+ local len = math.max(string.len(minvalstr),string.len(maxvalstr))
write_command(conn,"widget_set "..pageid.." "..pageid..".max "..trim(tostring(width-string.len(maxvalstr)+1)).." 2 "..maxvalstr)
write_command(conn,"widget_set "..pageid.." "..pageid..".max "..trim(tostring(width-string.len(maxvalstr)+1)).." 2 "..maxvalstr)
+ for k = 3,height-1 do
+ write_command(conn,"widget_set "..pageid.." "..pageid..".place"..trim(tostring(k)).." "..trim(tostring(width-len+1)).." "..k.." \""..string.rep("-",len).."\"")
+ end
write_command(conn,"widget_set "..pageid.." "..pageid..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr)
write_command(conn,"widget_set "..pageid.." "..pageid..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr)
- for k = 1,width-def["pos"] do
- val = vals[k]
+ local m = width
+ for k = width-len,1,-1 do
+ val = vals[m]
if val then
h = math.floor(0.5+(val-minval)/(maxval-minval)*(height-1)*charheight)
else
h = 0
end
write_command(conn,"widget_set "..pageid.." "..pageid..".bar"..trim(tostring(k)).." "..k.." "..height.." "..h)
if val then
h = math.floor(0.5+(val-minval)/(maxval-minval)*(height-1)*charheight)
else
h = 0
end
write_command(conn,"widget_set "..pageid.." "..pageid..".bar"..trim(tostring(k)).." "..k.." "..height.." "..h)
+ m = m - 1
+ end
+ for k= m,1,-1 do
+ write_command(conn,"widget_set "..pageid.." "..pageid..".bar"..trim(tostring(k)).." 0 0 0")
end
end
end
end
end
end