-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw-heartbeat.lua
40 lines (34 loc) · 1005 Bytes
/
draw-heartbeat.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
40
return function(t,fb,p)
local c, c2
local function drawHeart()
fb:set( 3,c)
fb:set( 5,c)
fb:set(10,c)
fb:set(12,c)
fb:set(14,c)
fb:set(19,c)
fb:set(21,c)
fb:set(28,c)
end
local function reinit()
c = p[1]
c2 = p[2] or c
drawHeart()
end
reinit()
local z = string.char(0,0,0)
local ft = { [1] = function() fb:set(11,c2) fb:set(13,c2) end, -- side chambers
[2] = function() fb:set(11,z) fb:set(20,c2) fb:set(13,z) end, -- bottom chamber
[3] = function() fb:set(20,z) end, -- empty
[4] = function() end -- stay empty
}
fb:fill(0,0,0)
drawHeart()
local ix = 4
t:register(250,tmr.ALARM_AUTO,function()
ix = (ix == 4 and 1) or ix + 1
ft[ix]()
dodraw()
end)
return { ['ncolors'] = 2, ['cccb'] = function() reinit(); local ixp for ixp = 1,ix do ft[ixp]() end; dodraw() end }
end