#264 improvements to RTU speaker sounder

This commit is contained in:
Mikayla Fischler
2023-07-29 17:57:51 -04:00
parent b3c7263bc4
commit 775d4dc95b
2 changed files with 45 additions and 40 deletions

View File

@@ -25,7 +25,7 @@ local threads = {}
local RTU_UNIT_TYPE = types.RTU_UNIT_TYPE
local UNIT_HW_STATE = databus.RTU_UNIT_HW_STATE
local MAIN_CLOCK = 2 -- (2Hz, 40 ticks)
local MAIN_CLOCK = 0.5 -- (2Hz, 10 ticks)
local COMMS_SLEEP = 100 -- (100ms, 2 ticks)
-- main thread
@@ -68,6 +68,15 @@ function threads.thread__main(smem)
-- blink heartbeat indicator
databus.heartbeat()
-- update speaker states
for _, sounder in pairs(sounders) do
-- re-compute output if needed, then play audio if available
if sounder.stream.is_recompute_needed() then
sounder.stream.compute_buffer()
if sounder.stream.has_next_block() then sounder.play() else sounder.stop() end
end
end
-- start next clock timer
loop_clock.start()