From 2f226a27e900f080a326552b9fc4384f32d0eec7 Mon Sep 17 00:00:00 2001 From: Nathaniel Wesley Filardo Date: Fri, 10 Nov 2017 16:37:30 -0500 Subject: [PATCH] Remove dependency on deprecated core/tq 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 | 11 +++++------ init2.lua | 4 +--- init3.lua | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/ctfws-lcd.lua b/ctfws-lcd.lua index b9c4f81..c89bcdb 100644 --- a/ctfws-lcd.lua +++ b/ctfws-lcd.lua @@ -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 diff --git a/init2.lua b/init2.lua index 8623c4f..7ae5297 100644 --- 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) diff --git a/init3.lua b/init3.lua index 582d269..612004b 100644 --- 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 -- 2.50.1