Skip to content

Instantly share code, notes, and snippets.

@frasten
Created March 22, 2017 19:37
Show Gist options
  • Save frasten/d34e7fd94971acb831b7198e1ec62beb to your computer and use it in GitHub Desktop.
Save frasten/d34e7fd94971acb831b7198e1ec62beb to your computer and use it in GitHub Desktop.
NodeMCU Init script to avoid semi-brick on infinite loops
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