]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_lamp/commitdiff
examples/lamp: stop using a timer for touch
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sun, 16 Oct 2016 15:13:19 +0000 (11:13 -0400)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Sun, 16 Oct 2016 15:13:19 +0000 (11:13 -0400)
lamp-touch.lua

index 388ad6af0af222ea95e7407a281ea46eaa3dc8eb..75f56d3737535cd684db02277cc810c090b32cf2 100644 (file)
@@ -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