fix CONFIG not working if nothing changed and got less flickering by separating text output (#1034)

-fix CONFIG dysfunction if nothing had changed: this was a reminiscence of the nothread conversion
-addressed screen flickering: reduced it by separating two text output
-variables: took out unneeded userpause (reminiscence of the nothread conversion)
-solved problem with manual range not updating description on consecutive clicks
-solved problem with direction changing on 'UNLOCK/SKIPLCK'
This commit is contained in:
gullradriel 2023-05-22 10:49:07 +02:00 committed by GitHub
parent 874d3c251c
commit 80636c53da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 35 deletions

View File

@ -239,18 +239,16 @@ void ReconView::recon_redraw() {
} }
if (last_entry.frequency_a != freq) { if (last_entry.frequency_a != freq) {
last_entry.frequency_a = freq; last_entry.frequency_a = freq;
big_display.set("FREQ: " + to_string_short_freq(freq) + " MHz"); big_display.set("FREQ:" + to_string_short_freq(freq) + " MHz");
} }
if (last_db != db || last_list_size != frequency_list.size() || last_freq_lock != freq_lock || last_nb_match != recon_lock_nb_match) { if (last_nb_match != recon_lock_nb_match || last_freq_lock != freq_lock) {
last_freq_lock = freq; last_freq_lock = freq_lock;
last_list_size = frequency_list.size();
last_db = db;
last_nb_match = recon_lock_nb_match; last_nb_match = recon_lock_nb_match;
text_max.set("/" + to_string_dec_uint(frequency_list.size()) + " " + to_string_dec_int(db) + " db " + to_string_dec_uint(freq_lock) + "/" + to_string_dec_uint(recon_lock_nb_match)); text_nb_locks.set(to_string_dec_uint(freq_lock) + "/" + to_string_dec_uint(recon_lock_nb_match));
if (freq_lock == 0) { if (freq_lock == 0) {
// NO FREQ LOCK, ONGOING STANDARD SCANNING // NO FREQ LOCK, ONGOING STANDARD SCANNING
big_display.set_style(&style_white); big_display.set_style(&style_white);
if (!userpause) if (recon)
button_pause.set_text("<PAUSE>"); button_pause.set_text("<PAUSE>");
else else
button_pause.set_text("<RESUME>"); button_pause.set_text("<RESUME>");
@ -261,13 +259,17 @@ void ReconView::recon_redraw() {
} else if (freq_lock >= recon_lock_nb_match) { } else if (freq_lock >= recon_lock_nb_match) {
big_display.set_style(&style_green); big_display.set_style(&style_green);
button_pause.set_text("<UNLOCK>"); button_pause.set_text("<UNLOCK>");
// FREQ IS STRONG: GREEN and recon will pause when on_statistics_update() // FREQ IS STRONG: GREEN and recon will pause when on_statistics_update()
if ((!scanner_mode) && autosave && frequency_list.size() > 0) { if ((!scanner_mode) && autosave && frequency_list.size() > 0) {
recon_save_freq(freq_file_path, current_index, false); recon_save_freq(freq_file_path, current_index, false);
} }
} }
} }
if (last_db != db || last_list_size != frequency_list.size()) {
last_list_size = frequency_list.size();
last_db = db;
text_max.set("/" + to_string_dec_uint(frequency_list.size()) + " " + to_string_dec_int(db) + " db");
}
} }
void ReconView::handle_retune() { void ReconView::handle_retune() {
@ -305,7 +307,7 @@ void ReconView::handle_retune() {
if (last_index != current_index) { if (last_index != current_index) {
last_index = current_index; last_index = current_index;
if ((int32_t)frequency_list.size() && current_index < (int32_t)frequency_list.size() && frequency_list[current_index].type == RANGE) { if ((int32_t)frequency_list.size() && current_index < (int32_t)frequency_list.size() && frequency_list[current_index].type == RANGE) {
if (update_ranges) { if (update_ranges && !manual_mode) {
button_manual_start.set_text(to_string_short_freq(frequency_list[current_index].frequency_a)); button_manual_start.set_text(to_string_short_freq(frequency_list[current_index].frequency_a));
frequency_range.min = frequency_list[current_index].frequency_a; frequency_range.min = frequency_list[current_index].frequency_a;
if (frequency_list[current_index].frequency_b != 0) { if (frequency_list[current_index].frequency_b != 0) {
@ -371,6 +373,7 @@ ReconView::ReconView(NavigationView& nav)
&rssi, &rssi,
&text_cycle, &text_cycle,
&text_max, &text_max,
&text_nb_locks,
&desc_cycle, &desc_cycle,
&big_display, &big_display,
&freq_stats, &freq_stats,
@ -508,7 +511,7 @@ ReconView::ReconView(NavigationView& nav)
} }
button_pause.set_text("<PAUSE>"); // Show button for non continuous stop button_pause.set_text("<PAUSE>"); // Show button for non continuous stop
} else { } else {
if (userpause) { if (!recon) {
recon_resume(); recon_resume();
} else { } else {
recon_pause(); recon_pause();
@ -653,7 +656,6 @@ ReconView::ReconView(NavigationView& nav)
scanner_mode = false; scanner_mode = false;
manual_mode = true; manual_mode = true;
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) { } else if (frequency_range.min > frequency_range.max) {
@ -668,10 +670,10 @@ ReconView::ReconView(NavigationView& nav)
manual_freq_entry.type = RANGE; manual_freq_entry.type = RANGE;
manual_freq_entry.description = manual_freq_entry.description =
"R " + to_string_short_freq(frequency_range.min) + ">" + to_string_short_freq(frequency_range.max) + " S" // current Manual range to_string_short_freq(frequency_range.min).erase(0, 1) + ">" + to_string_short_freq(frequency_range.max).erase(0, 1) + " S:" // current Manual range
+ to_string_short_freq(freqman_entry_get_step_value(def_step)).erase(0, 1); // euquiq: lame kludge to reduce spacing in step freq + freqman_entry_get_step_string_short(def_step); // euquiq: lame kludge to reduce spacing in step freq
manual_freq_entry.frequency_a = frequency_range.min; // min range val manual_freq_entry.frequency_a = frequency_range.min; // min range val
manual_freq_entry.frequency_b = frequency_range.max; // max range val manual_freq_entry.frequency_b = frequency_range.max; // max range val
manual_freq_entry.modulation = -1; manual_freq_entry.modulation = -1;
manual_freq_entry.bandwidth = -1; manual_freq_entry.bandwidth = -1;
manual_freq_entry.step = def_step; manual_freq_entry.step = def_step;
@ -690,7 +692,11 @@ ReconView::ReconView(NavigationView& nav)
file_name.set_style(&style_white); file_name.set_style(&style_white);
file_name.set("MANUAL RANGE RECON"); file_name.set("MANUAL RANGE RECON");
desc_cycle.set_style(&style_white); desc_cycle.set_style(&style_white);
desc_cycle.set("MANUAL RANGE RECON");
last_entry.modulation = -1;
last_entry.bandwidth = -1;
last_entry.step = -1;
last_index = -1;
current_index = 0; current_index = 0;
freq = manual_freq_entry.frequency_a; freq = manual_freq_entry.frequency_a;
@ -709,7 +715,7 @@ ReconView::ReconView(NavigationView& nav)
button_dir.set_text("FW>"); button_dir.set_text("FW>");
} }
timer = 0; timer = 0;
if (userpause) if (!recon)
recon_resume(); recon_resume();
}; };
@ -767,9 +773,6 @@ ReconView::ReconView(NavigationView& nav)
button_recon_setup.on_select = [this, &nav](Button&) { button_recon_setup.on_select = [this, &nav](Button&) {
audio::output::stop(); audio::output::stop();
frequency_list.clear();
auto open_view = nav.push<ReconSetupView>(input_file, output_file, recon_lock_duration, recon_lock_nb_match, recon_match_mode); auto open_view = nav.push<ReconSetupView>(input_file, output_file, recon_lock_duration, recon_lock_nb_match, recon_match_mode);
open_view->on_changed = [this](std::vector<std::string> result) { open_view->on_changed = [this](std::vector<std::string> result) {
input_file = result[0]; input_file = result[0];
@ -778,7 +781,6 @@ ReconView::ReconView(NavigationView& nav)
recon_lock_duration = strtol(result[2].c_str(), nullptr, 10); recon_lock_duration = strtol(result[2].c_str(), nullptr, 10);
recon_lock_nb_match = strtol(result[3].c_str(), nullptr, 10); recon_lock_nb_match = strtol(result[3].c_str(), nullptr, 10);
recon_match_mode = strtol(result[4].c_str(), nullptr, 10); recon_match_mode = strtol(result[4].c_str(), nullptr, 10);
recon_save_config_to_sd(); recon_save_config_to_sd();
autosave = persistent_memory::recon_autosave_freqs(); autosave = persistent_memory::recon_autosave_freqs();
@ -788,7 +790,6 @@ ReconView::ReconView(NavigationView& nav)
load_freqs = persistent_memory::recon_load_freqs(); load_freqs = persistent_memory::recon_load_freqs();
load_ranges = persistent_memory::recon_load_ranges(); load_ranges = persistent_memory::recon_load_ranges();
load_hamradios = persistent_memory::recon_load_hamradios(); load_hamradios = persistent_memory::recon_load_hamradios();
update_ranges = persistent_memory::recon_update_ranges_when_recon(); update_ranges = persistent_memory::recon_update_ranges_when_recon();
field_wait.set_value(wait); field_wait.set_value(wait);
@ -796,14 +797,12 @@ ReconView::ReconView(NavigationView& nav)
colorize_waits(); colorize_waits();
frequency_file_load(false); frequency_file_load(false);
if (autostart) { if (autostart) {
recon_resume(); recon_resume();
} else { } else {
recon_pause(); recon_pause();
} }
if (userpause != true) {
recon_resume();
}
}; };
}; };
@ -957,7 +956,7 @@ void ReconView::frequency_file_load(bool stop_all_before) {
break; break;
} }
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) { if (update_ranges && !manual_mode) {
button_manual_start.set_text(to_string_short_freq(frequency_list[current_index].frequency_a)); button_manual_start.set_text(to_string_short_freq(frequency_list[current_index].frequency_a));
frequency_range.min = frequency_list[current_index].frequency_a; frequency_range.min = frequency_list[current_index].frequency_a;
if (frequency_list[current_index].frequency_b != 0) { if (frequency_list[current_index].frequency_b != 0) {
@ -977,7 +976,7 @@ void ReconView::frequency_file_load(bool stop_all_before) {
void ReconView::on_statistics_update(const ChannelStatistics& statistics) { void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
db = statistics.max_db; db = statistics.max_db;
if (!userpause) { if (recon) {
if (!timer) { if (!timer) {
status = 0; status = 0;
continuous_lock = false; continuous_lock = false;
@ -1176,7 +1175,6 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
break; break;
} }
} }
// send a pause message with the right freq
if (has_looped && !continuous) { if (has_looped && !continuous) {
recon_pause(); recon_pause();
} }
@ -1194,7 +1192,6 @@ void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
void ReconView::recon_pause() { void ReconView::recon_pause() {
timer = 0; timer = 0;
freq_lock = 0; freq_lock = 0;
userpause = true;
continuous_lock = false; continuous_lock = false;
recon = false; recon = false;
@ -1207,7 +1204,6 @@ void ReconView::recon_pause() {
void ReconView::recon_resume() { void ReconView::recon_resume() {
timer = 0; timer = 0;
freq_lock = 0; freq_lock = 0;
userpause = false;
continuous_lock = false; continuous_lock = false;
recon = true; recon = true;
@ -1221,7 +1217,8 @@ void ReconView::on_index_delta(int32_t v) {
if (v > 0) { if (v > 0) {
fwd = true; fwd = true;
button_dir.set_text("FW>"); button_dir.set_text("FW>");
} else { }
if (v < 0) {
fwd = false; fwd = false;
button_dir.set_text("<RW"); button_dir.set_text("<RW");
} }
@ -1236,7 +1233,8 @@ void ReconView::on_stepper_delta(int32_t v) {
if (v > 0) { if (v > 0) {
fwd = true; fwd = true;
button_dir.set_text("FW>"); button_dir.set_text("FW>");
} else { }
if (v < 0) {
fwd = false; fwd = false;
button_dir.set_text("<RW"); button_dir.set_text("<RW");
} }

View File

@ -125,7 +125,6 @@ class ReconView : public View {
int32_t wait{RECON_DEF_WAIT_DURATION}; // in msec. if > 0 wait duration after a lock, if < 0 duration is set to 'wait' unless there is no more activity int32_t wait{RECON_DEF_WAIT_DURATION}; // in msec. if > 0 wait duration after a lock, if < 0 duration is set to 'wait' unless there is no more activity
freqman_db frequency_list = {}; freqman_db frequency_list = {};
int32_t current_index{0}; int32_t current_index{0};
bool userpause{false};
bool continuous_lock{false}; bool continuous_lock{false};
std::string input_file = {"RECON"}; std::string input_file = {"RECON"};
std::string output_file = {"RECON_RESULTS"}; std::string output_file = {"RECON_RESULTS"};
@ -229,15 +228,21 @@ class ReconView : public View {
}; };
RSSI rssi{ RSSI rssi{
{0 * 16, 2 * 16, SCREEN_W - 8 * 8 + 4, 16}, {0 * 16, 2 * 16, SCREEN_W - 8 * 8 + 4, 14},
}; };
ButtonWithEncoder text_cycle{ ButtonWithEncoder text_cycle{
{0, 3 * 16, 4 * 8, 16}, {0, 3 * 16, 4 * 8, 16},
""}; ""};
// "/XXX -XXX db" => 12 chars max
Text text_max{ Text text_max{
{4 * 8, 3 * 16, SCREEN_W - 7 * 8 - 4 * 8, 16}, {4 * 8, 3 * 16, 12 * 8, 16},
};
// "XX/XX" => 5 chars max
Text text_nb_locks{
{16 * 8, 3 * 16, 5 * 8, 16},
}; };
Text desc_cycle{ Text desc_cycle{