diff --git a/firmware/application/apps/tpms_app.cpp b/firmware/application/apps/tpms_app.cpp index bf9f14f8..06cf1c37 100644 --- a/firmware/application/apps/tpms_app.cpp +++ b/firmware/application/apps/tpms_app.cpp @@ -23,7 +23,7 @@ #include "tpms_app.hpp" #include "baseband_api.hpp" - +#include "audio.hpp" #include "portapack.hpp" using namespace portapack; @@ -32,6 +32,8 @@ using namespace portapack; #include "utility.hpp" #include "file_path.hpp" +namespace pmem = portapack::persistent_memory; + namespace tpms { namespace format { @@ -147,6 +149,7 @@ TPMSAppView::TPMSAppView(NavigationView&) { baseband::run_image(portapack::spi_flash::image_tag_tpms); add_children({&rssi, + &field_volume, &channel, &options_band, &options_pressure, @@ -179,9 +182,15 @@ TPMSAppView::TPMSAppView(NavigationView&) { if (logger) { logger->append(logs_dir / u"TPMS.TXT"); } + + if (pmem::beep_on_packets()) { + audio::set_rate(audio::Rate::Hz_24000); + audio::output::start(); + } } TPMSAppView::~TPMSAppView() { + audio::output::stop(); receiver_model.disable(); baseband::shutdown(); } @@ -214,6 +223,10 @@ void TPMSAppView::on_packet(const tpms::Packet& packet) { entry.update(reading); recent_entries_view.set_dirty(); } + + if (pmem::beep_on_packets()) { + baseband::request_audio_beep(1000, 24000, 60); + } } void TPMSAppView::on_show_list() { diff --git a/firmware/application/apps/tpms_app.hpp b/firmware/application/apps/tpms_app.hpp index d4beb831..06d93003 100644 --- a/firmware/application/apps/tpms_app.hpp +++ b/firmware/application/apps/tpms_app.hpp @@ -143,6 +143,9 @@ class TPMSAppView : public View { {21 * 8, 0, 6 * 8, 4}, }; + AudioVolumeField field_volume{ + {28 * 8, 0 * 16}}; + Channel channel{ {21 * 8, 5, 6 * 8, 4}, }; diff --git a/firmware/baseband/proc_tpms.cpp b/firmware/baseband/proc_tpms.cpp index bd604231..2cae8a24 100644 --- a/firmware/baseband/proc_tpms.cpp +++ b/firmware/baseband/proc_tpms.cpp @@ -21,6 +21,7 @@ */ #include "proc_tpms.hpp" +#include "audio_dma.hpp" #include "dsp_fir_taps.hpp" @@ -60,7 +61,17 @@ void TPMSProcessor::execute(const buffer_c8_t& buffer) { } } +void TPMSProcessor::on_message(const Message* const msg) { + if (msg->id == Message::ID::AudioBeep) + on_beep_message(*reinterpret_cast(msg)); +} + +void TPMSProcessor::on_beep_message(const AudioBeepMessage& message) { + audio::dma::beep_start(message.freq, message.sample_rate, message.duration_ms); +} + int main() { + audio::dma::init_audio_out(); EventDispatcher event_dispatcher{std::make_unique()}; event_dispatcher.run(); return 0; diff --git a/firmware/baseband/proc_tpms.hpp b/firmware/baseband/proc_tpms.hpp index c755a677..6fcf1d62 100644 --- a/firmware/baseband/proc_tpms.hpp +++ b/firmware/baseband/proc_tpms.hpp @@ -140,6 +140,9 @@ class TPMSProcessor : public BasebandProcessor { shared_memory.application_queue.push(message); }}; + void on_message(const Message* const message); + void on_beep_message(const AudioBeepMessage& message); + /* NB: Threads should be the last members in the class definition. */ BasebandThread baseband_thread{ baseband_fs, this, baseband::Direction::Receive, /*auto_start*/ false};