mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2025-07-01 21:58:35 +00:00
Replace receiver mode ordinals with enum.
This commit is contained in:
parent
f15716a06b
commit
c0db15f3e5
@ -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(v);
|
this->on_modulation_changed(static_cast<ReceiverMode>(v));
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
options_baseband_oversampling.set_by_value(receiver_model.baseband_oversampling());
|
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);
|
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!!! */
|
/* TODO: This is TERRIBLE!!! */
|
||||||
switch(modulation) {
|
switch(mode) {
|
||||||
case 3:
|
case ReceiverMode::AIS:
|
||||||
case 5:
|
case ReceiverMode::TPMS:
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
.mode = modulation,
|
.mode = toUType(mode),
|
||||||
.sampling_rate = 2457600,
|
.sampling_rate = 2457600,
|
||||||
.decimation_factor = 4,
|
.decimation_factor = 4,
|
||||||
});
|
});
|
||||||
receiver_model.set_baseband_bandwidth(1750000);
|
receiver_model.set_baseband_bandwidth(1750000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case ReceiverMode::ERT:
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
.mode = modulation,
|
.mode = toUType(mode),
|
||||||
.sampling_rate = 4194304,
|
.sampling_rate = 4194304,
|
||||||
.decimation_factor = 1,
|
.decimation_factor = 1,
|
||||||
});
|
});
|
||||||
receiver_model.set_baseband_bandwidth(1750000);
|
receiver_model.set_baseband_bandwidth(1750000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 4:
|
case ReceiverMode::SpectrumAnalysis:
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
.mode = modulation,
|
.mode = toUType(mode),
|
||||||
.sampling_rate = 20000000,
|
.sampling_rate = 20000000,
|
||||||
.decimation_factor = 1,
|
.decimation_factor = 1,
|
||||||
});
|
});
|
||||||
@ -829,7 +829,7 @@ void ReceiverView::on_modulation_changed(int32_t modulation) {
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
receiver_model.set_baseband_configuration({
|
receiver_model.set_baseband_configuration({
|
||||||
.mode = modulation,
|
.mode = toUType(mode),
|
||||||
.sampling_rate = 3072000,
|
.sampling_rate = 3072000,
|
||||||
.decimation_factor = 4,
|
.decimation_factor = 4,
|
||||||
});
|
});
|
||||||
@ -840,18 +840,18 @@ void ReceiverView::on_modulation_changed(int32_t modulation) {
|
|||||||
remove_child(widget_content.get());
|
remove_child(widget_content.get());
|
||||||
widget_content.reset();
|
widget_content.reset();
|
||||||
|
|
||||||
switch(modulation) {
|
switch(mode) {
|
||||||
case 3:
|
case ReceiverMode::AIS:
|
||||||
widget_content = std::make_unique<AISView>();
|
widget_content = std::make_unique<AISView>();
|
||||||
add_child(widget_content.get());
|
add_child(widget_content.get());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 5:
|
case ReceiverMode::TPMS:
|
||||||
widget_content = std::make_unique<TPMSView>();
|
widget_content = std::make_unique<TPMSView>();
|
||||||
add_child(widget_content.get());
|
add_child(widget_content.get());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 6:
|
case ReceiverMode::ERT:
|
||||||
widget_content = std::make_unique<ERTView>();
|
widget_content = std::make_unique<ERTView>();
|
||||||
add_child(widget_content.get());
|
add_child(widget_content.get());
|
||||||
break;
|
break;
|
||||||
|
@ -357,6 +357,16 @@ 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);
|
||||||
@ -411,14 +421,13 @@ private:
|
|||||||
{ 19 * 8, 1 * 16 },
|
{ 19 * 8, 1 * 16 },
|
||||||
4,
|
4,
|
||||||
{
|
{
|
||||||
// TODO: Put ordinals in here...
|
{ " AM ", toUType(ReceiverMode::AMAudio) },
|
||||||
{ " AM ", 0 },
|
{ "NFM ", toUType(ReceiverMode::NarrowbandFMAudio) },
|
||||||
{ "NFM ", 1 },
|
{ "WFM ", toUType(ReceiverMode::WidebandFMAudio) },
|
||||||
{ "WFM ", 2 },
|
{ "AIS ", toUType(ReceiverMode::AIS) },
|
||||||
{ "AIS ", 3 },
|
{ "TPMS", toUType(ReceiverMode::TPMS) },
|
||||||
{ "TPMS", 5 },
|
{ "ERT", toUType(ReceiverMode::ERT) },
|
||||||
{ "ERT", 6 },
|
{ "SPEC", toUType(ReceiverMode::SpectrumAnalysis) },
|
||||||
{ "SPEC", 4 },
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
@ -465,7 +474,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(int32_t modulation);
|
void on_modulation_changed(ReceiverMode 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);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user