fixing bandwidth application, changed UI a bit (#1158)

* fixxing bandwidth application, moved 'continuous' from config page to main page in form of a 'loop' button. Removed looking glass button as it's not configurable to position on a range/signal
This commit is contained in:
gullradriel 2023-06-16 07:50:04 +02:00 committed by GitHub
parent d29826e6f2
commit 3a5c2da66c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 110 additions and 120 deletions

View File

@ -30,6 +30,12 @@ using portapack::memory::map::backup_ram;
namespace ui { namespace ui {
void ReconView::set_loop_config(bool v) {
continuous = v;
button_loop_config.set_style(v ? &Styles::green : &Styles::white);
persistent_memory::set_recon_continuous(continuous);
}
void ReconView::clear_freqlist_for_ui_action() { void ReconView::clear_freqlist_for_ui_action() {
audio::output::stop(); audio::output::stop();
// flag to detect and reload frequency_list // flag to detect and reload frequency_list
@ -93,9 +99,9 @@ bool ReconView::recon_save_freq(const std::string& freq_file_path, size_t freq_i
auto result = recon_file.open(freq_file_path); // First recon if freq is already in txt auto result = recon_file.open(freq_file_path); // First recon if freq is already in txt
if (!result.is_valid()) { if (!result.is_valid()) {
char one_char[1]; // Read it char by char char one_char[1]{}; // Read it char by char
std::string line; // and put read line in here std::string line{}; // and put read line in here
bool found = false; bool found{false};
for (size_t pointer = 0; pointer < recon_file.size(); pointer++) { for (size_t pointer = 0; pointer < recon_file.size(); pointer++) {
recon_file.seek(pointer); recon_file.seek(pointer);
recon_file.read(one_char, 1); recon_file.read(one_char, 1);
@ -128,16 +134,16 @@ bool ReconView::recon_save_freq(const std::string& freq_file_path, size_t freq_i
} }
bool ReconView::recon_load_config_from_sd() { bool ReconView::recon_load_config_from_sd() {
File settings_file; File settings_file{};
size_t length, file_position = 0; size_t length{0};
char* pos; size_t file_position{0};
char* line_start; char* pos{NULL};
char* line_end; char* line_start{NULL};
char file_data[257]; char* line_end{NULL};
char file_data[257]{};
uint32_t it = 0; uint32_t it{0};
uint32_t nb_params = RECON_SETTINGS_NB_PARAMS; uint32_t nb_params{RECON_SETTINGS_NB_PARAMS};
std::string params[RECON_SETTINGS_NB_PARAMS]; std::string params[RECON_SETTINGS_NB_PARAMS]{};
make_new_directory(u"SETTINGS"); make_new_directory(u"SETTINGS");
@ -297,23 +303,12 @@ void ReconView::handle_retune() {
if (last_entry.modulation != frequency_list[current_index].modulation && frequency_list[current_index].modulation >= 0) { if (last_entry.modulation != frequency_list[current_index].modulation && frequency_list[current_index].modulation >= 0) {
last_entry.modulation = frequency_list[current_index].modulation; last_entry.modulation = frequency_list[current_index].modulation;
field_mode.set_selected_index(frequency_list[current_index].modulation); field_mode.set_selected_index(frequency_list[current_index].modulation);
last_entry.bandwidth = -1;
} }
// Set bandwidth if any // Set bandwidth if any
if (last_entry.bandwidth != frequency_list[current_index].bandwidth && frequency_list[current_index].bandwidth >= 0) { if (last_entry.bandwidth != frequency_list[current_index].bandwidth && frequency_list[current_index].bandwidth >= 0) {
last_entry.bandwidth = frequency_list[current_index].bandwidth; last_entry.bandwidth = frequency_list[current_index].bandwidth;
switch (frequency_list[current_index].modulation) { field_bw.set_selected_index(frequency_list[current_index].bandwidth);
case AM_MODULATION:
receiver_model.set_am_configuration(freq);
break;
case NFM_MODULATION:
receiver_model.set_nbfm_configuration(freq);
break;
case WFM_MODULATION:
receiver_model.set_wfm_configuration(freq);
default:
break;
}
field_bw.set_selected_index(freq);
} }
if (last_entry.step != frequency_list[current_index].step && frequency_list[current_index].step >= 0) { if (last_entry.step != frequency_list[current_index].step && frequency_list[current_index].step >= 0) {
last_entry.step = frequency_list[current_index].step; last_entry.step = frequency_list[current_index].step;
@ -383,7 +378,7 @@ ReconView::ReconView(NavigationView& nav)
&field_lock_wait, &field_lock_wait,
&button_config, &button_config,
&button_scanner_mode, &button_scanner_mode,
&button_looking_glass, &button_loop_config,
&file_name, &file_name,
&rssi, &rssi,
&text_cycle, &text_cycle,
@ -539,10 +534,10 @@ ReconView::ReconView(NavigationView& nav)
nav_.push<AnalogAudioView>(); nav_.push<AnalogAudioView>();
}; };
button_looking_glass.on_select = [this](Button&) { button_loop_config.on_select = [this](Button&) {
nav_.pop(); set_loop_config(!continuous);
nav_.push<GlassView>();
}; };
set_loop_config(continuous);
rssi.set_focusable(true); rssi.set_focusable(true);
rssi.set_peak(true, 500); rssi.set_peak(true, 500);
@ -603,7 +598,7 @@ ReconView::ReconView(NavigationView& nav)
} }
// also remove from output file if in scanner mode // also remove from output file if in scanner mode
if (scanner_mode) { if (scanner_mode) {
File freqman_file; File freqman_file{};
delete_file(freq_file_path); delete_file(freq_file_path);
auto result = freqman_file.create(freq_file_path); auto result = freqman_file.create(freq_file_path);
if (!result.is_valid()) { if (!result.is_valid()) {
@ -616,10 +611,10 @@ ReconView::ReconView(NavigationView& nav)
} }
} else if (manual_mode) // only remove from output } else if (manual_mode) // only remove from output
{ {
File recon_file; File recon_file{};
File tmp_recon_file; File tmp_recon_file{};
std::string tmp_freq_file_path = freq_file_path + ".TMP"; std::string tmp_freq_file_path{freq_file_path + ".TMP"};
std::string frequency_to_add; std::string frequency_to_add{};
freqman_entry entry = frequency_list[current_index]; freqman_entry entry = frequency_list[current_index];
entry.frequency_a = freq; entry.frequency_a = freq;
@ -636,8 +631,8 @@ ReconView::ReconView(NavigationView& nav)
bool found = false; bool found = false;
result = recon_file.open(freq_file_path); // First recon if freq is already in txt result = recon_file.open(freq_file_path); // First recon if freq is already in txt
if (!result.is_valid()) { if (!result.is_valid()) {
char one_char[1]; // Read it char by char char one_char[1]{}; // Read it char by char
std::string line; // and put read line in here std::string line{}; // and put read line in here
for (size_t pointer = 0; pointer < recon_file.size(); pointer++) { for (size_t pointer = 0; pointer < recon_file.size(); pointer++) {
recon_file.seek(pointer); recon_file.seek(pointer);
recon_file.read(one_char, 1); recon_file.read(one_char, 1);
@ -815,7 +810,6 @@ ReconView::ReconView(NavigationView& nav)
autosave = persistent_memory::recon_autosave_freqs(); autosave = persistent_memory::recon_autosave_freqs();
autostart = persistent_memory::recon_autostart_recon(); autostart = persistent_memory::recon_autostart_recon();
continuous = persistent_memory::recon_continuous();
filedelete = persistent_memory::recon_clear_output(); filedelete = persistent_memory::recon_clear_output();
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();
@ -1341,9 +1335,10 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
} }
void ReconView::handle_coded_squelch(const uint32_t value) { void ReconView::handle_coded_squelch(const uint32_t value) {
float diff, min_diff = value; float diff{0.0};
float min_diff{(float)value};
size_t min_idx{0}; size_t min_idx{0};
size_t c; size_t c{0};
if (field_mode.selected_index() != NFM_MODULATION) { if (field_mode.selected_index() != NFM_MODULATION) {
text_ctcss.set(" "); text_ctcss.set(" ");

View File

@ -65,6 +65,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 set_loop_config(bool v);
void clear_freqlist_for_ui_action(); void clear_freqlist_for_ui_action();
void reset_indexes(); void reset_indexes();
void audio_output_start(); void audio_output_start();
@ -84,68 +85,69 @@ class ReconView : public View {
bool recon_load_config_from_sd(); bool recon_load_config_from_sd();
bool recon_save_config_to_sd(); bool recon_save_config_to_sd();
bool recon_save_freq(const std::string& freq_file_path, size_t index, bool warn_if_exists); bool recon_save_freq(const std::string& freq_file_path, size_t index, bool warn_if_exists);
jammer::jammer_range_t frequency_range{false, 0, MAX_UFREQ}; // perfect for manual recon task too... jammer::jammer_range_t frequency_range{false, 0, MAX_UFREQ}; // perfect for manual recon task too...
int32_t squelch{0}; int32_t squelch{0};
int32_t db{0}; int32_t db{0};
int32_t timer{0}; int32_t timer{0};
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 continuous_lock{false}; bool continuous_lock{false};
bool freqlist_cleared_for_ui_action{false}; // flag positioned by ui widgets to manage freqlist unload/load bool freqlist_cleared_for_ui_action{false}; // flag positioned by ui widgets to manage freqlist unload/load
std::string input_file = {"RECON"}; std::string input_file{"RECON"};
std::string output_file = {"RECON_RESULTS"}; std::string output_file{"RECON_RESULTS"};
std::string description = {"...no description..."}; std::string description{"...no description..."};
bool autosave = {true}; bool autosave{true};
bool autostart = {true}; bool autostart{true};
bool continuous = {true}; bool continuous{true};
bool filedelete = {true}; bool filedelete{true};
bool load_freqs = {true}; bool load_freqs{true};
bool load_ranges = {true}; bool load_ranges{true};
bool load_hamradios = {true}; bool load_hamradios{true};
bool update_ranges = {true}; bool update_ranges{true};
bool fwd = {true}; bool fwd{true};
bool recon = true; bool recon{true};
bool user_pause = false; bool user_pause{false};
uint32_t recon_lock_nb_match = {3}; uint32_t recon_lock_nb_match{3};
uint32_t recon_lock_duration = {RECON_MIN_LOCK_DURATION}; uint32_t recon_lock_duration{RECON_MIN_LOCK_DURATION};
uint32_t recon_match_mode = {RECON_MATCH_CONTINUOUS}; uint32_t recon_match_mode{RECON_MATCH_CONTINUOUS};
bool scanner_mode{false}; bool scanner_mode{false};
bool manual_mode{false}; bool manual_mode{false};
bool sd_card_mounted = false; bool sd_card_mounted{false};
int32_t stepper = 0; int32_t stepper{0};
int32_t index_stepper = 0; int32_t index_stepper{0};
int64_t freq = 0; int64_t freq{0};
uint32_t step = 0; uint32_t step{0};
freqman_index_t def_modulation = 0; freqman_index_t def_modulation{0};
freqman_index_t def_bandwidth = 0; freqman_index_t def_bandwidth{0};
freqman_index_t def_step = 0; freqman_index_t def_step{0};
tone_index tone = 0; tone_index tone{0};
freqman_entry last_entry = {}; freqman_entry last_entry{};
bool entry_has_changed = false; bool entry_has_changed{false};
uint32_t freq_lock{0}; uint32_t freq_lock{0};
int64_t minfreq = 0; int64_t minfreq{0};
int64_t maxfreq = 0; int64_t maxfreq{0};
bool has_looped = false; bool has_looped{false};
int8_t status = -1; // 0 recon , 1 locking , 2 locked int8_t status{-1}; // 0 recon , 1 locking , 2 locked
int32_t last_timer = -1; int32_t last_timer{-1};
int8_t last_db = -127; int8_t last_db{-127};
uint16_t last_nb_match = 999; uint16_t last_nb_match{999};
uint16_t last_freq_lock = 999; uint16_t last_freq_lock{999};
size_t last_list_size = 0; size_t last_list_size{0};
int8_t last_rssi_min = -127; int8_t last_rssi_min{-127};
int8_t last_rssi_med = -127; int8_t last_rssi_med{-127};
int8_t last_rssi_max = -127; int8_t last_rssi_max{-127};
int32_t last_index = -1; int32_t last_index{-1};
int32_t last_squelch_index = -1; int32_t last_squelch_index{-1};
int64_t last_freq = 0; int64_t last_freq{0};
std::string freq_file_path = {}; std::string freq_file_path{};
Labels labels{ Labels labels{
{{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Color::light_grey()}, {{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Color::light_grey()},
{{3 * 8, 8 * 16}, "START END", Color::light_grey()}, {{3 * 8, 8 * 16}, "START END", Color::light_grey()},
{{0 * 8, (22 * 8)}, " S: ", Color::light_grey()}, {{0 * 8, (22 * 8)}, " S: ", Color::light_grey()},
{{0 * 8, (24 * 8) + 4}, "NBLCK: x W,L: , ", Color::light_grey()}, {{0 * 8, (24 * 8) + 4}, "NBLCKS:x W,L: , ", Color::light_grey()},
{{0 * 8, (26 * 8) + 4}, "MODE: , SQUELCH: ", Color::light_grey()}}; {{0 * 8, (26 * 8) + 4}, "MODE: , SQUELCH: ", Color::light_grey()}};
LNAGainField field_lna{ LNAGainField field_lna{
@ -160,26 +162,31 @@ class ReconView : public View {
AudioVolumeField field_volume{ AudioVolumeField field_volume{
{24 * 8, 0 * 16}}; {24 * 8, 0 * 16}};
Text file_name{
// show file used
{0, 1 * 16, SCREEN_W, 16},
};
Text desc_cycle{
{0, 2 * 16, SCREEN_W, 16},
};
RSSI rssi{ RSSI rssi{
{0 * 16, 2 * 16 + 2, SCREEN_W - 8 * 8 + 4, 12}, {0 * 16, 3 * 16 + 2, SCREEN_W - 8 * 8 + 4, 12},
}; };
ButtonWithEncoder text_cycle{ ButtonWithEncoder text_cycle{
{0, 3 * 16, 4 * 8, 16}, {0, 4 * 16, 4 * 8, 16},
""}; ""};
// "/XXX -XXX db" => 12 chars max // "/XXX -XXX db" => 12 chars max
Text text_max{ Text text_max{
{4 * 8, 3 * 16, 12 * 8, 16}, {4 * 8, 4 * 16, 12 * 8, 16},
}; };
// "XX/XX" => 5 chars max // "XX/XX" => 5 chars max
Text text_nb_locks{ Text text_nb_locks{
{16 * 8, 3 * 16, 5 * 8, 16}, {16 * 8, 4 * 16, 5 * 8, 16},
};
Text desc_cycle{
{0, 4 * 16, SCREEN_W, 16},
}; };
Text big_display{ Text big_display{
@ -203,23 +210,18 @@ class ReconView : public View {
{14 * 8, 7 * 16, 8 * 8, 1 * 8}, {14 * 8, 7 * 16, 8 * 8, 1 * 8},
""}; ""};
Button button_config{
{SCREEN_W - 7 * 8, 2 * 16, 7 * 8, 28},
"CONFIG"};
Button button_looking_glass{
{SCREEN_W - 7 * 8, 5 * 16, 7 * 8, 28},
"GLASS"};
// Button can be RECON or SCANNER // Button can be RECON or SCANNER
Button button_scanner_mode{ Button button_scanner_mode{
{SCREEN_W - 7 * 8, 7 * 16, 7 * 8, 28}, {SCREEN_W - 7 * 8, 3 * 16, 7 * 8, 28},
"RECON"}; "RECON"};
Text file_name{ Button button_loop_config{
// show file used {SCREEN_W - 7 * 8, 5 * 16, 7 * 8, 28},
{0, 1 * 16, SCREEN_W, 16}, "[LOOP]"};
};
Button button_config{
{SCREEN_W - 7 * 8, 7 * 16, 7 * 8, 28},
"CONFIG"};
ButtonWithEncoder button_manual_start{ ButtonWithEncoder button_manual_start{
{0 * 8, 9 * 16, 11 * 8, 28}, {0 * 8, 9 * 16, 11 * 8, 28},

View File

@ -44,12 +44,10 @@ ReconSetupViewMain::ReconSetupViewMain(NavigationView& nav, Rect parent_rect, st
&button_output_file, &button_output_file,
&checkbox_autosave_freqs, &checkbox_autosave_freqs,
&checkbox_autostart_recon, &checkbox_autostart_recon,
&checkbox_continuous,
&checkbox_clear_output}); &checkbox_clear_output});
checkbox_autosave_freqs.set_value(persistent_memory::recon_autosave_freqs()); checkbox_autosave_freqs.set_value(persistent_memory::recon_autosave_freqs());
checkbox_autostart_recon.set_value(persistent_memory::recon_autostart_recon()); checkbox_autostart_recon.set_value(persistent_memory::recon_autostart_recon());
checkbox_continuous.set_value(persistent_memory::recon_continuous());
checkbox_clear_output.set_value(persistent_memory::recon_clear_output()); checkbox_clear_output.set_value(persistent_memory::recon_clear_output());
text_input_file.set(_input_file); text_input_file.set(_input_file);
@ -96,7 +94,6 @@ ReconSetupViewMain::ReconSetupViewMain(NavigationView& nav, Rect parent_rect, st
void ReconSetupViewMain::save(std::string& input_file, std::string& output_file) { void ReconSetupViewMain::save(std::string& input_file, std::string& output_file) {
persistent_memory::set_recon_autosave_freqs(checkbox_autosave_freqs.value()); persistent_memory::set_recon_autosave_freqs(checkbox_autosave_freqs.value());
persistent_memory::set_recon_autostart_recon(checkbox_autostart_recon.value()); persistent_memory::set_recon_autostart_recon(checkbox_autostart_recon.value());
persistent_memory::set_recon_continuous(checkbox_continuous.value());
persistent_memory::set_recon_clear_output(checkbox_clear_output.value()); persistent_memory::set_recon_clear_output(checkbox_clear_output.value());
input_file = _input_file; input_file = _input_file;
output_file = _output_file; output_file = _output_file;

View File

@ -71,8 +71,8 @@ class ReconSetupViewMain : public View {
void focus() override; void focus() override;
private: private:
std::string _input_file = {"RECON"}; std::string _input_file{"RECON"};
std::string _output_file = {"RECON_RESULTS"}; std::string _output_file{"RECON_RESULTS"};
Button button_load_freqs{ Button button_load_freqs{
{1 * 8, 12, 18 * 8, 22}, {1 * 8, 12, 18 * 8, 22},
@ -98,12 +98,8 @@ class ReconSetupViewMain : public View {
3, 3,
"autostart recon"}; "autostart recon"};
Checkbox checkbox_continuous{
{1 * 8, 11 * 16 - 4},
3,
"continuous"};
Checkbox checkbox_clear_output{ Checkbox checkbox_clear_output{
{1 * 8, 13 * 16 - 4}, {1 * 8, 11 * 16 - 4},
3, 3,
"clear output at start"}; "clear output at start"};
}; };
@ -151,10 +147,10 @@ class ReconSetupView : public View {
private: private:
NavigationView& nav_; NavigationView& nav_;
std::string input_file = {"RECON"}; std::string input_file{"RECON"};
std::string output_file = {"RECON_RESULTS"}; std::string output_file{"RECON_RESULTS"};
Rect view_rect = {0, 3 * 8, SCREEN_W, 230}; Rect view_rect{0, 3 * 8, SCREEN_W, 230};
ReconSetupViewMain viewMain{nav_, view_rect, input_file, output_file}; ReconSetupViewMain viewMain{nav_, view_rect, input_file, output_file};
ReconSetupViewMore viewMore{nav_, view_rect}; ReconSetupViewMore viewMore{nav_, view_rect};