added controll room alarm

This commit is contained in:
2025-06-15 18:36:47 -04:00
parent 1403a45fa2
commit 1a6f7fe882
4 changed files with 71 additions and 2 deletions

60
speaker_driver.lua Normal file
View File

@@ -0,0 +1,60 @@
local dfpwm = require("cc.audio.dfpwm")
local encoder = dfpwm.make_encoder()
local decoder = dfpwm.make_decoder()
local function getFileName(name)
local extension = ".dfpwm"
local fullFile = name .. extension
return fullFile
end
local function playSound(speaker, fileName)
for input in io.lines(getFileName(fileName), 16 * 1024) do
local decoded = decoder(input)
while not speaker.playAudio(decoded) do
os.pullEvent("speaker_audio_empty")
end
end
end
function playControlRoomAlarm(speakers)
for _, speaker in ipairs(speakers) do
playSound(speaker,"control_alarm")
end
end
function addSoundFile(fileName)
local baseRoute = "https://git.astrocore.space/root/NovaCorpLLC/raw/branch/main/"
local name = getFileName(fileName)
local fullPath = baseRoute .. name
shell.execute("rm", name)
shell.execute("wget", fullPath)
end
local function watch()
end
local function startUp()
local sounds = {
{ fileName = "control_alarm" }
}
for i, item in ipairs(sounds) do
addSoundFile(item.fileName)
end
end
local function shutdown()
end
local function report()
end
return { report = report, watch = watch, startUp = startUp, shutdown = shutdown }