]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
examples/lamp : "animated" "snake" graphic
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 15 Oct 2016 04:05:21 +0000 (00:05 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sat, 15 Oct 2016 04:05:21 +0000 (00:05 -0400)
lamp-draw.lua

index 9926444abc6383b537f48c63402aa6811d2f9aef..99e5caf921e0ae83fc802b0227c3064a6ea8f9cd 100644 (file)
@@ -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
 }