From f05d917a7c80a65337a3005d44cbeea9cd542637 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Wed, 27 Jul 2016 14:51:37 -0700 Subject: [PATCH] ReceiverModel: Use Mode instead of integer. --- firmware/application/analog_audio_app.cpp | 4 ++-- firmware/application/receiver_model.cpp | 8 ++++---- firmware/application/receiver_model.hpp | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/firmware/application/analog_audio_app.cpp b/firmware/application/analog_audio_app.cpp index 9a0d7175..417d1ea1 100644 --- a/firmware/application/analog_audio_app.cpp +++ b/firmware/application/analog_audio_app.cpp @@ -119,7 +119,7 @@ AnalogAudioView::AnalogAudioView( }; const auto modulation = receiver_model.modulation(); - options_modulation.set_by_value(modulation); + options_modulation.set_by_value(toUType(modulation)); options_modulation.on_change = [this](size_t, OptionsField::value_t v) { this->on_modulation_changed(static_cast(v)); }; @@ -286,7 +286,7 @@ void AnalogAudioView::update_modulation(const ReceiverModel::Mode modulation) { baseband::run_image(image_tag); const auto is_wideband_spectrum_mode = (modulation == ReceiverModel::Mode::SpectrumAnalysis); - receiver_model.set_modulation(toUType(modulation)); + receiver_model.set_modulation(modulation); receiver_model.set_sampling_rate(is_wideband_spectrum_mode ? 20000000 : 3072000); receiver_model.set_baseband_bandwidth(is_wideband_spectrum_mode ? 12000000 : 1750000); receiver_model.enable(); diff --git a/firmware/application/receiver_model.cpp b/firmware/application/receiver_model.cpp index f807129e..35059f5c 100644 --- a/firmware/application/receiver_model.cpp +++ b/firmware/application/receiver_model.cpp @@ -124,11 +124,11 @@ void ReceiverModel::set_sampling_rate(uint32_t v) { update_sampling_rate(); } -uint32_t ReceiverModel::modulation() const { +ReceiverModel::Mode ReceiverModel::modulation() const { return mode_; } -void ReceiverModel::set_modulation(const uint32_t v) { +void ReceiverModel::set_modulation(const Mode v) { mode_ = v; update_modulation(); } @@ -171,7 +171,7 @@ void ReceiverModel::disable() { } int32_t ReceiverModel::tuning_offset() { - if( (modulation() == 4) ) { + if( (modulation() == Mode::SpectrumAnalysis) ) { return 0; } else { return -(sampling_rate() / 4); @@ -242,7 +242,7 @@ void ReceiverModel::update_headphone_volume() { } void ReceiverModel::update_modulation() { - switch(static_cast(modulation())) { + switch(modulation()) { default: case Mode::AMAudio: update_am_configuration(); diff --git a/firmware/application/receiver_model.hpp b/firmware/application/receiver_model.hpp index d4ab71b2..a51a4be0 100644 --- a/firmware/application/receiver_model.hpp +++ b/firmware/application/receiver_model.hpp @@ -64,8 +64,8 @@ public: uint32_t sampling_rate() const; void set_sampling_rate(uint32_t v); - uint32_t modulation() const; - void set_modulation(uint32_t v); + Mode modulation() const; + void set_modulation(Mode v); volume_t headphone_volume() const; void set_headphone_volume(volume_t v); @@ -92,7 +92,7 @@ private: int32_t lna_gain_db_ { 32 }; uint32_t baseband_bandwidth_ { max2837::filter::bandwidth_minimum }; int32_t vga_gain_db_ { 32 }; - uint32_t mode_ { 1 }; + Mode mode_ { Mode::NarrowbandFMAudio }; uint32_t sampling_rate_ { 3072000 }; size_t decimation_factor_ { 1 }; size_t am_config_index = 0;