From bc4bc7e5354d841fb893f9ca54a3dc13222c519c Mon Sep 17 00:00:00 2001 From: Rachael Date: Sat, 15 Oct 2016 23:49:32 -0700 Subject: [PATCH] updates to one file per pattern and fixes a couple bugs --- draw-kiss.lua | 4 ++-- init2.lua | 4 +++- lamp-touch.lua | 8 +++++++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/draw-kiss.lua b/draw-kiss.lua index 381b52a..a9b7660 100644 --- a/draw-kiss.lua +++ b/draw-kiss.lua @@ -1,4 +1,4 @@ -return function(t,fb,g,r,b) +return function(t,fb,g,r,b) t:unregister() fb:fill(0,0,0) local ix = 0 @@ -17,4 +17,4 @@ return function(t,fb,g,r,b) ix = 1 - ix dodraw() end) -end \ No newline at end of file +end diff --git a/init2.lua b/init2.lua index a71dc7b..1311114 100644 --- a/init2.lua +++ b/init2.lua @@ -14,7 +14,9 @@ cap = require "cap1188" local function drawfailsafe(t,fb,g,r,b) fb:fill(g,r,b) end function loaddrawfn(name) - local f = loadfile ("draw-%s.lc":format(name)) + print("The name is ") + print(name) + local f = loadfile (string.format("draw-%s.lc", name)) local fn = f and f() if fn then return fn else return drawfailsafe end end diff --git a/lamp-touch.lua b/lamp-touch.lua index cfa2719..58e6058 100644 --- a/lamp-touch.lua +++ b/lamp-touch.lua @@ -13,8 +13,9 @@ local touchfnix = 1 -- Whip through the drawing functions and build indexes local k,v for k,v in pairs(file.list()) do - local ix, _, meth = k:find("^draw-(%w+)\\.lc$") + local ix, _, meth = k:find("^draw%-(%w+)%.lc$") if ix then + print("XXXXX touching", meth, #touchfns) touchfns[#touchfns+1] = meth if meth == "fill" then touchfnix = #touchfns end end @@ -118,10 +119,12 @@ local function ontouch() -- front middle: mode select (rate-limited, not exactly debounced) if bit.isset(down,3) then + print("front middle touched", touch_db_fn) if touch_db_fn == nil then touchfnix = touchfnix + 1 if touchfnix > #touchfns then touchfnix = 1 end touch_db_fn = touch_tq:queue(200,onfndebounce) + print("the function is now", touch_db_fn) end claimfb() end @@ -131,8 +134,11 @@ local function ontouch() -- if bit.isset(down,4) then end -- draw if we've claimed it! + print("ahhhh", ledfb, touchfb) if ledfb == touchfb then touchtmr:unregister() + print("XXXXX looking for XXXXX") + print(touchfnix) loaddrawfn(touchfns[touchfnix])(touchtmr,touchfb,touchcolorvec(touchcolor)); dodraw() touchtmr:start() end -- 2.50.1