2017-01-03 14:07:23 +01:00
|
|
|
uart.setup(0, 115200, 8, 0, 1, 1 )
|
2016-12-14 18:37:56 +01:00
|
|
|
print("Autostart in 5 seconds...")
|
2016-06-19 17:04:30 +02:00
|
|
|
|
2016-07-03 18:41:32 +02:00
|
|
|
ws2812.init() -- WS2812 LEDs initialized on GPIO2
|
|
|
|
|
2016-06-19 17:04:30 +02:00
|
|
|
counter1=0
|
2016-07-03 18:41:32 +02:00
|
|
|
ws2812.write(string.char(0,0,0):rep(114))
|
2016-06-19 17:04:30 +02:00
|
|
|
tmr.alarm(2, 85, 1, function()
|
|
|
|
counter1=counter1+1
|
2016-07-03 18:41:32 +02:00
|
|
|
ws2812.write(string.char(128,0,0):rep(counter1))
|
2016-06-19 17:04:30 +02:00
|
|
|
end)
|
|
|
|
|
|
|
|
local blacklistfile="init.lua config.lua"
|
|
|
|
function recompileAll()
|
|
|
|
-- compile all files
|
|
|
|
l = file.list();
|
|
|
|
for k,_ in pairs(l) do
|
|
|
|
if (string.find(k, ".lc", -3)) then
|
|
|
|
print ("Skipping " .. k)
|
|
|
|
elseif (string.find(blacklistfile, k) == nil) then
|
2016-12-30 13:39:22 +01:00
|
|
|
-- Only look at lua files
|
|
|
|
if (string.find(k, ".lua") ~= nil) then
|
|
|
|
print("Compiling and deleting " .. k)
|
|
|
|
node.compile(k)
|
|
|
|
-- remove the lua file
|
|
|
|
file.remove(k)
|
|
|
|
else
|
|
|
|
print("No code: " .. k)
|
|
|
|
end
|
2016-06-19 17:04:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function mydofile(mod)
|
|
|
|
if (file.open(mod .. ".lua")) then
|
|
|
|
dofile( mod .. ".lua")
|
|
|
|
else
|
|
|
|
dofile(mod .. ".lc")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2016-12-14 18:37:56 +01:00
|
|
|
tmr.alarm(1, 5000, 0, function()
|
2016-06-19 17:04:30 +02:00
|
|
|
tmr.stop(2)
|
|
|
|
if (file.open("main.lua")) then
|
|
|
|
recompileAll()
|
|
|
|
print("Rebooting ...")
|
|
|
|
-- reboot repairs everything
|
|
|
|
node.restart()
|
|
|
|
elseif (file.open("main.lc")) then
|
|
|
|
print("Starting main")
|
|
|
|
dofile("main.lc")
|
|
|
|
else
|
|
|
|
print("No Main file found")
|
|
|
|
end
|
|
|
|
end)
|