From 24b943a6e7b7490d7cb5b9fb02b5561a8b74c697 Mon Sep 17 00:00:00 2001 From: Roman Bazalevsky Date: Wed, 22 Jan 2020 06:51:26 +0300 Subject: [PATCH] =?utf8?q?=D0=9D=D0=B0=20=D1=83=D0=B7=D0=BA=D0=B8=D1=85=20?= =?utf8?q?=D0=B4=D0=B8=D1=81=D0=BF=D0=BB=D0=B5=D1=8F=D1=85=20=D0=BD=D0=B5?= =?utf8?q?=20=D0=BE=D1=82=D0=BE=D0=B1=D1=80=D0=B0=D0=B6=D0=B0=D1=82=D1=8C?= =?utf8?q?=20=D0=BC=D0=B0=D0=BA=D1=81=D0=B8=D0=BC=D0=B0=D0=BB=D1=8C=D0=BD?= =?utf8?q?=D0=BE=D0=B5-=D0=BC=D0=B8=D0=BD=D0=B8=D0=BC=D0=B0=D0=BB=D1=8C?= =?utf8?q?=D0=BD=D0=BE=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D0=BD=D0=B0=20=D0=B3=D1=80=D0=B0=D1=84=D0=B8=D0=BA?= =?utf8?q?=D0=B0=D1=85,=20=D0=B2=D1=82=D0=B8=D1=81=D0=BA=D0=B8=D0=B2=D0=B0?= =?utf8?q?=D1=82=D1=8C=20=D0=B2=D1=81=D0=B5=20=D0=B2=20=D0=BE=D0=B4=D0=BD?= =?utf8?q?=D1=83=20=D1=81=D1=82=D1=80=D0=BE=D0=BA=D1=83.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- bin/weather-lcd | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/bin/weather-lcd b/bin/weather-lcd index 17436ef..9ecadfa 100755 --- a/bin/weather-lcd +++ b/bin/weather-lcd @@ -155,11 +155,13 @@ function setup_pages(conn) write_command(conn,"screen_add "..pageid) 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..".max string") - write_command(conn,"widget_add "..pageid.." "..pageid..".min string") - for k = 3,height-1 do - write_command(conn,"widget_add "..pageid.." "..pageid..".place"..trim(tostring(k)).." string") - end + if height>2 then + write_command(conn,"widget_add "..pageid.." "..pageid..".max string") + write_command(conn,"widget_add "..pageid.." "..pageid..".min string") + for k = 3,height-1 do + write_command(conn,"widget_add "..pageid.." "..pageid..".place"..trim(tostring(k)).." string") + end + end write_command(conn,"widget_set "..pageid.." "..pageid..".title \"".. pagetitle.."\"") end end @@ -196,6 +198,7 @@ function process_graphs() local vals = {} local maxval = -99999999 local minval = 99999999 + local len for k=width,1,-1 do if row then val = row["val"] * def["scale"] @@ -208,15 +211,19 @@ function process_graphs() if val and (val < minval) then minval = val; end end minval = math.floor(minval) - local minvalstr = trim(tostring(minval)) maxval = math.ceil(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) - 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-1).."\"") - end - write_command(conn,"widget_set "..pageid.." "..pageid..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr) + if height>2 then + local minvalstr = trim(tostring(minval)) + local maxvalstr = trim(tostring(maxval)) + 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..".min "..trim(tostring(width-string.len(minvalstr)+1)).." "..height.." "..minvalstr) + 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-1).."\"") + end + else + len = 0 + end local m = width for k=1,width do write_command(conn,"widget_del "..pageid.." "..pageid..".bar"..trim(tostring(k))) -- 2.34.1