X-Git-Url: https://git.rvb.name/weathermon.git/blobdiff_plain/731aeb86fa110c689081532d0d6058a4581728dd..df46c1d6c7aa6058b5507fff9636f1f0684dd05b:/bin/weather-lcd?ds=inline diff --git a/bin/weather-lcd b/bin/weather-lcd index 9ee87ba..49fd5e3 100755 --- a/bin/weather-lcd +++ b/bin/weather-lcd @@ -47,22 +47,29 @@ function process_file() end function get_display_config() + width = tonumber(uci.get(config_name,"display","width")) height = tonumber(uci.get(config_name,"display","height")) charwidth = tonumber(uci.get(config_name,"display","charwidth")) charheight = tonumber(uci.get(config_name,"display","charheight")) - cols = tonumber(uci.get(config_name,"display","columns")) title = uci.get(config_name,"display","title") - col_width = math.floor(width/cols) pages = {} pagetitles = {} pagedurations = {} + pagecolumns = {} + pagecolwidth = {} local page, def, line, col, pos cur.foreach(config_name,"display", function(s) page = {} + local columns = s["columns"] + if not columns or columns == "" then + columns = 1 + else + columns = tonumber(columns) + end local pagetitle = s["title"] if not pagetitle then pagetitle = title @@ -91,7 +98,7 @@ function get_display_config() page[#page+1] = def end col = col + 1 - if col > cols then + if col > columns then col = 1 line = line + 1 end @@ -99,6 +106,8 @@ function get_display_config() pages[#pages+1] = page pagetitles[#pages] = pagetitle pagedurations[#pages] = pageduration + pagecolumns[#pages] = columns + pagecolwidth[#pages] = math.floor(width/columns) end) end @@ -160,6 +169,7 @@ end function process_vals(vals) for i,page in pairs(pages) do + col_width = pagecolwidth[i] local pageid = "page"..trim(tostring(i)) for j,def in pairs(page) do val = vals[def["sensor"]][def["param"]]