diff --git a/firmware/application/apps/ui_weatherstation.cpp b/firmware/application/apps/ui_weatherstation.cpp index e277696b..06ae180f 100644 --- a/firmware/application/apps/ui_weatherstation.cpp +++ b/firmware/application/apps/ui_weatherstation.cpp @@ -30,6 +30,8 @@ using namespace portapack; using namespace ui; +namespace pmem = portapack::persistent_memory; + namespace ui { void WeatherRecentEntryDetailView::update_data() { @@ -91,6 +93,7 @@ WeatherView::WeatherView(NavigationView& nav) &field_rf_amp, &field_lna, &field_vga, + &field_volume, &field_frequency, &options_temperature, &button_clear_list, @@ -120,6 +123,11 @@ WeatherView::WeatherView(NavigationView& nav) signal_token_tick_second = rtc_time::signal_tick_second += [this]() { on_tick_second(); }; + + if (pmem::beep_on_packets()) { + audio::set_rate(audio::Rate::Hz_24000); + audio::output::start(); + } } void WeatherView::on_tick_second() { @@ -142,10 +150,15 @@ void WeatherView::on_data(const WeatherDataMessage* data) { truncate_entries(recent, 64); } recent_entries_view.set_dirty(); + + if (pmem::beep_on_packets()) { + baseband::request_audio_beep(1000, 24000, 60); + } } WeatherView::~WeatherView() { rtc_time::signal_tick_second -= signal_token_tick_second; + audio::output::stop(); receiver_model.disable(); baseband::shutdown(); } diff --git a/firmware/application/apps/ui_weatherstation.hpp b/firmware/application/apps/ui_weatherstation.hpp index a0b8f0e9..c31bf628 100644 --- a/firmware/application/apps/ui_weatherstation.hpp +++ b/firmware/application/apps/ui_weatherstation.hpp @@ -126,6 +126,10 @@ class WeatherView : public View { {18 * 8, 0 * 16}}; RSSI rssi{ {21 * 8, 0, 6 * 8, 4}}; + + AudioVolumeField field_volume{ + {28 * 8, 0 * 16}}; + RxFrequencyField field_frequency{ {0 * 8, 0 * 16}, nav_}; diff --git a/firmware/baseband/proc_weather.cpp b/firmware/baseband/proc_weather.cpp index 99b7489f..3d661c60 100644 --- a/firmware/baseband/proc_weather.cpp +++ b/firmware/baseband/proc_weather.cpp @@ -23,6 +23,7 @@ #include "proc_weather.hpp" #include "portapack_shared_memory.hpp" #include "event_m4.hpp" +#include "audio_dma.hpp" void WeatherProcessor::execute(const buffer_c8_t& buffer) { if (!configured) return; @@ -66,8 +67,18 @@ void WeatherProcessor::execute(const buffer_c8_t& buffer) { } void WeatherProcessor::on_message(const Message* const message) { - if (message->id == Message::ID::SubGhzFPRxConfigure) - configure(*reinterpret_cast(message)); + switch (message->id) { + case Message::ID::SubGhzFPRxConfigure: + configure(*reinterpret_cast(message)); + break; + + case Message::ID::AudioBeep: + on_beep_message(*reinterpret_cast(message)); + break; + + default: + break; + } } void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { @@ -84,7 +95,12 @@ void WeatherProcessor::configure(const SubGhzFPRxConfigureMessage& message) { configured = true; } +void WeatherProcessor::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_weather.hpp b/firmware/baseband/proc_weather.hpp index dc3824c7..c668f604 100644 --- a/firmware/baseband/proc_weather.hpp +++ b/firmware/baseband/proc_weather.hpp @@ -66,6 +66,7 @@ class WeatherProcessor : public BasebandProcessor { FProtoListGeneral* protoList = new WeatherProtos(); // holds all the protocols we can parse void configure(const SubGhzFPRxConfigureMessage& 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};