Brightness control can be activated and deactivated

This commit is contained in:
ollo 2019-05-03 22:11:44 +02:00
parent 13343fa645
commit 69a2158ca6
4 changed files with 11 additions and 10 deletions

View File

@ -49,11 +49,6 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
return nil return nil
end end
-- Initial value of percentage
if (words.briPercent == nil) then
words.briPercent=50
end
local minutes=1 local minutes=1
if (words.min1 == 1) then if (words.min1 == 1) then
minutes = minutes + 1 minutes = minutes + 1
@ -64,7 +59,7 @@ local generateLEDs = function(words, colorForground, colorMin1, colorMin2, color
elseif (words.min4 == 1) then elseif (words.min4 == 1) then
minutes = minutes + 4 minutes = minutes + 4
end end
if (adc ~= nil) then if ( (adc ~= nil) and (words.briPercent ~= nil) ) then
local per = math.floor(100*adc.read(0)/1000) local per = math.floor(100*adc.read(0)/1000)
words.briPercent = tonumber( ((words.briPercent * 4) + per) / 5) words.briPercent = tonumber( ((words.briPercent * 4) + per) / 5)
print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(words.briPercent) .. "% current: " .. tostring(per) .. "%") print("Minutes : " .. tostring(minutes) .. " bright: " .. tostring(words.briPercent) .. "% current: " .. tostring(per) .. "%")

View File

@ -49,7 +49,11 @@ function displayTime()
end end
local time = getTime(sec, timezoneoffset) local time = getTime(sec, timezoneoffset)
local words = display_timestat(time.hour, time.minute) 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") dp = dofile("displayword.lc")
if (dp ~= nil) then if (dp ~= nil) then
ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4) ledBuf = dp.generateLEDs(words, color, color1, color2, color3, color4)

View File

@ -53,9 +53,9 @@ Please note that all settings are mandatory<br /><br />
<tr><th>2. Minute Color</th><td><input type="color" name="colorMin2" value="$HEXCOLOR2"></td><td>Second minute after</td></tr> <tr><th>2. Minute Color</th><td><input type="color" name="colorMin2" value="$HEXCOLOR2"></td><td>Second minute after</td></tr>
<tr><th>3. Minute Color</th><td><input type="color" name="colorMin3" value="$HEXCOLOR3"></td><td>Third minute after</td></tr> <tr><th>3. Minute Color</th><td><input type="color" name="colorMin3" value="$HEXCOLOR3"></td><td>Third minute after</td></tr>
<tr><th>4. Minute Color</th><td><input type="color" name="colorMin4" value="$HEXCOLOR4"></td><td>Fourth minute after</td></tr> <tr><th>4. Minute Color</th><td><input type="color" name="colorMin4" value="$HEXCOLOR4"></td><td>Fourth minute after</td></tr>
<tr><th>Three quater</th><td><input type="checkbox" name="threequater" $THREEQUATER></td><td>Dreiviertel Joa/nei</td></tr> <tr><th>Three quater</th><td><input type="checkbox" name="threequater" $THREEQUATER></td><td>Dreiviertel Joa/nei</td></tr>
<tr><th>Invert lines 4-6</th><td><input type="checkbox" name="inv46" $THREEQUATER></td><td>invert</td></tr> <tr><th>Invert lines 4-6</th><td><input type="checkbox" name="inv46" $THREEQUATER></td><td>invert</td></tr>
<tr><th>Adjust brightnes</th><td><input type="checkbox" name="dim" $AUTODIM></td><td>Adjust brightness of LEDs</td></tr>
<tr><td colspan="3"><div align="center"><input type="submit" value="Save Configuration" onclick="this.value='Submitting ..';this.disabled='disabled'; this.form.submit();"></div></td></tr> <tr><td colspan="3"><div align="center"><input type="submit" value="Save Configuration" onclick="this.value='Submitting ..';this.disabled='disabled'; this.form.submit();"></div></td></tr>
<tr><td colspan="3"><div align="center"><input type="submit" name="action" value="Reboot"></div></td></tr> <tr><td colspan="3"><div align="center"><input type="submit" name="action" value="Reboot"></div></td></tr>

View File

@ -120,6 +120,8 @@ function fillDynamicMap()
replaceMap["$HEXCOLOR3"]=hexColor3 replaceMap["$HEXCOLOR3"]=hexColor3
replaceMap["$HEXCOLOR4"]=hexColor4 replaceMap["$HEXCOLOR4"]=hexColor4
replaceMap["$HEXCOLORBG"]=hexColorBg 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 return replaceMap
end end
@ -200,7 +202,7 @@ function startWebServer()
sec, _ = rtctime.get() sec, _ = rtctime.get()
file.open(configFile.. ".new", "w+") 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("-- 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 if ( _POST.fcolor ~= nil) then
-- color=string.char(_POST.green, _POST.red, _POST.blue) -- color=string.char(_POST.green, _POST.red, _POST.blue)