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 {
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() {
audio::output::stop();
// 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
if (!result.is_valid()) {
char one_char[1]; // Read it char by char
std::string line; // and put read line in here
bool found = false;
char one_char[1]{}; // Read it char by char
std::string line{}; // and put read line in here
bool found{false};
for (size_t pointer = 0; pointer < recon_file.size(); pointer++) {
recon_file.seek(pointer);
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() {
File settings_file;
size_t length, file_position = 0;
char* pos;
char* line_start;
char* line_end;
char file_data[257];
uint32_t it = 0;
uint32_t nb_params = RECON_SETTINGS_NB_PARAMS;
std::string params[RECON_SETTINGS_NB_PARAMS];
File settings_file{};
size_t length{0};
size_t file_position{0};
char* pos{NULL};
char* line_start{NULL};
char* line_end{NULL};
char file_data[257]{};
uint32_t it{0};
uint32_t nb_params{RECON_SETTINGS_NB_PARAMS};
std::string params[RECON_SETTINGS_NB_PARAMS]{};
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) {
last_entry.modulation = frequency_list[current_index].modulation;
field_mode.set_selected_index(frequency_list[current_index].modulation);
last_entry.bandwidth = -1;
}
// Set bandwidth if any
if (last_entry.bandwidth != frequency_list[current_index].bandwidth && frequency_list[current_index].bandwidth >= 0) {
last_entry.bandwidth = frequency_list[current_index].bandwidth;
switch (frequency_list[current_index].modulation) {
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);
field_bw.set_selected_index(frequency_list[current_index].bandwidth);
}
if (last_entry.step != frequency_list[current_index].step && frequency_list[current_index].step >= 0) {
last_entry.step = frequency_list[current_index].step;
@ -383,7 +378,7 @@ ReconView::ReconView(NavigationView& nav)
&field_lock_wait,
&button_config,
&button_scanner_mode,
&button_looking_glass,
&button_loop_config,
&file_name,
&rssi,
&text_cycle,
@ -539,10 +534,10 @@ ReconView::ReconView(NavigationView& nav)
nav_.push<AnalogAudioView>();
};
button_looking_glass.on_select = [this](Button&) {
nav_.pop();
nav_.push<GlassView>();
button_loop_config.on_select = [this](Button&) {
set_loop_config(!continuous);
};
set_loop_config(continuous);
rssi.set_focusable(true);
rssi.set_peak(true, 500);
@ -603,7 +598,7 @@ ReconView::ReconView(NavigationView& nav)
}
// also remove from output file if in scanner mode
if (scanner_mode) {
File freqman_file;
File freqman_file{};
delete_file(freq_file_path);
auto result = freqman_file.create(freq_file_path);
if (!result.is_valid()) {
@ -616,10 +611,10 @@ ReconView::ReconView(NavigationView& nav)
}
} else if (manual_mode) // only remove from output
{
File recon_file;
File tmp_recon_file;
std::string tmp_freq_file_path = freq_file_path + ".TMP";
std::string frequency_to_add;
File recon_file{};
File tmp_recon_file{};
std::string tmp_freq_file_path{freq_file_path + ".TMP"};
std::string frequency_to_add{};
freqman_entry entry = frequency_list[current_index];
entry.frequency_a = freq;
@ -636,8 +631,8 @@ ReconView::ReconView(NavigationView& nav)
bool found = false;
result = recon_file.open(freq_file_path); // First recon if freq is already in txt
if (!result.is_valid()) {
char one_char[1]; // Read it char by char
std::string line; // and put read line in here
char one_char[1]{}; // Read it char by char
std::string line{}; // and put read line in here
for (size_t pointer = 0; pointer < recon_file.size(); pointer++) {
recon_file.seek(pointer);
recon_file.read(one_char, 1);
@ -815,7 +810,6 @@ ReconView::ReconView(NavigationView& nav)
autosave = persistent_memory::recon_autosave_freqs();
autostart = persistent_memory::recon_autostart_recon();
continuous = persistent_memory::recon_continuous();
filedelete = persistent_memory::recon_clear_output();
load_freqs = persistent_memory::recon_load_freqs();
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) {
float diff, min_diff = value;
float diff{0.0};
float min_diff{(float)value};
size_t min_idx{0};
size_t c;
size_t c{0};
if (field_mode.selected_index() != NFM_MODULATION) {
text_ctcss.set(" ");

View File

@ -65,6 +65,7 @@ class ReconView : public View {
app_settings::SettingsManager settings_{
"rx_recon", app_settings::Mode::RX};
void set_loop_config(bool v);
void clear_freqlist_for_ui_action();
void reset_indexes();
void audio_output_start();
@ -84,68 +85,69 @@ class ReconView : public View {
bool recon_load_config_from_sd();
bool recon_save_config_to_sd();
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...
int32_t squelch{0};
int32_t db{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
freqman_db frequency_list = {};
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};
bool filedelete = {true};
bool load_freqs = {true};
bool load_ranges = {true};
bool load_hamradios = {true};
bool update_ranges = {true};
bool fwd = {true};
bool recon = true;
bool user_pause = false;
uint32_t recon_lock_nb_match = {3};
uint32_t recon_lock_duration = {RECON_MIN_LOCK_DURATION};
uint32_t recon_match_mode = {RECON_MATCH_CONTINUOUS};
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};
bool filedelete{true};
bool load_freqs{true};
bool load_ranges{true};
bool load_hamradios{true};
bool update_ranges{true};
bool fwd{true};
bool recon{true};
bool user_pause{false};
uint32_t recon_lock_nb_match{3};
uint32_t recon_lock_duration{RECON_MIN_LOCK_DURATION};
uint32_t recon_match_mode{RECON_MATCH_CONTINUOUS};
bool scanner_mode{false};
bool manual_mode{false};
bool sd_card_mounted = false;
int32_t stepper = 0;
int32_t index_stepper = 0;
int64_t freq = 0;
uint32_t step = 0;
freqman_index_t def_modulation = 0;
freqman_index_t def_bandwidth = 0;
freqman_index_t def_step = 0;
tone_index tone = 0;
freqman_entry last_entry = {};
bool entry_has_changed = false;
bool sd_card_mounted{false};
int32_t stepper{0};
int32_t index_stepper{0};
int64_t freq{0};
uint32_t step{0};
freqman_index_t def_modulation{0};
freqman_index_t def_bandwidth{0};
freqman_index_t def_step{0};
tone_index tone{0};
freqman_entry last_entry{};
bool entry_has_changed{false};
uint32_t freq_lock{0};
int64_t minfreq = 0;
int64_t maxfreq = 0;
bool has_looped = false;
int8_t status = -1; // 0 recon , 1 locking , 2 locked
int32_t last_timer = -1;
int8_t last_db = -127;
uint16_t last_nb_match = 999;
uint16_t last_freq_lock = 999;
size_t last_list_size = 0;
int8_t last_rssi_min = -127;
int8_t last_rssi_med = -127;
int8_t last_rssi_max = -127;
int32_t last_index = -1;
int32_t last_squelch_index = -1;
int64_t last_freq = 0;
std::string freq_file_path = {};
int64_t minfreq{0};
int64_t maxfreq{0};
bool has_looped{false};
int8_t status{-1}; // 0 recon , 1 locking , 2 locked
int32_t last_timer{-1};
int8_t last_db{-127};
uint16_t last_nb_match{999};
uint16_t last_freq_lock{999};
size_t last_list_size{0};
int8_t last_rssi_min{-127};
int8_t last_rssi_med{-127};
int8_t last_rssi_max{-127};
int32_t last_index{-1};
int32_t last_squelch_index{-1};
int64_t last_freq{0};
std::string freq_file_path{};
Labels labels{
{{0 * 8, 0 * 16}, "LNA: VGA: AMP: VOL: ", Color::light_grey()},
{{3 * 8, 8 * 16}, "START END", 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()}};
LNAGainField field_lna{
@ -160,26 +162,31 @@ class ReconView : public View {
AudioVolumeField field_volume{
{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{
{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{
{0, 3 * 16, 4 * 8, 16},
{0, 4 * 16, 4 * 8, 16},
""};
// "/XXX -XXX db" => 12 chars max
Text text_max{
{4 * 8, 3 * 16, 12 * 8, 16},
{4 * 8, 4 * 16, 12 * 8, 16},
};
// "XX/XX" => 5 chars max
Text text_nb_locks{
{16 * 8, 3 * 16, 5 * 8, 16},
};
Text desc_cycle{
{0, 4 * 16, SCREEN_W, 16},
{16 * 8, 4 * 16, 5 * 8, 16},
};
Text big_display{
@ -203,23 +210,18 @@ class ReconView : public View {
{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 button_scanner_mode{
{SCREEN_W - 7 * 8, 7 * 16, 7 * 8, 28},
{SCREEN_W - 7 * 8, 3 * 16, 7 * 8, 28},
"RECON"};
Text file_name{
// show file used
{0, 1 * 16, SCREEN_W, 16},
};
Button button_loop_config{
{SCREEN_W - 7 * 8, 5 * 16, 7 * 8, 28},
"[LOOP]"};
Button button_config{
{SCREEN_W - 7 * 8, 7 * 16, 7 * 8, 28},
"CONFIG"};
ButtonWithEncoder button_manual_start{
{0 * 8, 9 * 16, 11 * 8, 28},

View File

@ -44,12 +44,10 @@ ReconSetupViewMain::ReconSetupViewMain(NavigationView& nav, Rect parent_rect, st
&button_output_file,
&checkbox_autosave_freqs,
&checkbox_autostart_recon,
&checkbox_continuous,
&checkbox_clear_output});
checkbox_autosave_freqs.set_value(persistent_memory::recon_autosave_freqs());
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());
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) {
persistent_memory::set_recon_autosave_freqs(checkbox_autosave_freqs.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());
input_file = _input_file;
output_file = _output_file;

View File

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