diff --git a/displayword.lua b/displayword.lua index ed67ac4..da094f2 100644 --- a/displayword.lua +++ b/displayword.lua @@ -49,11 +49,6 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color return nil end - -- Initial value of percentage - if (words.briPercent == nil) then - words.briPercent=50 - end - local minutes=1 if (words.min1 == 1) then minutes = minutes + 1 @@ -64,7 +59,7 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color elseif (words.min4 == 1) then minutes = minutes + 4 end - if (adc ~= nil) then + if ( (adc ~= nil) and (words.briPercent ~= nil) ) then local per = math.floor(100*adc.read(0)/1000) words.briPercent = tonumber( ((words.briPercent * 4) + per) / 5) print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(words.briPercent) .. "% current: " .. tostring(per) .. "%") diff --git a/main.lua b/main.lua index 241c4a7..3e75444 100644 --- a/main.lua +++ b/main.lua @@ -49,7 +49,11 @@ function displayTime() end local time = getTime(sec, timezoneoffset) local words = display_timestat(time.hour, time.minute) - words.briPercent=briPercent + if ((dim ~= nil) and (dim == "on")) then + words.briPercent=briPercent + else + words.briPercent=nil + end dp = dofile("displayword.lc") if (dp ~= nil) then ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4) diff --git a/webpage.html b/webpage.html index 2ba586a..25d1c80 100644 --- a/webpage.html +++ b/webpage.html @@ -45,7 +45,7 @@ Please note that all settings are mandatory

- + @@ -53,9 +53,9 @@ Please note that all settings are mandatory

- + diff --git a/webserver.lua b/webserver.lua index 7162400..5a7d178 100644 --- a/webserver.lua +++ b/webserver.lua @@ -120,6 +120,8 @@ function fillDynamicMap() replaceMap["$HEXCOLOR3"]=hexColor3 replaceMap["$HEXCOLOR4"]=hexColor4 replaceMap["$HEXCOLORBG"]=hexColorBg + replaceMap["$INV46"]=((inv46 ~= nil and inv46 == "on") and "checked" or "") + replaceMap["$AUTODIM"]=((dim ~= nil and dim == "on") and "checked" or "") return replaceMap end @@ -200,7 +202,7 @@ function startWebServer() sec, _ = rtctime.get() file.open(configFile.. ".new", "w+") file.write("-- Config\n" .. "station_cfg={}\nstation_cfg.ssid=\"" .. _POST.ssid .. "\"\nstation_cfg.pwd=\"" .. _POST.password .. "\"\nstation_cfg.save=false\nwifi.sta.config(station_cfg)\n") - file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=\"" .. tostring(_POST.inv46) .. "\"\n") + file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=\"" .. tostring(_POST.inv46) .. "\"\n" .. "dim=\"" .. tostring(_POST.dim) .. "\"\n") if ( _POST.fcolor ~= nil) then -- color=string.char(_POST.green, _POST.red, _POST.blue)
WIFI-SSIDSSID of the wireless network
WIFI-PasswordPassword of the wireless network
SNTP ServerServer to sync the time with. Only one ntp server is allowed.
SNTP ServerServer to sync the time with. Only one ntp server is allowed.
Offset to UTC timeDefine the offset to UTC time in hours. For example +1 hour for Germany
Foreground ColorLED Color for all minutes, divisible by five
Background ColorBackground LED Color
2. Minute ColorSecond minute after
3. Minute ColorThird minute after
4. Minute ColorFourth minute after
Three quaterDreiviertel Joa/nei
Invert lines 4-6invert
Adjust brightnesAdjust brightness of LEDs