From 0db65ccb6be824c33fd045e93c8d40a8821439f2 Mon Sep 17 00:00:00 2001 From: Mark Thompson <129641948+NotherNgineer@users.noreply.github.com> Date: Fri, 29 Mar 2024 15:27:53 -0500 Subject: [PATCH] Beep-on-packet support in POCSAG app (#2061) --- firmware/application/apps/pocsag_app.cpp | 8 ++++++++ firmware/baseband/proc_pocsag2.cpp | 8 ++++++++ firmware/baseband/proc_pocsag2.hpp | 1 + 3 files changed, 17 insertions(+) diff --git a/firmware/application/apps/pocsag_app.cpp b/firmware/application/apps/pocsag_app.cpp index 5d0533e4..3879c8e8 100644 --- a/firmware/application/apps/pocsag_app.cpp +++ b/firmware/application/apps/pocsag_app.cpp @@ -136,6 +136,10 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav) }; refresh_ui(); + + if (pmem::beep_on_packets()) + audio::set_rate(audio::Rate::Hz_24000); + audio::output::start(); receiver_model.enable(); baseband::set_pocsag(); @@ -304,6 +308,10 @@ void POCSAGAppView::on_packet(const POCSAGPacketMessage* message) { // Set status icon color to indicate state machine state. image_status.set_foreground(get_status_color(pocsag_state)); + + if (pmem::beep_on_packets()) { + baseband::request_audio_beep(1000, 24000, 60); + } } void POCSAGAppView::on_stats(const POCSAGStatsMessage* stats) { diff --git a/firmware/baseband/proc_pocsag2.cpp b/firmware/baseband/proc_pocsag2.cpp index 1170a520..65dd7b09 100644 --- a/firmware/baseband/proc_pocsag2.cpp +++ b/firmware/baseband/proc_pocsag2.cpp @@ -361,6 +361,10 @@ void POCSAGProcessor::on_message(const Message* const message) { break; } + case Message::ID::AudioBeep: + on_beep_message(*reinterpret_cast(message)); + break; + default: break; } @@ -414,6 +418,10 @@ void POCSAGProcessor::send_packet() { shared_memory.application_queue.push(message); } +void POCSAGProcessor::on_beep_message(const AudioBeepMessage& message) { + audio::dma::beep_start(message.freq, message.sample_rate, message.duration_ms); +} + /* main **************************************************/ int main() { diff --git a/firmware/baseband/proc_pocsag2.hpp b/firmware/baseband/proc_pocsag2.hpp index d7ca2118..9215e7fd 100644 --- a/firmware/baseband/proc_pocsag2.hpp +++ b/firmware/baseband/proc_pocsag2.hpp @@ -212,6 +212,7 @@ class POCSAGProcessor : public BasebandProcessor { void reset(); void send_stats() const; void send_packet(); + void on_beep_message(const AudioBeepMessage& message); /* Set once app is ready to receive messages. */ bool configured = false;