From ee67948a639a4b4675993e9ac03496e8e5402d93 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Mon, 1 Feb 2016 09:17:32 -0800 Subject: [PATCH] Simplify AnalogAudioView mode switching. --- firmware/application/analog_audio_app.cpp | 37 ++++++----------------- 1 file changed, 9 insertions(+), 28 deletions(-) diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index 38c25090..8de5d215 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -227,49 +227,30 @@ void AnalogAudioView::on_modulation_changed(const ReceiverModel::Mode mode) { // it's being shown or hidden. waterfall.on_hide(); + const auto is_wideband_spectrum_mode = (mode == ReceiverModel::Mode::SpectrumAnalysis); + receiver_model.set_baseband_configuration({ + .mode = toUType(mode), + .sampling_rate = is_wideband_spectrum_mode ? 20000000U : 3072000U, + .decimation_factor = 1, + }); + receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? 12000000 : 1750000); + receiver_model.enable(); + switch(mode) { default: case ReceiverModel::Mode::AMAudio: - receiver_model.set_baseband_configuration({ - .mode = toUType(mode), - .sampling_rate = 3072000, - .decimation_factor = 1, - }); - receiver_model.set_baseband_bandwidth(1750000); - receiver_model.enable(); model.configure_am(0); break; case ReceiverModel::Mode::NarrowbandFMAudio: - receiver_model.set_baseband_configuration({ - .mode = toUType(mode), - .sampling_rate = 3072000, - .decimation_factor = 1, - }); - receiver_model.set_baseband_bandwidth(1750000); - receiver_model.enable(); model.configure_nbfm(0); break; case ReceiverModel::Mode::WidebandFMAudio: - receiver_model.set_baseband_configuration({ - .mode = toUType(mode), - .sampling_rate = 3072000, - .decimation_factor = 1, - }); - receiver_model.set_baseband_bandwidth(1750000); - receiver_model.enable(); model.configure_wfm(); break; case ReceiverModel::Mode::SpectrumAnalysis: - receiver_model.set_baseband_configuration({ - .mode = toUType(mode), - .sampling_rate = 20000000, - .decimation_factor = 1, - }); - receiver_model.set_baseband_bandwidth(12000000); - receiver_model.enable(); break; }