drawDS(lcd,3,13,maxt,self.dl_remain ,rem); self.dl_remain = rem
end
-local function attention(self)
+local function attention(self,long)
if self.attnState then return end
local tq = self.tq
local lcd = self.lcd
local function doBlink()
- if self.attnState <= 0 then self.attnState = nil ; return end
+ if self.attnState <= 0 then
+ self.attnState = nil
+ gpio.write(5,gpio.HIGH) -- silence beeper always
+ return
+ end
self.attnState = self.attnState - 1
+ -- blink
lcd:light(false)
tq:queue(250, function() lcd:light(true); tq:queue(500, 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
end
self.attnState = 2
local rix, maxt, ela = ctfws:times(rtctime.get)
if rix == nil then
drawNoGame(self.lcd, maxt)
+ if rix ~= self.dl_round then
+ self.dl_round = rix
+ attention(self,true)
+ end
return false
end
if rix ~= self.dl_round then
- if self.dl_round ~= nil then attention(self) end -- XXX beep when not forcibly reset
+ if self.dl_round ~= nil then attention(self,true) end
self.dl_round = rix
self.dl_elapsed = nil -- force redraws of times on round boundaries
self.dl_remain = nil
ctfws.flagsN, tostring(ctfws.flagsR), tostring(ctfws.flagsY))
:sub(1,20)
lcd:put(lcd:locate(1,(20-#str)/2), str)
- attention(self)
+ attention(self,false)
end
end
end
self.mtmr:alarm(300, tmr.ALARM_AUTO, scroller)
end
- attention(self)
+ attention(self,false)
end
local function reset(self)
-- Grab some configuration parameters we might need,
-- notably, the LCD address
-ctfwshw = {}
+local ctfwshw = {}
if file.open("ctfws-misc.conf","r") then
local conf = cjson.decode(file.read() or "")
if type(conf) == "table"
end
-- Hardware initialization
+print("init2 hw")
+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() dofile("init3.lc") end)
+tq:queue(125, function() print("init2 go3") dofile("init3.lc") end)