local function attention(self,long)
if self.attnState then return end
- local tq = self.tq
local lcd = self.lcd
local function doBlink()
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
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
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)
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