mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Add AM/NBFM configuration options views.
This commit is contained in:
parent
be8c1307e2
commit
3f86a7c4ae
@ -29,6 +29,46 @@ using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
/* AMOptionsView *********************************************************/
|
||||
|
||||
AMOptionsView::AMOptionsView(
|
||||
const Rect parent_rect, const Style* const style
|
||||
) : View { parent_rect }
|
||||
{
|
||||
set_style(style);
|
||||
|
||||
add_children({ {
|
||||
&label_config,
|
||||
&options_config,
|
||||
} });
|
||||
|
||||
options_config.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
if( on_config_changed ) {
|
||||
this->on_config_changed(n);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* NBFMOptionsView *******************************************************/
|
||||
|
||||
NBFMOptionsView::NBFMOptionsView(
|
||||
const Rect parent_rect, const Style* const style
|
||||
) : View { parent_rect }
|
||||
{
|
||||
set_style(style);
|
||||
|
||||
add_children({ {
|
||||
&label_config,
|
||||
&options_config,
|
||||
} });
|
||||
|
||||
options_config.on_change = [this](size_t n, OptionsField::value_t) {
|
||||
if( on_config_changed ) {
|
||||
this->on_config_changed(n);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/* AnalogAudioView *******************************************************/
|
||||
|
||||
AnalogAudioView::AnalogAudioView(
|
||||
@ -45,6 +85,8 @@ AnalogAudioView::AnalogAudioView(
|
||||
&field_volume,
|
||||
&view_frequency_options,
|
||||
&view_rf_gain_options,
|
||||
&view_am_options,
|
||||
&view_nbfm_options,
|
||||
&waterfall,
|
||||
} });
|
||||
|
||||
@ -84,6 +126,9 @@ AnalogAudioView::AnalogAudioView(
|
||||
options_modulation.on_change = [this](size_t, OptionsField::value_t v) {
|
||||
this->on_modulation_changed(static_cast<ReceiverModel::Mode>(v));
|
||||
};
|
||||
options_modulation.on_show_options = [this]() {
|
||||
this->on_show_options_modulation();
|
||||
};
|
||||
|
||||
field_volume.set_value((receiver_model.headphone_volume() - wolfson::wm8731::headphone_gain_range.max).decibel() + 99);
|
||||
field_volume.on_change = [this](int32_t v) {
|
||||
@ -106,6 +151,16 @@ AnalogAudioView::AnalogAudioView(
|
||||
this->on_rf_amp_changed(enable);
|
||||
};
|
||||
|
||||
view_am_options.hidden(true);
|
||||
view_am_options.on_config_changed = [this](size_t n) {
|
||||
this->on_am_config_index_changed(n);
|
||||
};
|
||||
|
||||
view_nbfm_options.hidden(true);
|
||||
view_nbfm_options.on_config_changed = [this](size_t n) {
|
||||
this->on_nbfm_config_index_changed(n);
|
||||
};
|
||||
|
||||
update_modulation(static_cast<ReceiverModel::Mode>(receiver_model.modulation()));
|
||||
}
|
||||
|
||||
@ -160,25 +215,61 @@ void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode modulation
|
||||
// it's being shown or hidden.
|
||||
waterfall.on_hide();
|
||||
update_modulation(modulation);
|
||||
on_show_options_modulation();
|
||||
waterfall.on_show();
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_show_options_frequency() {
|
||||
// TODO: This approach of managing options views is error-prone and unsustainable!
|
||||
view_rf_gain_options.hidden(true);
|
||||
view_am_options.hidden(true);
|
||||
view_nbfm_options.hidden(true);
|
||||
|
||||
field_lna.set_style(nullptr);
|
||||
options_modulation.set_style(nullptr);
|
||||
|
||||
view_frequency_options.hidden(false);
|
||||
field_frequency.set_style(&view_frequency_options.style());
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_show_options_rf_gain() {
|
||||
// TODO: This approach of managing options views is error-prone and unsustainable!
|
||||
view_frequency_options.hidden(true);
|
||||
view_am_options.hidden(true);
|
||||
view_nbfm_options.hidden(true);
|
||||
|
||||
field_frequency.set_style(nullptr);
|
||||
options_modulation.set_style(nullptr);
|
||||
|
||||
view_rf_gain_options.hidden(false);
|
||||
field_lna.set_style(&view_frequency_options.style());
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_show_options_modulation() {
|
||||
// TODO: This approach of managing options views is error-prone and unsustainable!
|
||||
view_frequency_options.hidden(true);
|
||||
view_rf_gain_options.hidden(true);
|
||||
|
||||
const auto modulation = static_cast<ReceiverModel::Mode>(receiver_model.modulation());
|
||||
if( modulation != ReceiverModel::Mode::AMAudio ) {
|
||||
view_am_options.hidden(true);
|
||||
}
|
||||
if( modulation != ReceiverModel::Mode::NarrowbandFMAudio ) {
|
||||
view_nbfm_options.hidden(true);
|
||||
}
|
||||
|
||||
field_frequency.set_style(nullptr);
|
||||
field_lna.set_style(nullptr);
|
||||
|
||||
if( modulation == ReceiverModel::Mode::AMAudio ) {
|
||||
view_am_options.hidden(false);
|
||||
}
|
||||
if( modulation == ReceiverModel::Mode::NarrowbandFMAudio ) {
|
||||
view_nbfm_options.hidden(false);
|
||||
}
|
||||
options_modulation.set_style(&view_frequency_options.style());
|
||||
}
|
||||
|
||||
void AnalogAudioView::on_frequency_step_changed(rf::Frequency f) {
|
||||
receiver_model.set_frequency_step(f);
|
||||
field_frequency.set_step(f);
|
||||
|
@ -37,6 +37,52 @@ constexpr Style style_options_group {
|
||||
.foreground = Color::white(),
|
||||
};
|
||||
|
||||
class AMOptionsView : public View {
|
||||
public:
|
||||
std::function<void(size_t)> on_config_changed;
|
||||
|
||||
AMOptionsView(const Rect parent_rect, const Style* const style);
|
||||
|
||||
private:
|
||||
Text label_config {
|
||||
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||
"BW",
|
||||
};
|
||||
|
||||
OptionsField options_config {
|
||||
{ 3 * 8, 0 * 16 },
|
||||
4,
|
||||
{
|
||||
{ "DSB ", 0 },
|
||||
{ "USB ", 0 },
|
||||
{ "LSB ", 0 },
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class NBFMOptionsView : public View {
|
||||
public:
|
||||
std::function<void(size_t)> on_config_changed;
|
||||
|
||||
NBFMOptionsView(const Rect parent_rect, const Style* const style);
|
||||
|
||||
private:
|
||||
Text label_config {
|
||||
{ 0 * 8, 0 * 16, 2 * 8, 1 * 16 },
|
||||
"BW",
|
||||
};
|
||||
|
||||
OptionsField options_config {
|
||||
{ 3 * 8, 0 * 16 },
|
||||
4,
|
||||
{
|
||||
{ " 8k5", 0 },
|
||||
{ "11k ", 0 },
|
||||
{ "16k ", 0 },
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
class AnalogAudioView : public View {
|
||||
public:
|
||||
AnalogAudioView(NavigationView& nav);
|
||||
@ -107,20 +153,19 @@ private:
|
||||
{ 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
|
||||
&style_options_group
|
||||
};
|
||||
/*
|
||||
AmplitudeModulationOptionsView view_am_modulation_options {
|
||||
|
||||
AMOptionsView view_am_options {
|
||||
{ 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
|
||||
&style_options_group
|
||||
};
|
||||
|
||||
FrequencyModulationOptionsView view_fm_modulation_options {
|
||||
NBFMOptionsView view_nbfm_options {
|
||||
{ 0 * 8, 1 * 16, 30 * 8, 1 * 16 },
|
||||
&style_options_group
|
||||
};
|
||||
*/
|
||||
|
||||
spectrum::WaterfallWidget waterfall;
|
||||
|
||||
|
||||
void on_tuning_frequency_changed(rf::Frequency f);
|
||||
void on_baseband_bandwidth_changed(uint32_t bandwidth_hz);
|
||||
void on_rf_amp_changed(bool v);
|
||||
@ -129,6 +174,7 @@ private:
|
||||
void on_modulation_changed(const ReceiverModel::Mode modulation);
|
||||
void on_show_options_frequency();
|
||||
void on_show_options_rf_gain();
|
||||
void on_show_options_modulation();
|
||||
void on_frequency_step_changed(rf::Frequency f);
|
||||
void on_reference_ppm_correction_changed(int32_t v);
|
||||
void on_headphone_volume_changed(int32_t v);
|
||||
|
Loading…
Reference in New Issue
Block a user