Move ReceiverMode enum to receiver_model.hpp

This commit is contained in:
Jared Boone 2015-12-01 21:00:31 -08:00
parent 74d6518ea1
commit e9bf500bfc
3 changed files with 29 additions and 29 deletions

View File

@ -33,6 +33,16 @@
class ReceiverModel { class ReceiverModel {
public: public:
enum class Mode : int32_t {
AMAudio = 0,
NarrowbandFMAudio = 1,
WidebandFMAudio = 2,
AIS = 3,
SpectrumAnalysis = 4,
TPMS = 5,
ERT = 6,
};
constexpr ReceiverModel( constexpr ReceiverModel(
ClockManager& clock_manager ClockManager& clock_manager
) : clock_manager(clock_manager) ) : clock_manager(clock_manager)

View File

@ -456,7 +456,7 @@ ReceiverView::ReceiverView(
options_modulation.set_by_value(receiver_model.modulation()); options_modulation.set_by_value(receiver_model.modulation());
options_modulation.on_change = [this](size_t n, OptionsField::value_t v) { options_modulation.on_change = [this](size_t n, OptionsField::value_t v) {
(void)n; (void)n;
this->on_modulation_changed(static_cast<ReceiverMode>(v)); this->on_modulation_changed(static_cast<ReceiverModel::Mode>(v));
}; };
/* /*
options_baseband_oversampling.set_by_value(receiver_model.baseband_oversampling()); options_baseband_oversampling.set_by_value(receiver_model.baseband_oversampling());
@ -585,7 +585,7 @@ static ManchesterFormatted format_manchester(
class AnalogAudioModel { class AnalogAudioModel {
public: public:
AnalogAudioModel(ReceiverMode mode) { AnalogAudioModel(ReceiverModel::Mode mode) {
receiver_model.set_baseband_configuration({ receiver_model.set_baseband_configuration({
.mode = toUType(mode), .mode = toUType(mode),
.sampling_rate = 3072000, .sampling_rate = 3072000,
@ -598,7 +598,7 @@ public:
class AnalogAudioView : public spectrum::WaterfallWidget { class AnalogAudioView : public spectrum::WaterfallWidget {
public: public:
AnalogAudioView( AnalogAudioView(
ReceiverMode mode ReceiverModel::Mode mode
) : model { mode } ) : model { mode }
{ {
} }
@ -864,30 +864,30 @@ void ReceiverView::on_vga_changed(int32_t v_db) {
receiver_model.set_vga(v_db); receiver_model.set_vga(v_db);
} }
void ReceiverView::on_modulation_changed(ReceiverMode mode) { void ReceiverView::on_modulation_changed(ReceiverModel::Mode mode) {
remove_child(widget_content.get()); remove_child(widget_content.get());
widget_content.reset(); widget_content.reset();
switch(mode) { switch(mode) {
case ReceiverMode::AMAudio: case ReceiverModel::Mode::AMAudio:
case ReceiverMode::NarrowbandFMAudio: case ReceiverModel::Mode::NarrowbandFMAudio:
case ReceiverMode::WidebandFMAudio: case ReceiverModel::Mode::WidebandFMAudio:
widget_content = std::make_unique<AnalogAudioView>(mode); widget_content = std::make_unique<AnalogAudioView>(mode);
break; break;
case ReceiverMode::AIS: case ReceiverModel::Mode::AIS:
widget_content = std::make_unique<AISView>(); widget_content = std::make_unique<AISView>();
break; break;
case ReceiverMode::SpectrumAnalysis: case ReceiverModel::Mode::SpectrumAnalysis:
widget_content = std::make_unique<SpectrumAnalysisView>(); widget_content = std::make_unique<SpectrumAnalysisView>();
break; break;
case ReceiverMode::TPMS: case ReceiverModel::Mode::TPMS:
widget_content = std::make_unique<TPMSView>(); widget_content = std::make_unique<TPMSView>();
break; break;
case ReceiverMode::ERT: case ReceiverModel::Mode::ERT:
widget_content = std::make_unique<ERTView>(); widget_content = std::make_unique<ERTView>();
break; break;

View File

@ -357,16 +357,6 @@ constexpr Style style_options_group {
.foreground = Color::white(), .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 { class ReceiverView : public View {
public: public:
ReceiverView(NavigationView& nav, ReceiverModel& receiver_model); ReceiverView(NavigationView& nav, ReceiverModel& receiver_model);
@ -421,13 +411,13 @@ private:
{ 19 * 8, 1 * 16 }, { 19 * 8, 1 * 16 },
4, 4,
{ {
{ " AM ", toUType(ReceiverMode::AMAudio) }, { " AM ", toUType(ReceiverModel::Mode::AMAudio) },
{ "NFM ", toUType(ReceiverMode::NarrowbandFMAudio) }, { "NFM ", toUType(ReceiverModel::Mode::NarrowbandFMAudio) },
{ "WFM ", toUType(ReceiverMode::WidebandFMAudio) }, { "WFM ", toUType(ReceiverModel::Mode::WidebandFMAudio) },
{ "AIS ", toUType(ReceiverMode::AIS) }, { "AIS ", toUType(ReceiverModel::Mode::AIS) },
{ "TPMS", toUType(ReceiverMode::TPMS) }, { "TPMS", toUType(ReceiverModel::Mode::TPMS) },
{ "ERT", toUType(ReceiverMode::ERT) }, { "ERT", toUType(ReceiverModel::Mode::ERT) },
{ "SPEC", toUType(ReceiverMode::SpectrumAnalysis) }, { "SPEC", toUType(ReceiverModel::Mode::SpectrumAnalysis) },
} }
}; };
/* /*
@ -474,7 +464,7 @@ private:
void on_rf_amp_changed(bool v); void on_rf_amp_changed(bool v);
void on_lna_changed(int32_t v_db); void on_lna_changed(int32_t v_db);
void on_vga_changed(int32_t v_db); void on_vga_changed(int32_t v_db);
void on_modulation_changed(ReceiverMode mode); void on_modulation_changed(ReceiverModel::Mode mode);
void on_show_options_frequency(); void on_show_options_frequency();
void on_show_options_rf_gain(); void on_show_options_rf_gain();
void on_frequency_step_changed(rf::Frequency f); void on_frequency_step_changed(rf::Frequency f);