From: Nathaniel Wesley Filardo Date: Sat, 15 Oct 2016 04:05:21 +0000 (-0400) Subject: examples/lamp : "animated" "snake" graphic X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=5055e49ae9f4d56e8a64b1fb173cdad9ddb42050;p=acmetensortoys-esp-lua_lamp examples/lamp : "animated" "snake" graphic --- diff --git a/lamp-draw.lua b/lamp-draw.lua index 9926444..99e5caf 100644 --- a/lamp-draw.lua +++ b/lamp-draw.lua @@ -27,5 +27,20 @@ return { fb:fade(2); fb:set(ix,c); dodraw() ix = ix + 1; if ix > fb:size() then ix = 1 end end) + end, + ["snake"] = function(t,fb,g,r,b) + local ix = 0 + local c = string.char(g,r,b) + fb:fill(0,0,0) + fb:set(25,c) fb:set(26,c) fb:set(19,c) fb:set(28,c) fb:set(29,c) fb:set(30,c) + fb:set(23,c) fb:set(15,c) fb:set(7,c) fb:set(8,c) + t:register(1000,tmr.ALARM_AUTO,function() + if ix == 1 + then fb:set(19,c) fb:set(27,0,0,0) fb:set(20,0,0,0) fb:set(28,c) + else fb:set(19,0,0,0) fb:set(27,c) fb:set(20,c) fb:set(28,0,0,0) + end + ix = 1 - ix + dodraw() + end) end }