mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
reconnect alarm sounder speaker on peripheral reconnect
This commit is contained in:
parent
9475700930
commit
5224dcbd25
@ -288,6 +288,13 @@ function sounder.init(speaker, volume)
|
|||||||
gen_tone_8()
|
gen_tone_8()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- reconnect the speaker peripheral
|
||||||
|
---@param speaker table speaker peripheral
|
||||||
|
function sounder.reconnect(speaker)
|
||||||
|
alarm_ctl.speaker = speaker
|
||||||
|
alarm_ctl.playing = false
|
||||||
|
end
|
||||||
|
|
||||||
-- check alarm state to enable/disable alarms
|
-- check alarm state to enable/disable alarms
|
||||||
---@param units table|nil unit list or nil to use test mode
|
---@param units table|nil unit list or nil to use test mode
|
||||||
function sounder.eval(units)
|
function sounder.eval(units)
|
||||||
|
@ -18,7 +18,7 @@ local coordinator = require("coordinator.coordinator")
|
|||||||
local renderer = require("coordinator.renderer")
|
local renderer = require("coordinator.renderer")
|
||||||
local sounder = require("coordinator.sounder")
|
local sounder = require("coordinator.sounder")
|
||||||
|
|
||||||
local COORDINATOR_VERSION = "beta-v0.7.3"
|
local COORDINATOR_VERSION = "beta-v0.7.4"
|
||||||
|
|
||||||
local print = util.print
|
local print = util.print
|
||||||
local println = util.println
|
local println = util.println
|
||||||
@ -238,11 +238,15 @@ local function main()
|
|||||||
elseif type == "monitor" then
|
elseif type == "monitor" then
|
||||||
if renderer.is_monitor_used(device) then
|
if renderer.is_monitor_used(device) then
|
||||||
-- "halt and catch fire" style handling
|
-- "halt and catch fire" style handling
|
||||||
|
println_ts("lost a configured monitor, system will now exit")
|
||||||
log_sys("lost a configured monitor, system will now exit")
|
log_sys("lost a configured monitor, system will now exit")
|
||||||
break
|
break
|
||||||
else
|
else
|
||||||
log_sys("lost unused monitor, ignoring")
|
log_sys("lost unused monitor, ignoring")
|
||||||
end
|
end
|
||||||
|
elseif type == "speaker" then
|
||||||
|
println_ts("lost alarm sounder speaker")
|
||||||
|
log_sys("lost alarm sounder speaker")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif event == "peripheral" then
|
elseif event == "peripheral" then
|
||||||
@ -267,6 +271,10 @@ local function main()
|
|||||||
end
|
end
|
||||||
elseif type == "monitor" then
|
elseif type == "monitor" then
|
||||||
-- not supported, system will exit on loss of in-use monitors
|
-- not supported, system will exit on loss of in-use monitors
|
||||||
|
elseif type == "speaker" then
|
||||||
|
println_ts("alarm sounder speaker reconnected")
|
||||||
|
log_sys("alarm sounder speaker reconnected")
|
||||||
|
sounder.reconnect(device)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
elseif event == "timer" then
|
elseif event == "timer" then
|
||||||
|
Loading…
Reference in New Issue
Block a user