Fixed WS2812 buffer manipulation
This commit is contained in:
parent
fc5bd38ac1
commit
34e7f173fc
16
main.lua
16
main.lua
@ -69,8 +69,8 @@ function displayTime()
|
|||||||
else
|
else
|
||||||
-- set FG to fix value: RED
|
-- set FG to fix value: RED
|
||||||
local color = string.char(255,0,0)
|
local color = string.char(255,0,0)
|
||||||
rgbBuffer.fill(0,0,0) -- disable all LEDs
|
rgbBuffer:fill(0,0,0) -- disable all LEDs
|
||||||
for i=108,110, 1 do rgbBuffer.set(i, color) end
|
for i=108,110, 1 do rgbBuffer:set(i, color) end
|
||||||
ws2812.write(rgbBuffer)
|
ws2812.write(rgbBuffer)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -137,20 +137,20 @@ function normalOperation()
|
|||||||
connect_counter=connect_counter+1
|
connect_counter=connect_counter+1
|
||||||
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...")
|
||||||
rgbBuffer.fill(0,0,0) -- clear all LEDs
|
rgbBuffer:fill(0,0,0) -- clear all LEDs
|
||||||
if (connect_counter % 5 ~= 4) then
|
if (connect_counter % 5 ~= 4) then
|
||||||
local wlanColor=string.char((connect_counter % 6)*20,(connect_counter % 5)*20,(connect_counter % 3)*20)
|
local wlanColor=string.char((connect_counter % 6)*20,(connect_counter % 5)*20,(connect_counter % 3)*20)
|
||||||
if ((connect_counter % 5) >= 1) then
|
if ((connect_counter % 5) >= 1) then
|
||||||
rgbBuffer.set(7, wlanColor)
|
rgbBuffer:set(7, wlanColor)
|
||||||
end
|
end
|
||||||
if ((connect_counter % 5) >= 3) then
|
if ((connect_counter % 5) >= 3) then
|
||||||
rgbBuffer.set(15, wlanColor)
|
rgbBuffer:set(15, wlanColor)
|
||||||
end
|
end
|
||||||
if ((connect_counter % 5) >= 2) then
|
if ((connect_counter % 5) >= 2) then
|
||||||
rgbBuffer.set(16, wlanColor)
|
rgbBuffer:set(16, wlanColor)
|
||||||
end
|
end
|
||||||
if ((connect_counter % 5) >= 0) then
|
if ((connect_counter % 5) >= 0) then
|
||||||
rgbBuffer.set(17, wlanColor)
|
rgbBuffer:set(17, wlanColor)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
ws2812.write(rgbBuffer)
|
ws2812.write(rgbBuffer)
|
||||||
@ -180,7 +180,7 @@ btntimer:register(5000, tmr.ALARM_AUTO, function (t)
|
|||||||
mlt:unregister()
|
mlt:unregister()
|
||||||
print("Button pressed " .. tostring(btnCounter))
|
print("Button pressed " .. tostring(btnCounter))
|
||||||
btnCounter = btnCounter + 5
|
btnCounter = btnCounter + 5
|
||||||
for i=1,btnCounter do rgbBuffer.set(i, 128, 0, 0) end
|
for i=1,btnCounter do rgbBuffer:set(i, 128, 0, 0) end
|
||||||
ws2812.write(rgbBuffer)
|
ws2812.write(rgbBuffer)
|
||||||
if (btnCounter >= 110) then
|
if (btnCounter >= 110) then
|
||||||
file.remove("config.lua")
|
file.remove("config.lua")
|
||||||
|
Loading…
Reference in New Issue
Block a user