Restore use of ReceiverModel::Mode enum.

This commit is contained in:
Jared Boone 2016-02-01 09:12:55 -08:00
parent 4d3294c228
commit c5f8daa210
2 changed files with 20 additions and 26 deletions

View File

@ -149,10 +149,9 @@ AnalogAudioView::AnalogAudioView(
this->on_vga_changed(v_db);
};
options_modulation.set_by_value(1);
options_modulation.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n;
this->on_modulation_changed(v);
options_modulation.set_by_value(toUType(ReceiverModel::Mode::AMAudio));
options_modulation.on_change = [this](size_t, OptionsField::value_t v) {
this->on_modulation_changed(static_cast<ReceiverModel::Mode>(v));
};
field_volume.set_value((receiver_model.headphone_volume() - wolfson::wm8731::headphone_gain_range.max).decibel() + 99);
@ -229,63 +228,58 @@ void AnalogAudioView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db);
}
void AnalogAudioView::on_modulation_changed(int32_t mode) {
// remove_child(widget_content.get());
// widget_content.reset();
void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode mode) {
// TODO: Terrible kludge because widget system doesn't notify Waterfall that
// it's being shown or hidden.
waterfall.on_hide();
switch(mode) {
default:
case 1:
case ReceiverModel::Mode::AMAudio:
receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::AMAudio),
.mode = toUType(mode),
.sampling_rate = 3072000,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.enable();
model.configure_am(0);
waterfall.on_show();
break;
case 2:
case ReceiverModel::Mode::NarrowbandFMAudio:
receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::NarrowbandFMAudio),
.mode = toUType(mode),
.sampling_rate = 3072000,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.enable();
model.configure_nbfm(1);
waterfall.on_show();
model.configure_nbfm(0);
break;
case 3:
case ReceiverModel::Mode::WidebandFMAudio:
receiver_model.set_baseband_configuration({
.mode = toUType(ReceiverModel::Mode::WidebandFMAudio),
.mode = toUType(mode),
.sampling_rate = 3072000,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(1750000);
receiver_model.enable();
model.configure_wfm();
waterfall.on_show();
break;
case 4:
case ReceiverModel::Mode::SpectrumAnalysis:
receiver_model.set_baseband_configuration({
.mode = 4,
.mode = toUType(mode),
.sampling_rate = 20000000,
.decimation_factor = 1,
});
receiver_model.set_baseband_bandwidth(12000000);
receiver_model.enable();
waterfall.on_show();
break;
}
waterfall.on_show();
}
void AnalogAudioView::on_show_options_frequency() {

View File

@ -93,10 +93,10 @@ private:
{ 0 * 8, 0 * 16 },
4,
{
{ " AM ", 1 },
{ "NFM ", 2 },
{ "WFM ", 3 },
{ "SPEC", 4 },
{ " AM ", toUType(ReceiverModel::Mode::AMAudio) },
{ "NFM ", toUType(ReceiverModel::Mode::NarrowbandFMAudio) },
{ "WFM ", toUType(ReceiverModel::Mode::WidebandFMAudio) },
{ "SPEC", toUType(ReceiverModel::Mode::SpectrumAnalysis) },
}
};
@ -135,7 +135,7 @@ private:
void on_rf_amp_changed(bool v);
void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db);
void on_modulation_changed(int32_t v);
void on_modulation_changed(const ReceiverModel::Mode mode);
void on_show_options_frequency();
void on_show_options_rf_gain();
void on_frequency_step_changed(rf::Frequency f);