diff --git a/firmware/application/ui_receiver.cpp b/firmware/application/ui_receiver.cpp index f8204607..6fe9b9d0 100644 --- a/firmware/application/ui_receiver.cpp +++ b/firmware/application/ui_receiver.cpp @@ -456,7 +456,7 @@ ReceiverView::ReceiverView( options_modulation.set_by_value(receiver_model.modulation()); options_modulation.on_change = [this](size_t n, OptionsField::value_t v) { (void)n; - this->on_modulation_changed(v); + this->on_modulation_changed(static_cast(v)); }; /* options_baseband_oversampling.set_by_value(receiver_model.baseband_oversampling()); @@ -796,31 +796,31 @@ void ReceiverView::on_vga_changed(int32_t v_db) { receiver_model.set_vga(v_db); } -void ReceiverView::on_modulation_changed(int32_t modulation) { +void ReceiverView::on_modulation_changed(ReceiverMode mode) { /* TODO: This is TERRIBLE!!! */ - switch(modulation) { - case 3: - case 5: + switch(mode) { + case ReceiverMode::AIS: + case ReceiverMode::TPMS: receiver_model.set_baseband_configuration({ - .mode = modulation, + .mode = toUType(mode), .sampling_rate = 2457600, .decimation_factor = 4, }); receiver_model.set_baseband_bandwidth(1750000); break; - case 6: + case ReceiverMode::ERT: receiver_model.set_baseband_configuration({ - .mode = modulation, + .mode = toUType(mode), .sampling_rate = 4194304, .decimation_factor = 1, }); receiver_model.set_baseband_bandwidth(1750000); break; - case 4: + case ReceiverMode::SpectrumAnalysis: receiver_model.set_baseband_configuration({ - .mode = modulation, + .mode = toUType(mode), .sampling_rate = 20000000, .decimation_factor = 1, }); @@ -829,7 +829,7 @@ void ReceiverView::on_modulation_changed(int32_t modulation) { default: receiver_model.set_baseband_configuration({ - .mode = modulation, + .mode = toUType(mode), .sampling_rate = 3072000, .decimation_factor = 4, }); @@ -840,18 +840,18 @@ void ReceiverView::on_modulation_changed(int32_t modulation) { remove_child(widget_content.get()); widget_content.reset(); - switch(modulation) { - case 3: + switch(mode) { + case ReceiverMode::AIS: widget_content = std::make_unique(); add_child(widget_content.get()); break; - case 5: + case ReceiverMode::TPMS: widget_content = std::make_unique(); add_child(widget_content.get()); break; - case 6: + case ReceiverMode::ERT: widget_content = std::make_unique(); add_child(widget_content.get()); break; diff --git a/firmware/application/ui_receiver.hpp b/firmware/application/ui_receiver.hpp index 65e97f04..9827cdc7 100644 --- a/firmware/application/ui_receiver.hpp +++ b/firmware/application/ui_receiver.hpp @@ -357,6 +357,16 @@ constexpr Style style_options_group { .foreground = Color::white(), }; +enum class ReceiverMode : int32_t { + AMAudio = 0, + NarrowbandFMAudio = 1, + WidebandFMAudio = 2, + AIS = 3, + SpectrumAnalysis = 4, + TPMS = 5, + ERT = 6, +}; + class ReceiverView : public View { public: ReceiverView(NavigationView& nav, ReceiverModel& receiver_model); @@ -411,14 +421,13 @@ private: { 19 * 8, 1 * 16 }, 4, { - // TODO: Put ordinals in here... - { " AM ", 0 }, - { "NFM ", 1 }, - { "WFM ", 2 }, - { "AIS ", 3 }, - { "TPMS", 5 }, - { "ERT", 6 }, - { "SPEC", 4 }, + { " AM ", toUType(ReceiverMode::AMAudio) }, + { "NFM ", toUType(ReceiverMode::NarrowbandFMAudio) }, + { "WFM ", toUType(ReceiverMode::WidebandFMAudio) }, + { "AIS ", toUType(ReceiverMode::AIS) }, + { "TPMS", toUType(ReceiverMode::TPMS) }, + { "ERT", toUType(ReceiverMode::ERT) }, + { "SPEC", toUType(ReceiverMode::SpectrumAnalysis) }, } }; /* @@ -465,7 +474,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 modulation); + void on_modulation_changed(ReceiverMode mode); void on_show_options_frequency(); void on_show_options_rf_gain(); void on_frequency_step_changed(rf::Frequency f);