mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04: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.on_change = [this](size_t n, OptionsField::value_t v) {
|
||||
(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());
|
||||
@ -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<AISView>();
|
||||
add_child(widget_content.get());
|
||||
break;
|
||||
|
||||
case 5:
|
||||
case ReceiverMode::TPMS:
|
||||
widget_content = std::make_unique<TPMSView>();
|
||||
add_child(widget_content.get());
|
||||
break;
|
||||
|
||||
case 6:
|
||||
case ReceiverMode::ERT:
|
||||
widget_content = std::make_unique<ERTView>();
|
||||
add_child(widget_content.get());
|
||||
break;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user