mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-13 03:34:35 +00:00
Recon: reducing memory imprint, live list removal function in Recon (#1058)
* reducing memory imprint before launching a nav * added remove from loaded list in Recon / delete from output file in Scanner functionality * fix initial color for filename
This commit is contained in:
parent
ffd72eb232
commit
edc6dc819c
@ -30,6 +30,24 @@ using portapack::memory::map::backup_ram;
|
||||
|
||||
namespace ui {
|
||||
|
||||
void ReconView::clear_freqlist_for_ui_action() {
|
||||
audio::output::stop();
|
||||
// flag to detect and reload frequency_list
|
||||
freqlist_cleared_for_ui_action = true;
|
||||
// if in manual mode, there is enough memory to load freqman files, else we have to unload/reload
|
||||
if (!manual_mode) {
|
||||
frequency_list.clear();
|
||||
}
|
||||
}
|
||||
|
||||
void ReconView::reset_indexes() {
|
||||
last_entry.modulation = -1;
|
||||
last_entry.bandwidth = -1;
|
||||
last_entry.step = -1;
|
||||
description = "...no description...";
|
||||
current_index = 0;
|
||||
}
|
||||
|
||||
void ReconView::colorize_waits() {
|
||||
// colorize wait on match
|
||||
if (wait == 0) {
|
||||
@ -367,7 +385,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
&field_squelch,
|
||||
&field_wait,
|
||||
&field_lock_wait,
|
||||
&button_recon_setup,
|
||||
&button_config,
|
||||
&button_scanner_mode,
|
||||
&button_looking_glass,
|
||||
&file_name,
|
||||
@ -429,6 +447,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
}
|
||||
|
||||
button_manual_start.on_select = [this, &nav](ButtonWithEncoder& button) {
|
||||
clear_freqlist_for_ui_action();
|
||||
auto new_view = nav_.push<FrequencyKeypadView>(frequency_range.min);
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
frequency_range.min = f;
|
||||
@ -437,6 +456,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
};
|
||||
|
||||
button_manual_end.on_select = [this, &nav](ButtonWithEncoder& button) {
|
||||
clear_freqlist_for_ui_action();
|
||||
auto new_view = nav.push<FrequencyKeypadView>(frequency_range.max);
|
||||
new_view->on_changed = [this, &button](rf::Frequency f) {
|
||||
frequency_range.max = f;
|
||||
@ -550,7 +570,9 @@ ReconView::ReconView(NavigationView& nav)
|
||||
|
||||
button_remove.on_select = [this](ButtonWithEncoder&) {
|
||||
if (frequency_list.size() > 0) {
|
||||
if (scanner_mode) {
|
||||
if (!manual_mode) {
|
||||
// scanner or recon (!scanner) mode
|
||||
// in both we delete index from live view, but only remove in output file in scanner_mode
|
||||
if (current_index >= (int32_t)frequency_list.size()) {
|
||||
current_index = frequency_list.size() - 1;
|
||||
}
|
||||
@ -576,11 +598,11 @@ ReconView::ReconView(NavigationView& nav)
|
||||
desc_cycle.set("...no description...");
|
||||
}
|
||||
text_cycle.set_text(to_string_dec_uint(current_index + 1, 3));
|
||||
|
||||
}
|
||||
// also remove from output file if in scanner mode
|
||||
if (scanner_mode) {
|
||||
File freqman_file;
|
||||
|
||||
delete_file(freq_file_path);
|
||||
|
||||
auto result = freqman_file.create(freq_file_path);
|
||||
if (!result.is_valid()) {
|
||||
for (size_t n = 0; n < frequency_list.size(); n++) {
|
||||
@ -590,7 +612,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
}
|
||||
}
|
||||
}
|
||||
} else // RECON MODE / MANUAL, only remove matching from output
|
||||
} else if (manual_mode) // only remove from output
|
||||
{
|
||||
File recon_file;
|
||||
File tmp_recon_file;
|
||||
@ -654,6 +676,7 @@ ReconView::ReconView(NavigationView& nav)
|
||||
};
|
||||
|
||||
button_manual_recon.on_select = [this](Button&) {
|
||||
button_remove.set_text("DELETE");
|
||||
scanner_mode = false;
|
||||
manual_mode = true;
|
||||
recon_pause();
|
||||
@ -759,10 +782,12 @@ ReconView::ReconView(NavigationView& nav)
|
||||
scanner_mode = false;
|
||||
button_scanner_mode.set_style(&style_blue);
|
||||
button_scanner_mode.set_text("RECON");
|
||||
button_remove.set_text("DELETE");
|
||||
} else {
|
||||
scanner_mode = true;
|
||||
button_scanner_mode.set_style(&style_red);
|
||||
button_scanner_mode.set_text("SCANNER");
|
||||
button_scanner_mode.set_text("REMOVE");
|
||||
}
|
||||
frequency_file_load(true);
|
||||
if (autostart) {
|
||||
@ -772,10 +797,12 @@ ReconView::ReconView(NavigationView& nav)
|
||||
}
|
||||
};
|
||||
|
||||
button_recon_setup.on_select = [this, &nav](Button&) {
|
||||
audio::output::stop();
|
||||
button_config.on_select = [this, &nav](Button&) {
|
||||
clear_freqlist_for_ui_action();
|
||||
|
||||
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) {
|
||||
freqlist_cleared_for_ui_action = false;
|
||||
input_file = result[0];
|
||||
output_file = result[1];
|
||||
freq_file_path = "/FREQMAN/" + output_file + ".TXT";
|
||||
@ -880,7 +907,6 @@ void ReconView::frequency_file_load(bool stop_all_before) {
|
||||
button_scanner_mode.set_style(&style_blue);
|
||||
button_scanner_mode.set_text("RECON");
|
||||
}
|
||||
file_name.set_style(&style_white);
|
||||
desc_cycle.set_style(&style_white);
|
||||
if (!load_freqman_file_ex(file_input, frequency_list, load_freqs, load_ranges, load_hamradios)) {
|
||||
file_name.set_style(&style_red);
|
||||
@ -934,15 +960,10 @@ void ReconView::frequency_file_load(bool stop_all_before) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
last_entry.modulation = -1;
|
||||
last_entry.bandwidth = -1;
|
||||
last_entry.step = -1;
|
||||
|
||||
reset_indexes();
|
||||
step_mode.set_selected_index(def_step); // Impose the default step into the manual step selector
|
||||
receiver_model.enable();
|
||||
receiver_model.set_squelch_level(0);
|
||||
std::string description = "...no description...";
|
||||
current_index = 0;
|
||||
if (frequency_list.size() != 0) {
|
||||
switch (frequency_list[current_index].type) {
|
||||
case RANGE:
|
||||
@ -976,6 +997,18 @@ void ReconView::frequency_file_load(bool stop_all_before) {
|
||||
}
|
||||
|
||||
void ReconView::on_statistics_update(const ChannelStatistics& statistics) {
|
||||
// hack to reload the list if it was cleared by going into CONFIG
|
||||
if (freqlist_cleared_for_ui_action) {
|
||||
if (!manual_mode) {
|
||||
frequency_file_load(false);
|
||||
}
|
||||
if (autostart) {
|
||||
recon_resume();
|
||||
} else {
|
||||
recon_pause();
|
||||
}
|
||||
freqlist_cleared_for_ui_action = false;
|
||||
}
|
||||
db = statistics.max_db;
|
||||
if (recon) {
|
||||
if (!timer) {
|
||||
|
@ -101,6 +101,8 @@ class ReconView : public View {
|
||||
private:
|
||||
NavigationView& nav_;
|
||||
|
||||
void clear_freqlist_for_ui_action();
|
||||
void reset_indexes();
|
||||
void audio_output_start();
|
||||
bool check_sd_card();
|
||||
size_t change_mode(freqman_index_t mod_type);
|
||||
@ -127,8 +129,10 @@ class ReconView : public View {
|
||||
freqman_db frequency_list = {};
|
||||
int32_t current_index{0};
|
||||
bool continuous_lock{false};
|
||||
bool freqlist_cleared_for_ui_action{false}; // flag positioned by ui widgets to manage freqlist unload/load
|
||||
std::string input_file = {"RECON"};
|
||||
std::string output_file = {"RECON_RESULTS"};
|
||||
std::string description = {"...no description..."};
|
||||
bool autosave = {true};
|
||||
bool autostart = {true};
|
||||
bool continuous = {true};
|
||||
@ -271,7 +275,7 @@ class ReconView : public View {
|
||||
{12 * 8 + 4, 7 * 16, 14 * 8, 1 * 8},
|
||||
""};
|
||||
|
||||
Button button_recon_setup{
|
||||
Button button_config{
|
||||
{SCREEN_W - 7 * 8, 2 * 16, 7 * 8, 28},
|
||||
"CONFIG"};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user