Created
March 22, 2017 19:37
-
-
Save frasten/d34e7fd94971acb831b7198e1ec62beb to your computer and use it in GitHub Desktop.
NodeMCU Init script to avoid semi-brick on infinite loops
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local IDLE_AT_STARTUP_MS = 5000; | |
local DELTA = 1000 | |
local current = 0 | |
local function printRimanente() | |
local rimanente = (IDLE_AT_STARTUP_MS - current) | |
print("Caricamento. Hai ancora " .. rimanente .. "ms per annullare modificando program.lua...") | |
end | |
printRimanente() | |
local mainTimer = tmr.create() | |
mainTimer:register(DELTA, tmr.ALARM_AUTO, function(t) | |
if current >= (IDLE_AT_STARTUP_MS - DELTA) then | |
t:unregister() | |
print("==> Avvio del programma.") | |
dofile("program.lua")--Write your program name in dofile | |
else | |
current = current + DELTA | |
printRimanente() | |
end | |
end) | |
mainTimer:start() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment