WS2812 library changed with the last ROM update
This commit is contained in:
parent
6e8a35307e
commit
dc8c5b5361
7
init.lua
7
init.lua
@ -1,11 +1,12 @@
|
|||||||
print("Autostart in 10 seconds...")
|
print("Autostart in 10 seconds...")
|
||||||
|
|
||||||
ledPin=4
|
ws2812.init() -- WS2812 LEDs initialized on GPIO2
|
||||||
|
|
||||||
counter1=0
|
counter1=0
|
||||||
ws2812.write(ledPin, string.char(0,0,0):rep(114))
|
ws2812.write(string.char(0,0,0):rep(114))
|
||||||
tmr.alarm(2, 85, 1, function()
|
tmr.alarm(2, 85, 1, function()
|
||||||
counter1=counter1+1
|
counter1=counter1+1
|
||||||
ws2812.write(ledPin, string.char(128,0,0):rep(counter1))
|
ws2812.write(string.char(128,0,0):rep(counter1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
local blacklistfile="init.lua config.lua"
|
local blacklistfile="init.lua config.lua"
|
||||||
|
13
main.lua
13
main.lua
@ -1,5 +1,4 @@
|
|||||||
-- Main Module
|
-- Main Module
|
||||||
ledPin=4
|
|
||||||
|
|
||||||
function startSetupMode()
|
function startSetupMode()
|
||||||
tmr.stop(0)
|
tmr.stop(0)
|
||||||
@ -17,7 +16,7 @@ function startSetupMode()
|
|||||||
local color=string.char(0,128,0)
|
local color=string.char(0,128,0)
|
||||||
local white=string.char(0,0,0)
|
local white=string.char(0,0,0)
|
||||||
local ledBuf= white:rep(6) .. color .. white:rep(7) .. color:rep(3) .. white:rep(44) .. color:rep(3) .. white:rep(50)
|
local ledBuf= white:rep(6) .. color .. white:rep(7) .. color:rep(3) .. white:rep(44) .. color:rep(3) .. white:rep(50)
|
||||||
ws2812.write(ledPin, ledBuf)
|
ws2812.write(ledBuf)
|
||||||
color=nil
|
color=nil
|
||||||
white=nil
|
white=nil
|
||||||
ledBuf=nil
|
ledBuf=nil
|
||||||
@ -34,6 +33,7 @@ function syncTimeFromInternet()
|
|||||||
sntp.sync(sntpserverhostname,
|
sntp.sync(sntpserverhostname,
|
||||||
function(sec,usec,server)
|
function(sec,usec,server)
|
||||||
print('sync', sec, usec, server)
|
print('sync', sec, usec, server)
|
||||||
|
displayTime()
|
||||||
end,
|
end,
|
||||||
function()
|
function()
|
||||||
print('failed!')
|
print('failed!')
|
||||||
@ -49,7 +49,7 @@ function displayTime()
|
|||||||
words = display_timestat(time.hour, time.minute)
|
words = display_timestat(time.hour, time.minute)
|
||||||
ledBuf = generateLEDs(words, color)
|
ledBuf = generateLEDs(words, color)
|
||||||
-- Write the buffer to the LEDs
|
-- Write the buffer to the LEDs
|
||||||
ws2812.write(ledPin, ledBuf)
|
ws2812.write(ledBuf)
|
||||||
|
|
||||||
-- Used for debugging
|
-- Used for debugging
|
||||||
if (clockdebug ~= nil) then
|
if (clockdebug ~= nil) then
|
||||||
@ -80,9 +80,9 @@ function normalOperation()
|
|||||||
if wifi.sta.status() ~= 5 then
|
if wifi.sta.status() ~= 5 then
|
||||||
print(connect_counter .. "/60 Connecting to AP...")
|
print(connect_counter .. "/60 Connecting to AP...")
|
||||||
if (connect_counter % 2 == 0) then
|
if (connect_counter % 2 == 0) then
|
||||||
ws2812.write(ledPin, string.char((connect_counter % 6)*20,(connect_counter % 5)*20,(connect_counter % 3)*20):rep(114))
|
ws2812.write(string.char((connect_counter % 6)*20,(connect_counter % 5)*20,(connect_counter % 3)*20):rep(114))
|
||||||
else
|
else
|
||||||
ws2812.write(ledPin, string.char(0,0,0):rep(114))
|
ws2812.write(string.char(0,0,0):rep(114))
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
tmr.stop(0)
|
tmr.stop(0)
|
||||||
@ -120,7 +120,8 @@ function normalOperation()
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-------------------main program -----------------------------
|
||||||
|
ws2812.init() -- WS2812 LEDs initialized on GPIO2
|
||||||
|
|
||||||
if ( file.open("config.lua") ) then
|
if ( file.open("config.lua") ) then
|
||||||
--- Normal operation
|
--- Normal operation
|
||||||
|
Loading…
Reference in New Issue
Block a user