Skip to content

Commit

Permalink
save and restore region and or manual frequency values (#2340)
Browse files Browse the repository at this point in the history
  • Loading branch information
gullradriel authored Nov 5, 2024
1 parent da53227 commit 110a543
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 16 deletions.
32 changes: 26 additions & 6 deletions firmware/application/apps/ui_aprs_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,21 +94,39 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect)
record_view.set_sampling_rate(24000);

options_region.on_change = [this](size_t, int32_t i) {
if (i == 0) {
field_frequency.on_change = [this](rf::Frequency f) { (void)f; };
if (i == 0) { // MAN Manual setting
field_frequency.set_value(aprs_rx_freq);
} else if (i == 1) { // NA - North America - is also the default
field_frequency.set_value(144390000);
} else if (i == 1) {
} else if (i == 2) { // EUR
field_frequency.set_value(144800000);
} else if (i == 2) {
} else if (i == 3) { // AUS
field_frequency.set_value(145175000);
} else if (i == 3) {
} else if (i == 4) { // NZ
field_frequency.set_value(144575000);
} else if (i == 4) {
} else if (i == 5) { // ISS
field_frequency.set_value(145825000);
}
options_region_id = i;
receiver_model.set_target_frequency(field_frequency.value()); // Retune
field_frequency.on_change = [this](rf::Frequency f) {
aprs_rx_freq = f;
options_region.set_selected_index(0, true);
};
};

field_frequency.set_step(100);
options_region.set_selected_index(0, true);
field_frequency.on_edit = [this]() {
auto freq_view = nav_.push<FrequencyKeypadView>(field_frequency.value());
freq_view->on_changed = [this](rf::Frequency f) {
aprs_rx_freq = f;
field_frequency.set_value(f);
};
};

// Note: setting the region is also going to sef field_frequency.on_change
options_region.set_selected_index(options_region_id, true);

logger = std::make_unique<APRSLogger>();
if (logger)
Expand All @@ -124,6 +142,8 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect)

void APRSRxView::on_freqchg(int64_t freq) {
field_frequency.set_value(freq);
aprs_rx_freq = freq;
options_region.set_selected_index(0, true);
}

void APRSRxView::on_packet(const APRSPacketMessage* message) {
Expand Down
25 changes: 15 additions & 10 deletions firmware/application/apps/ui_aprs_rx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ class APRSRxView : public View {
private:
void on_data(uint32_t value, bool is_data);
bool reset_console = false;
uint8_t options_region_id = 1; // default to North America
rf::Frequency aprs_rx_freq{144390000}; // default to North America frequency

NavigationView& nav_;
RxRadioState radio_state_{
Expand All @@ -198,7 +200,10 @@ class APRSRxView : public View {
3072000 /* sampling rate */
};
app_settings::SettingsManager settings_{
"rx_aprs", app_settings::Mode::RX};
"rx_aprs",
app_settings::Mode::RX,
{{"options_region_id"sv, &options_region_id},
{"aprs_rx_freq"sv, &aprs_rx_freq}}};

uint8_t console_color{0};
std::string str_log{""};
Expand All @@ -220,15 +225,15 @@ class APRSRxView : public View {
OptionsField options_region{
{0 * 8, 0 * 8},
3,
{{"NA ", 0},
{"EUR", 1},
{"AUS", 2},
{"NZ ", 3},
{"ISS", 4}}};

RxFrequencyField field_frequency{
{3 * 8, 0 * 16},
nav_};
{{"MAN", 0},
{"NA ", 1},
{"EUR", 2},
{"AUS", 3},
{"NZ ", 4},
{"ISS", 5}}};

FrequencyField field_frequency{
{3 * 8, 0 * 16}};

// DEBUG
RecordView record_view{
Expand Down

0 comments on commit 110a543

Please sign in to comment.