]> hydra-www.ietfng.org Git - acmetensortoys-esp-lua_ctfws/commitdiff
Remove dependency on deprecated core/tq
authorNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 10 Nov 2017 21:37:30 +0000 (16:37 -0500)
committerNathaniel Wesley Filardo <nwf@cs.jhu.edu>
Fri, 10 Nov 2017 21:37:46 +0000 (16:37 -0500)
Use the dynamic, OO timer API; there's no real risk of running out,
and we never used tq's :dequeue() capability anyway.

ctfws-lcd.lua
init2.lua
init3.lua

index b9c4f81b3627c17fe23ae4c136b22ddc2ebd6655..c89bcdb3cb5b31bb98c6b113f2d3d9373f0f6956 100644 (file)
@@ -71,7 +71,6 @@ end
 local function attention(self,long)
   if self.attnState then return end
 
-  local tq = self.tq
   local lcd = self.lcd
 
   local function doBlink()
@@ -83,14 +82,15 @@ local function attention(self,long)
     self.attnState = self.attnState - 1
     -- blink
     lcd:light(false)
-    tq:queue(250, function() lcd:light(true); tq:queue(500, doBlink) end)
+    tmr.create():alarm(250,tmr.ALARM_SINGLE,
+      function() lcd:light(true) ; (tmr.create()):alarm(500,tmr.ALARM_SINGLE,doBlink) end)
     -- chirp or scream
     gpio.write(5,gpio.LOW)
-    if not long then tq:queue(100, function() gpio.write(5,gpio.HIGH) end) end
+    if not long then tmr.create():alarm(100, tmr.ALARM_SINGLE, function() gpio.write(5,gpio.HIGH) end) end
   end
 
   self.attnState = 2
-  tq:queue(250, doBlink)
+  (tmr.create()):alarm(250, tmr.ALARM_SINGLE, doBlink)
 end
 
 -- returns true if timers should keep going or false if we should wait for
@@ -168,11 +168,10 @@ local function reset(self)
   self.dl_round   = nil
 end
 
-return function(ctfws, lcd, tq, t)
+return function(ctfws, lcd, t)
   self = {}
   self.ctfws = ctfws
   self.lcd = lcd
-  self.tq = tq
   self.mtmr = t
 
   self.attnState        = nil
index 8623c4f114bc3e68cf9178b4e645e833b8acaf9b..7ae5297f10f6b1bda3d3da0a462c9d71512cddde 100644 (file)
--- a/init2.lua
+++ b/init2.lua
@@ -19,7 +19,5 @@ gpio.mode(5,gpio.OUTPUT)   -- beeper on GPIO14
 i2c.setup(0,2,1,i2c.SLOW)  -- init i2c on GPIO4 and GPIO5
 lcd = dofile("lcd1602.lc")(ctfwshw.lcd or 0x27)
 
-tq = (dofile "tq.lc")(tmr.create())
-
 -- give the LCD time to initialize properly
-tq:queue(125, function() print("init2 go3") dofile("init3.lc") end)
+tmr.create():alarm(125, tmr.ALARM_SINGLE, function() print("init2 go3") dofile("init3.lc") end)
index 582d269267b95a78640d5d4f58b1542c2c614da1..612004b1d33003574ade901b22222e0dd61609f1 100644 (file)
--- a/init3.lua
+++ b/init3.lua
@@ -7,7 +7,7 @@ ctfws = dofile("ctfws.lc")()
 ctfws:setFlags(0,0)
 
 msg_tmr = tmr.create()
-ctfws_lcd = dofile("ctfws-lcd.lc")(ctfws, lcd, tq, msg_tmr)
+ctfws_lcd = dofile("ctfws-lcd.lc")(ctfws, lcd, msg_tmr)
 ctfws_tmr = tmr.create()
 
 -- Draw the default display