Индивидуальная настройка плотности виджетов на экранах.
[weathermon.git] / bin / weather-lcd
index 9ee87ba529f4a7007dab6997818cf61889698e3f..49fd5e37c7fdc3a454f2f0ed67bbd9eaa918b16e 100755 (executable)
@@ -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"]]