added sounder volume to config

This commit is contained in:
Mikayla Fischler 2022-12-04 14:29:39 -05:00
parent 4030fdc5c9
commit 9475700930
3 changed files with 9 additions and 3 deletions

View File

@ -10,6 +10,9 @@ config.SCADA_API_LISTEN = 16200
config.NUM_UNITS = 4
-- graphics color
config.RECOLOR = true
-- alarm sounder volume (0.0 to 3.0, 1.0 being standard max volume, this is the option given to to speaker.play())
-- note: alarm sine waves are at half saturation, so that multiple will be required to reach full scale
config.SOUNDER_VOLUME = 1.0
-- log path
config.LOG_PATH = "/log.txt"
-- log mode

View File

@ -265,10 +265,12 @@ end
-- initialize the annunciator alarm system
---@param speaker table speaker peripheral
function sounder.init(speaker)
---@param volume number speaker volume
function sounder.init(speaker, volume)
alarm_ctl.speaker = speaker
alarm_ctl.speaker.stop()
alarm_ctl.volume = volume
alarm_ctl.playing = false
alarm_ctl.num_active = 0
alarm_ctl.next_block = 1

View File

@ -18,7 +18,7 @@ local coordinator = require("coordinator.coordinator")
local renderer = require("coordinator.renderer")
local sounder = require("coordinator.sounder")
local COORDINATOR_VERSION = "beta-v0.7.2"
local COORDINATOR_VERSION = "beta-v0.7.3"
local print = util.print
local println = util.println
@ -42,6 +42,7 @@ cfv.assert_port(config.SCADA_SV_LISTEN)
cfv.assert_port(config.SCADA_API_LISTEN)
cfv.assert_type_int(config.NUM_UNITS)
cfv.assert_type_bool(config.RECOLOR)
cfv.assert_type_num(config.SOUNDER_VOLUME)
cfv.assert_type_str(config.LOG_PATH)
cfv.assert_type_int(config.LOG_MODE)
cfv.assert_type_bool(config.SECURE)
@ -105,7 +106,7 @@ local function main()
else
local sounder_start = util.time_ms()
log_boot("annunciator alarm speaker connected")
sounder.init(speaker)
sounder.init(speaker, config.SOUNDER_VOLUME)
log_boot("tone generation took " .. (util.time_ms() - sounder_start) .. "ms")
log_sys("annunciator alarm configured")
end