From: Roman Bazalevsky Date: Tue, 21 Jan 2020 11:15:37 +0000 (+0300) Subject: Индивидуальная настройка плотности виджетов на экранах. X-Git-Url: https://git.rvb.name/weathermon.git/commitdiff_plain/df46c1d6c7aa6058b5507fff9636f1f0684dd05b?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"]] diff --git a/config/weathermon.uci b/config/weathermon.uci index c8c2e11..732d502 100644 --- a/config/weathermon.uci +++ b/config/weathermon.uci @@ -162,21 +162,33 @@ config internal 'display' option port 13666 option width 20 option height 4 - option columns 1 option charwidth 5 option charheight 8 option title "WeatherMonitor" option graph_duration 20 +config display + option title "WeatherMonitor" + option duration 40 + option columns 2 + list parameter "BME280:TEMPERATURE::C:1:1:5" + list parameter "BME280:HUMIDITY::%:1:1:5" + list parameter "BME280:PRESSURE::mm:0.75:0:4" + list parameter "" + list parameter "MHZ19:CO2PPM:CO2:ppm:1:0:4" + list parameter "CCS811:VOCPPB:Gas:ppb:1:0:5" + config display option title "Weather (BME280)" - option duration 40 + option duration 20 + option columns 1 list parameter "BME280:TEMPERATURE:Temperature:C:1:1:5" list parameter "BME280:HUMIDITY:Humidity :%:1:1:5" list parameter "BME280:PRESSURE:Pressure :mm:0.75:0:4" config display option title "Athmosphere" - option duration 40 + option columns 1 + option duration 20 list parameter "MHZ19:CO2PPM:CO2 :ppm:1:0:5" list parameter "CCS811:VOCPPB:Gas :ppb:1:0:5"