diff --git a/firmware/application/portapack.cpp b/firmware/application/portapack.cpp index 50872d9e..99843aec 100644 --- a/firmware/application/portapack.cpp +++ b/firmware/application/portapack.cpp @@ -93,6 +93,15 @@ bool get_antenna_bias() { return antenna_bias; } +bool speaker_mode { false }; + void set_speaker_mode(const bool v) { + speaker_mode = v; + if (speaker_mode) + audio::output::speaker_unmute(); + else + audio::output::speaker_mute(); + } + static constexpr uint32_t systick_count(const uint32_t clock_source_f) { return clock_source_f / CH_FREQUENCY; } diff --git a/firmware/application/portapack.hpp b/firmware/application/portapack.hpp index 359b1446..c46a8d42 100644 --- a/firmware/application/portapack.hpp +++ b/firmware/application/portapack.hpp @@ -51,6 +51,9 @@ extern ClockManager clock_manager; extern ReceiverModel receiver_model; extern TransmitterModel transmitter_model; +extern bool speaker_mode; +void set_speaker_mode(const bool v); + extern uint8_t bl_tick_counter; extern bool antenna_bias; diff --git a/firmware/application/ui_navigation.cpp b/firmware/application/ui_navigation.cpp index 53abcfd9..7d36f046 100644 --- a/firmware/application/ui_navigation.cpp +++ b/firmware/application/ui_navigation.cpp @@ -106,6 +106,7 @@ SystemStatusView::SystemStatusView( &backdrop, &button_back, &title, + &button_speaker, &button_stealth, //&button_textentry, &button_camera, @@ -115,6 +116,11 @@ SystemStatusView::SystemStatusView( &sd_card_status_view, }); + if (portapack::persistent_memory::config_speaker()) + button_speaker.hidden(false); + else + button_speaker.hidden(true); + button_back.id = -1; // Special ID used by FocusManager title.set_style(&style_systemstatus); @@ -133,6 +139,10 @@ SystemStatusView::SystemStatusView( this->on_back(); }; + button_speaker.on_select = [this](ImageButton&) { + this->on_speaker(); + }; + button_stealth.on_select = [this](ImageButton&) { this->on_stealth(); }; @@ -156,6 +166,14 @@ SystemStatusView::SystemStatusView( } void SystemStatusView::refresh() { + if (!portapack::persistent_memory::config_speaker()) { + button_speaker.set_foreground(Color::light_grey()); + button_speaker.set_bitmap(&bitmap_icon_speaker_mute); + button_speaker.hidden(false); + } + else { + button_speaker.hidden(true); + } if (portapack::get_antenna_bias()) { button_bias_tee.set_bitmap(&bitmap_icon_biast_on); button_bias_tee.set_foreground(ui::Color::yellow()); @@ -188,6 +206,23 @@ void SystemStatusView::set_title(const std::string new_value) { } } +void SystemStatusView::on_speaker() { + if (!portapack::speaker_mode) + { + portapack::set_speaker_mode(true); + button_speaker.set_foreground(Color::green()); + button_speaker.set_bitmap(&bitmap_icon_speaker); + } + else + { + portapack::set_speaker_mode(false); + button_speaker.set_foreground(Color::light_grey()); + button_speaker.set_bitmap(&bitmap_icon_speaker_mute); + } + + } + + void SystemStatusView::on_stealth() { bool mode = not portapack::persistent_memory::stealth_mode(); diff --git a/firmware/application/ui_navigation.hpp b/firmware/application/ui_navigation.hpp index 7d99e45b..57c7b27d 100644 --- a/firmware/application/ui_navigation.hpp +++ b/firmware/application/ui_navigation.hpp @@ -126,9 +126,16 @@ private: }; Text title { - { 20, 0, 16 * 8, 1 * 16 }, + { 20, 0, 14 * 8, 1 * 16 }, default_title, }; + + ImageButton button_speaker { + { 17 * 8, 0, 2 * 8, 1 * 16 }, + &bitmap_icon_speaker_mute, + Color::light_grey(), + Color::dark_grey() + }; ImageButton button_stealth { { 19 * 8, 0, 2 * 8, 1 * 16 }, @@ -176,6 +183,7 @@ private: { 28 * 8, 0 * 16, 2 * 8, 1 * 16 } }; + void on_speaker(); void on_stealth(); void on_bias_tee(); //void on_textentry();