Button included

This commit is contained in:
ollo 2019-04-19 22:05:00 +02:00
parent da743d8b0a
commit e5d7ec016b

View File

@ -160,3 +160,20 @@ else
-- Logic for inital setup -- Logic for inital setup
startSetupMode() startSetupMode()
end end
----------- button ---------
gpio.mode(3, gpio.INPUT)
btnCounter=0
-- Start the time Thread
tmr.alarm(4, 500, 1 ,function()
if (gpio.read(3) == 0) then
tmr.stop(1) -- stop the LED thread
print("Button pressed " .. tostring(btnCounter))
btnCounter = btnCounter + 5
local ledBuf= string.char(128,0,0):rep(btnCounter) .. string.char(0,0,0):rep(110 - btnCounter)
ws2812.write(ledBuf)
if (btnCounter >= 110) then
file.remove("config.lua")
node.restart()
end
end
end)