Speaker option for the H1

This commit is contained in:
eried 2020-06-08 01:23:44 +02:00
parent bf3f9cfe75
commit 934f4b07c4
4 changed files with 56 additions and 1 deletions

View File

@ -93,6 +93,15 @@ bool get_antenna_bias() {
return 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) { static constexpr uint32_t systick_count(const uint32_t clock_source_f) {
return clock_source_f / CH_FREQUENCY; return clock_source_f / CH_FREQUENCY;
} }

View File

@ -51,6 +51,9 @@ extern ClockManager clock_manager;
extern ReceiverModel receiver_model; extern ReceiverModel receiver_model;
extern TransmitterModel transmitter_model; extern TransmitterModel transmitter_model;
extern bool speaker_mode;
void set_speaker_mode(const bool v);
extern uint8_t bl_tick_counter; extern uint8_t bl_tick_counter;
extern bool antenna_bias; extern bool antenna_bias;

View File

@ -106,6 +106,7 @@ SystemStatusView::SystemStatusView(
&backdrop, &backdrop,
&button_back, &button_back,
&title, &title,
&button_speaker,
&button_stealth, &button_stealth,
//&button_textentry, //&button_textentry,
&button_camera, &button_camera,
@ -115,6 +116,11 @@ SystemStatusView::SystemStatusView(
&sd_card_status_view, &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 button_back.id = -1; // Special ID used by FocusManager
title.set_style(&style_systemstatus); title.set_style(&style_systemstatus);
@ -133,6 +139,10 @@ SystemStatusView::SystemStatusView(
this->on_back(); this->on_back();
}; };
button_speaker.on_select = [this](ImageButton&) {
this->on_speaker();
};
button_stealth.on_select = [this](ImageButton&) { button_stealth.on_select = [this](ImageButton&) {
this->on_stealth(); this->on_stealth();
}; };
@ -156,6 +166,14 @@ SystemStatusView::SystemStatusView(
} }
void SystemStatusView::refresh() { 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()) { if (portapack::get_antenna_bias()) {
button_bias_tee.set_bitmap(&bitmap_icon_biast_on); button_bias_tee.set_bitmap(&bitmap_icon_biast_on);
button_bias_tee.set_foreground(ui::Color::yellow()); 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() { void SystemStatusView::on_stealth() {
bool mode = not portapack::persistent_memory::stealth_mode(); bool mode = not portapack::persistent_memory::stealth_mode();

View File

@ -126,10 +126,17 @@ private:
}; };
Text title { Text title {
{ 20, 0, 16 * 8, 1 * 16 }, { 20, 0, 14 * 8, 1 * 16 },
default_title, 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 { ImageButton button_stealth {
{ 19 * 8, 0, 2 * 8, 1 * 16 }, { 19 * 8, 0, 2 * 8, 1 * 16 },
&bitmap_icon_stealth, &bitmap_icon_stealth,
@ -176,6 +183,7 @@ private:
{ 28 * 8, 0 * 16, 2 * 8, 1 * 16 } { 28 * 8, 0 * 16, 2 * 8, 1 * 16 }
}; };
void on_speaker();
void on_stealth(); void on_stealth();
void on_bias_tee(); void on_bias_tee();
//void on_textentry(); //void on_textentry();