From 8eef94289c974d50cb4e12fc02360f5f93e15279 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 16 Oct 2016 16:33:47 -0400 Subject: [PATCH] examples/lamp: add draw: animated heartbeat --- draw-heartbeat.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 draw-heartbeat.lua diff --git a/draw-heartbeat.lua b/draw-heartbeat.lua new file mode 100644 index 0000000..218baaf --- /dev/null +++ b/draw-heartbeat.lua @@ -0,0 +1,22 @@ +return function(t,fb,g,r,b) + local c = string.char(g,r,b) + local ft = { [1] = function() fb:set(11,c) fb:set(13,c) end, -- side chambers + [2] = function() fb:set(11,0,0,0) fb:set(20,c) fb:set(13,0,0,0) end, -- bottom chamber + [3] = function() fb:set(20,0,0,0) end, -- empty + [4] = function() end -- stay empty + } + + fb:fill(0,0,0) + + 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) + + local ix = 1 + t:register(250,tmr.ALARM_AUTO,function() + ft[ix]() + ix = (ix == 4 and 1) or ix + 1 + dodraw() + end) +end -- 2.50.1