From e9c28e8547b8380415ad9883cabb7c75614067b6 Mon Sep 17 00:00:00 2001 From: Florian Zahn Date: Sun, 23 Dec 2018 23:51:56 +0100 Subject: [PATCH] Inverted mode for special hardware --- main.lua | 20 +++++++++++++++++--- webpage.html | 2 ++ webserver.lua | 2 +- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/main.lua b/main.lua index 965268d..99f5c27 100644 --- a/main.lua +++ b/main.lua @@ -51,13 +51,27 @@ function displayTime() words = display_timestat(time.hour, time.minute) local charactersOfTime = display_countwords_de(words) - ledBuf = generateLEDs(words, color, color1, color2, color3, color4, + local ledBuf = generateLEDs(words, color, color1, color2, color3, color4, charactersOfTime) print("Local time : " .. time.year .. "-" .. time.month .. "-" .. time.day .. " " .. time.hour .. ":" .. time.minute .. ":" .. time.second .. " in " .. charactersOfTime .. " chars") - -- Write the buffer to the LEDs - ws2812.write(ledBuf) + --if lines 4 to 6 are inverted due to hardware-fuckup, unfuck it here + if ((inv46 ~= nil) and (inv46 == "on")) then + tempstring = ledBuf:sub(1,101) -- first 33 leds + rowend = {44,55,66} + for _, startled in ipairs(rowend) do + for i = 0,10 do + tempstring = tempstring .. ledBuf:sub((startled-i)*3,(startled-i)*3+2) + end + end + tempstring = tempstring .. ledBuf:sub((67*3),ledBuf:len()) + ws2812.write(tempstring) + else + ws2812.write(ledBuf) + end + + -- Used for debugging if (clockdebug ~= nil) then diff --git a/webpage.html b/webpage.html index 7e1dbdd..fad40f7 100644 --- a/webpage.html +++ b/webpage.html @@ -55,6 +55,8 @@ Please note that all settings are mandatory

4. Minute ColorFourth minute after Three quaterDreiviertel Joa/nei +Invert lines 4-6invert +
diff --git a/webserver.lua b/webserver.lua index f9452aa..8568412 100644 --- a/webserver.lua +++ b/webserver.lua @@ -166,7 +166,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") + file.write("sntpserverhostname=\"" .. _POST.sntpserver .. "\"\n" .. "timezoneoffset=\"" .. _POST.timezoneoffset .. "\"\n".. "inv46=\"" .. tostring(_POST.inv46) .. "\"\n") if ( _POST.fcolor ~= nil) then -- color=string.char(_POST.green, _POST.red, _POST.blue)