-
Notifications
You must be signed in to change notification settings - Fork 1
/
init_led.lua
39 lines (33 loc) · 855 Bytes
/
init_led.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
require('led')
led.show()
local offset = 0
local function cycle_off (t)
return tmr.alarm(4,t,tmr.ALARM_SINGLE, function ()
led.show_off(offset)
offset = (offset+1)%led.nled
return cycle_off(t)
end)
end
local function cycle (t)
return tmr.alarm(4,t,tmr.ALARM_SINGLE, function ()
led.setRainbow(offset)
led.show()
offset = (offset+1)%led.nled
return cycle(t)
end)
end
function rbow_start_off(t)
if t == nil then t = 10 end
led.setRainbow()
return cycle_off(t)
end
function rbow_start(t)
if t == nil then t = 10 end
return cycle(t)
end
function rbow_stop()
tmr.stop(4)
led.off()
offset = 0
return tmr.alarm(4,1000,tmr.ALARM_SINGLE, collectgarbage)
end