From e5d7ec016be5a5f7f3925f67a4300d4eb2f215d0 Mon Sep 17 00:00:00 2001 From: ollo Date: Fri, 19 Apr 2019 22:05:00 +0200 Subject: [PATCH] Button included --- main.lua | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.lua b/main.lua index 060e438..a3241ff 100644 --- a/main.lua +++ b/main.lua @@ -160,3 +160,20 @@ else -- Logic for inital setup startSetupMode() 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)