Recon: fixed behavior of auto update m-ranges (#1374) and coloring

* Fixed behavior of auto update m-ranges, added min and max to sd load and save if option not used
* changing xor swap by std::swap
* Fixed consecutive green color
This commit is contained in:
gullradriel 2023-08-15 18:29:16 +02:00 committed by GitHub
parent 09b9ed642f
commit f079d57fc6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 45 additions and 29 deletions

View File

@ -37,6 +37,22 @@ namespace fs = std::filesystem;
namespace ui { namespace ui {
void ReconView::check_update_ranges_from_current() {
if (frequency_list.size() && current_is_valid()) {
if (update_ranges && !manual_mode) {
button_manual_start.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.min = current_entry().frequency_a;
if (current_entry().frequency_b != 0) {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_b));
frequency_range.max = current_entry().frequency_b;
} else {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.max = current_entry().frequency_a;
}
}
}
}
bool ReconView::current_is_valid() { bool ReconView::current_is_valid() {
return (unsigned)current_index < frequency_list.size(); return (unsigned)current_index < frequency_list.size();
} }
@ -193,12 +209,24 @@ bool ReconView::recon_load_config_from_sd() {
break; break;
case 6: case 6:
parse_int(line, wait); parse_int(line, wait);
complete = true; // NB: Last entry. break;
case 7:
if (!update_ranges) {
parse_int(line, frequency_range.min);
button_manual_start.set_text(to_string_short_freq(frequency_range.min));
}
break;
case 8:
if (!update_ranges) {
parse_int(line, frequency_range.max);
button_manual_end.set_text(to_string_short_freq(frequency_range.max));
}
complete = true;
break;
default:
break; break;
} }
if (complete) break; if (complete) break;
line_nb++; line_nb++;
} }
@ -220,6 +248,8 @@ bool ReconView::recon_save_config_to_sd() {
settings_file.write_line(to_string_dec_int(squelch)); settings_file.write_line(to_string_dec_int(squelch));
settings_file.write_line(to_string_dec_uint(recon_match_mode)); settings_file.write_line(to_string_dec_uint(recon_match_mode));
settings_file.write_line(to_string_dec_int(wait)); settings_file.write_line(to_string_dec_int(wait));
settings_file.write_line(to_string_dec_uint(frequency_range.min));
settings_file.write_line(to_string_dec_uint(frequency_range.max));
return true; return true;
} }
@ -290,19 +320,7 @@ void ReconView::handle_retune() {
} }
if (last_index != current_index) { if (last_index != current_index) {
last_index = current_index; last_index = current_index;
if (frequency_list.size() && current_is_valid() && current_entry().type == freqman_type::Range) { check_update_ranges_from_current();
if (update_ranges && !manual_mode) {
button_manual_start.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.min = current_entry().frequency_a;
if (current_entry().frequency_b != 0) {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_b));
frequency_range.max = current_entry().frequency_b;
} else {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.max = current_entry().frequency_a;
}
}
}
text_cycle.set_text(to_string_dec_uint(current_index + 1, 3)); text_cycle.set_text(to_string_dec_uint(current_index + 1, 3));
update_description(); update_description();
} }
@ -562,9 +580,14 @@ ReconView::ReconView(NavigationView& nav)
recon_pause(); recon_pause();
if (!frequency_range.min || !frequency_range.max) { if (!frequency_range.min || !frequency_range.max) {
nav_.display_modal("Error", "Both START and END freqs\nneed a value"); nav_.display_modal("Error", "Both START and END freqs\nneed a value");
} else if (frequency_range.min > frequency_range.max) {
nav_.display_modal("Error", "END freq\nis lower than START");
} else { } else {
if (frequency_range.min > frequency_range.max) {
std::swap(frequency_range.min, frequency_range.max);
button_manual_start.set_text(to_string_short_freq(frequency_range.min));
button_manual_end.set_text(to_string_short_freq(frequency_range.max));
}
// no need to stop audio in SPEC
if (field_mode.selected_index_value() != SPEC_MODULATION) if (field_mode.selected_index_value() != SPEC_MODULATION)
audio::output::stop(); audio::output::stop();
@ -839,17 +862,7 @@ void ReconView::frequency_file_load(bool) {
receiver_model.enable(); receiver_model.enable();
receiver_model.set_squelch_level(0); receiver_model.set_squelch_level(0);
text_cycle.set_text(to_string_dec_uint(current_index + 1, 3)); text_cycle.set_text(to_string_dec_uint(current_index + 1, 3));
if (update_ranges && !manual_mode) { check_update_ranges_from_current();
button_manual_start.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.min = current_entry().frequency_a;
if (current_entry().frequency_b != 0) {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_b));
frequency_range.max = current_entry().frequency_b;
} else {
button_manual_end.set_text(to_string_short_freq(current_entry().frequency_a));
frequency_range.max = current_entry().frequency_a;
}
}
update_description(); update_description();
handle_retune(); handle_retune();
} }
@ -885,6 +898,8 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
if (!timer) { if (!timer) {
status = 0; status = 0;
freq_lock = 0; freq_lock = 0;
last_freq_lock = -1; // need to reset these two as else the green coloration can not occur on consecutive matches
last_nb_match = -1;
timer = local_recon_lock_duration; timer = local_recon_lock_duration;
big_display.set_style(&Styles::white); big_display.set_style(&Styles::white);
} }

View File

@ -70,6 +70,7 @@ class ReconView : public View {
app_settings::SettingsManager settings_{ app_settings::SettingsManager settings_{
"rx_recon", app_settings::Mode::RX}; "rx_recon", app_settings::Mode::RX};
void check_update_ranges_from_current();
void set_loop_config(bool v); void set_loop_config(bool v);
void clear_freqlist_for_ui_action(); void clear_freqlist_for_ui_action();
void reset_indexes(); void reset_indexes();