From: Rachael Date: Mon, 19 Feb 2018 23:57:24 +0000 (-0800) Subject: makes nom able to change color without starting the animation over X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=16e22c5b9cf25b62f596bd52742718b99908c9de;p=acmetensortoys-esp-lua_lamp makes nom able to change color without starting the animation over --- diff --git a/draw-nom.lua b/draw-nom.lua index 17bc5e8..51abcf6 100644 --- a/draw-nom.lua +++ b/draw-nom.lua @@ -1,7 +1,13 @@ -- return function(t,fb,p) local ix = 2 -- since we start effectively in state 1... - local c = p[1] + local c + + local function reinit() + c = p[1] + end + reinit() + local z = string.char(0,0,0) local ft = { -- open mouth [1] = function() fb:set(16,z) fb:set(24,z) fb:set(9,c) fb:set(17,c) fb:set(2,c) fb:set(26,c) end @@ -36,4 +42,5 @@ return function(t,fb,p) ix = (ix == 16 and 1) or ix + 1 dodraw() end) + return {['cccb'] = function() reinit(); local ixp for ixp=1,ix do ft[ixp]() end; dodraw() end } end