From 2baf13f66486e965bf603dfc82a03c0ade375c02 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Sun, 16 Oct 2016 11:13:19 -0400 Subject: [PATCH] examples/lamp: stop using a timer for touch --- lamp-touch.lua | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lamp-touch.lua b/lamp-touch.lua index 388ad6a..75f56d3 100644 --- a/lamp-touch.lua +++ b/lamp-touch.lua @@ -1,7 +1,6 @@ -- globals referenced: isblackout, dodraw, ledfb, ledfb_claimed, remotefb, remotetmr, lamp_announce, tq, loaddrawfn -- assumptions: gpio.trig(6) is the right thing to do for touch IRQs -local touch_tq = (dofile "tq.lc")(5) local touchfb = ws2812.newBuffer(32,3) local touch_fini = nil local touch_db_blackout = nil @@ -91,15 +90,15 @@ end local function ontouch() local _, down = cap:rt() - if touch_fini ~= nil then touch_tq:dequeue(touch_fini) end + if touch_fini ~= nil then tq:dequeue(touch_fini) end -- nothing down, kick off timer for touch done - if down == 0 then touch_fini = touch_tq:queue(1500,ontouchdone) end + if down == 0 then touch_fini = tq:queue(1500,ontouchdone) end -- back right button: display toggle once per touch of button if bit.isset(down,0) then - if touch_db_blackout == nil then toggleblackout() else touch_tq:dequeue(touch_db_blackout) end - touch_db_blackout = touch_tq:queue(300,onblackdebounce) + if touch_db_blackout == nil then toggleblackout() else tq:dequeue(touch_db_blackout) end + touch_db_blackout = tq:queue(300,onblackdebounce) end if not isblackout then @@ -121,7 +120,7 @@ local function ontouch() if touch_db_fn == nil then touchfnix = touchfnix + 1 if touchfnix > #touchfns then touchfnix = 1 end - touch_db_fn = touch_tq:queue(200,onfndebounce) + touch_db_fn = tq:queue(200,onfndebounce) end claimfb() end -- 2.50.1