ide.lua
должно хватить для этого без посторонних инструментов. ide.lua
, а вот запускать 20 раз вывод содержимого объектов так неудобно. По telnet — самое то
function wheel(pos)
pos = MAX_COLOR - pos;
if pos < 85 then
return string.char(MAX_COLOR - pos * 3, 0, pos * 3);
end
if pos < 170 then
pos = pos - 85;
return string.char(0, pos * 3, MAX_COLOR - pos * 3);
end
pos = pos - 170;
return string.char(pos * 3, MAX_COLOR - pos * 3, 0);
end
function rainbow()
tmr.alarm(3, 20, 1, function()
buffer:shift(1)
buffer:set(1, wheel((iter*4) % MAX_COLOR))
ws2812.write(buffer)
iter = iter + 1
end)
end
local count = 0
local pin = 4 -- D1-mini LED
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin, gpio.LOW)
if file.open("fail-counter.txt") then
count = tonumber(file.read())
if count == nil then
count = 0
end
file.close()
end
if count >= 2 then
print("Emergency stop")
file.remove("fail-counter.txt")
return
end
print("Fail proof check: ", count)
file.remove("fail-counter.txt")
file.open("fail-counter.txt","w+")
file.writeline(count+1)
file.close();
if not tmr.create():alarm(3000, tmr.ALARM_SINGLE, function()
file.remove("fail-counter.txt")
print("Fail proof check passed")
end)
then
print("Can't start timer")
return
end
gpio.write(pin, gpio.HIGH)
dofile('main.lua')
init.lua
грузит main.lua
, в котором уже и хранится основной инициализирующий код. ide.lua
и тогда можно будет контроллер и к компу не цеплять — трижды reset и грузится удалённый редактор.Здравствуйте, гость!
Гостевой функционал сайта ограничен. Для полноценной работы зарегистрируйтесь, пожалуйста.