2022-09-11 10:07:08 -04:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
|
|
|
* Copyright (C) 2016 Furrtek
|
2023-05-22 16:17:28 -04:00
|
|
|
* Copyright (C) 2023 gullradriel, Nilorea Studio Inc.
|
2022-09-11 10:07:08 -04:00
|
|
|
*
|
|
|
|
* This file is part of PortaPack.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; see the file COPYING. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ui_fileman.hpp"
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "ui_navigation.hpp"
|
|
|
|
#include "ui_recon_settings.hpp"
|
2022-09-11 10:07:08 -04:00
|
|
|
#include "ui_textentry.hpp"
|
|
|
|
|
|
|
|
#include "file.hpp"
|
2023-07-11 16:48:36 -04:00
|
|
|
#include "freqman_db.hpp"
|
2022-09-11 10:07:08 -04:00
|
|
|
#include "portapack.hpp"
|
|
|
|
#include "portapack_persistent_memory.hpp"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace portapack;
|
|
|
|
|
|
|
|
namespace ui {
|
|
|
|
|
2023-05-18 16:16:05 -04:00
|
|
|
ReconSetupViewMain::ReconSetupViewMain(NavigationView& nav, Rect parent_rect, std::string input_file, std::string output_file)
|
|
|
|
: View(parent_rect), _input_file{input_file}, _output_file{output_file} {
|
|
|
|
hidden(true);
|
2023-10-30 17:54:37 -04:00
|
|
|
add_children({&button_input_file,
|
2023-05-18 16:16:05 -04:00
|
|
|
&text_input_file,
|
2023-10-30 17:54:37 -04:00
|
|
|
&button_choose_output_file,
|
|
|
|
&button_choose_output_name,
|
2023-05-18 16:16:05 -04:00
|
|
|
&checkbox_autosave_freqs,
|
|
|
|
&checkbox_autostart_recon,
|
|
|
|
&checkbox_clear_output});
|
|
|
|
|
|
|
|
checkbox_autosave_freqs.set_value(persistent_memory::recon_autosave_freqs());
|
|
|
|
checkbox_autostart_recon.set_value(persistent_memory::recon_autostart_recon());
|
|
|
|
checkbox_clear_output.set_value(persistent_memory::recon_clear_output());
|
|
|
|
|
|
|
|
text_input_file.set(_input_file);
|
2023-10-30 17:54:37 -04:00
|
|
|
button_choose_output_name.set_text(_output_file);
|
2023-05-18 16:16:05 -04:00
|
|
|
|
2023-10-30 17:54:37 -04:00
|
|
|
button_input_file.on_select = [this, &nav](Button&) {
|
2023-05-18 16:16:05 -04:00
|
|
|
auto open_view = nav.push<FileLoadView>(".TXT");
|
2023-07-11 16:48:36 -04:00
|
|
|
open_view->push_dir(freqman_dir);
|
2023-05-18 16:16:05 -04:00
|
|
|
open_view->on_changed = [this, &nav](std::filesystem::path new_file_path) {
|
2023-07-11 16:48:36 -04:00
|
|
|
if (new_file_path.native().find(freqman_dir.native()) == 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
_input_file = new_file_path.stem().string();
|
|
|
|
text_input_file.set(_input_file);
|
|
|
|
} else {
|
|
|
|
nav.display_modal("LOAD ERROR", "A valid file from\nFREQMAN directory is\nrequired.");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-10-30 17:54:37 -04:00
|
|
|
button_choose_output_file.on_select = [this, &nav](Button&) {
|
2023-05-18 16:16:05 -04:00
|
|
|
auto open_view = nav.push<FileLoadView>(".TXT");
|
2023-07-29 01:16:49 -04:00
|
|
|
open_view->push_dir(freqman_dir);
|
2023-05-18 16:16:05 -04:00
|
|
|
open_view->on_changed = [this, &nav](std::filesystem::path new_file_path) {
|
2023-07-17 14:43:37 -04:00
|
|
|
if (new_file_path.native().find(freqman_dir.native()) == 0) {
|
2023-05-18 16:16:05 -04:00
|
|
|
_output_file = new_file_path.stem().string();
|
2023-10-30 17:54:37 -04:00
|
|
|
button_choose_output_name.set_text(_output_file);
|
2023-05-18 16:16:05 -04:00
|
|
|
} else {
|
2023-10-30 17:54:37 -04:00
|
|
|
nav.display_modal("SAVE ERROR", "A valid file from\nFREQMAN directory is\nrequired.");
|
2023-05-18 16:16:05 -04:00
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-10-30 17:54:37 -04:00
|
|
|
button_choose_output_name.on_select = [this, &nav](Button&) {
|
|
|
|
text_prompt(nav, _output_file, 28, [this](std::string& buffer) {
|
|
|
|
_output_file = buffer;
|
|
|
|
button_choose_output_name.set_text(_output_file);
|
|
|
|
});
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-05-21 16:31:03 -04:00
|
|
|
void ReconSetupViewMain::save(std::string& input_file, std::string& output_file) {
|
2023-05-18 16:16:05 -04:00
|
|
|
persistent_memory::set_recon_autosave_freqs(checkbox_autosave_freqs.value());
|
|
|
|
persistent_memory::set_recon_autostart_recon(checkbox_autostart_recon.value());
|
|
|
|
persistent_memory::set_recon_clear_output(checkbox_clear_output.value());
|
|
|
|
input_file = _input_file;
|
|
|
|
output_file = _output_file;
|
|
|
|
};
|
2023-06-11 12:49:28 -04:00
|
|
|
void ReconSetupViewMore::save() {
|
2023-05-18 16:16:05 -04:00
|
|
|
persistent_memory::set_recon_load_freqs(checkbox_load_freqs.value());
|
|
|
|
persistent_memory::set_recon_load_ranges(checkbox_load_ranges.value());
|
|
|
|
persistent_memory::set_recon_load_hamradios(checkbox_load_hamradios.value());
|
2023-12-28 05:25:53 -05:00
|
|
|
persistent_memory::set_recon_load_repeaters(checkbox_load_repeaters.value());
|
2023-05-18 16:16:05 -04:00
|
|
|
persistent_memory::set_recon_update_ranges_when_recon(checkbox_update_ranges_when_recon.value());
|
2023-06-25 02:16:49 -04:00
|
|
|
persistent_memory::set_recon_auto_record_locked(checkbox_auto_record_locked.value());
|
2023-12-28 05:25:53 -05:00
|
|
|
persistent_memory::set_recon_repeat_recorded(checkbox_repeat_recorded.value());
|
2024-03-09 19:45:54 -05:00
|
|
|
persistent_memory::set_recon_repeat_recorded_file_mode(field_repeat_file_mode.selected_index_value());
|
2023-12-28 05:25:53 -05:00
|
|
|
persistent_memory::set_recon_repeat_nb(field_repeat_nb.value());
|
|
|
|
persistent_memory::set_recon_repeat_amp(checkbox_repeat_amp.value());
|
|
|
|
persistent_memory::set_recon_repeat_gain(field_repeat_gain.value());
|
2023-12-30 16:32:41 -05:00
|
|
|
persistent_memory::set_recon_repeat_delay(field_repeat_delay.value());
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
void ReconSetupViewMain::focus() {
|
2023-10-30 17:54:37 -04:00
|
|
|
button_input_file.focus();
|
2023-05-18 16:16:05 -04:00
|
|
|
}
|
|
|
|
|
2023-06-11 12:49:28 -04:00
|
|
|
ReconSetupViewMore::ReconSetupViewMore(NavigationView& nav, Rect parent_rect)
|
|
|
|
: View(parent_rect) {
|
2023-05-18 16:16:05 -04:00
|
|
|
(void)nav;
|
|
|
|
hidden(true);
|
|
|
|
|
2023-06-11 12:49:28 -04:00
|
|
|
add_children({&checkbox_load_freqs,
|
2023-12-28 05:25:53 -05:00
|
|
|
&checkbox_load_repeaters,
|
2023-06-11 12:49:28 -04:00
|
|
|
&checkbox_load_ranges,
|
|
|
|
&checkbox_load_hamradios,
|
2023-06-25 02:16:49 -04:00
|
|
|
&checkbox_update_ranges_when_recon,
|
2023-12-28 05:25:53 -05:00
|
|
|
&checkbox_auto_record_locked,
|
|
|
|
&checkbox_repeat_recorded,
|
2024-03-09 19:45:54 -05:00
|
|
|
&field_repeat_file_mode,
|
2023-12-28 05:25:53 -05:00
|
|
|
&text_repeat_nb,
|
|
|
|
&field_repeat_nb,
|
|
|
|
&checkbox_repeat_amp,
|
|
|
|
&text_repeat_gain,
|
2023-12-30 16:32:41 -05:00
|
|
|
&field_repeat_gain,
|
|
|
|
&text_repeat_delay,
|
|
|
|
&field_repeat_delay});
|
2023-12-28 05:25:53 -05:00
|
|
|
|
|
|
|
// tx options have to be in yellow to inform the users that activating them will make the device transmit
|
|
|
|
checkbox_repeat_recorded.set_style(&Styles::yellow);
|
2024-03-09 19:45:54 -05:00
|
|
|
field_repeat_file_mode.set_style(&Styles::yellow);
|
2023-12-28 05:25:53 -05:00
|
|
|
text_repeat_nb.set_style(&Styles::yellow);
|
|
|
|
field_repeat_nb.set_style(&Styles::yellow);
|
|
|
|
checkbox_repeat_amp.set_style(&Styles::yellow);
|
|
|
|
text_repeat_gain.set_style(&Styles::yellow);
|
|
|
|
field_repeat_gain.set_style(&Styles::yellow);
|
2023-12-30 16:32:41 -05:00
|
|
|
text_repeat_delay.set_style(&Styles::yellow);
|
|
|
|
field_repeat_delay.set_style(&Styles::yellow);
|
2023-05-18 16:16:05 -04:00
|
|
|
|
|
|
|
checkbox_load_freqs.set_value(persistent_memory::recon_load_freqs());
|
2023-12-28 05:25:53 -05:00
|
|
|
checkbox_load_repeaters.set_value(persistent_memory::recon_load_repeaters());
|
2023-05-18 16:16:05 -04:00
|
|
|
checkbox_load_ranges.set_value(persistent_memory::recon_load_ranges());
|
|
|
|
checkbox_load_hamradios.set_value(persistent_memory::recon_load_hamradios());
|
|
|
|
checkbox_update_ranges_when_recon.set_value(persistent_memory::recon_update_ranges_when_recon());
|
2023-06-25 02:16:49 -04:00
|
|
|
checkbox_auto_record_locked.set_value(persistent_memory::recon_auto_record_locked());
|
2023-12-28 05:25:53 -05:00
|
|
|
checkbox_repeat_recorded.set_value(persistent_memory::recon_repeat_recorded());
|
2024-03-09 19:45:54 -05:00
|
|
|
field_repeat_file_mode.set_selected_index(persistent_memory::recon_repeat_recorded_file_mode());
|
2023-12-28 05:25:53 -05:00
|
|
|
checkbox_repeat_amp.set_value(persistent_memory::recon_repeat_amp());
|
|
|
|
field_repeat_nb.set_value(persistent_memory::recon_repeat_nb());
|
|
|
|
field_repeat_gain.set_value(persistent_memory::recon_repeat_gain());
|
2023-12-30 16:32:41 -05:00
|
|
|
field_repeat_delay.set_value(persistent_memory::recon_repeat_delay());
|
2023-12-28 05:25:53 -05:00
|
|
|
|
|
|
|
// tx warning modal
|
|
|
|
checkbox_repeat_recorded.on_select = [this, &nav](Checkbox&, bool v) {
|
|
|
|
if (v) {
|
|
|
|
nav.display_modal(
|
|
|
|
"TX WARNING",
|
|
|
|
"This activate TX ability\nin Recon !",
|
|
|
|
YESNO,
|
|
|
|
[this, &nav](bool choice) {
|
|
|
|
if (!choice)
|
|
|
|
checkbox_repeat_recorded.set_value(choice);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
2023-05-18 16:16:05 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
void ReconSetupViewMore::focus() {
|
|
|
|
checkbox_load_freqs.focus();
|
|
|
|
}
|
|
|
|
|
|
|
|
void ReconSetupView::focus() {
|
|
|
|
viewMain.focus();
|
|
|
|
}
|
|
|
|
|
2023-06-11 12:49:28 -04:00
|
|
|
ReconSetupView::ReconSetupView(NavigationView& nav, std::string _input_file, std::string _output_file)
|
|
|
|
: nav_{nav}, input_file{_input_file}, output_file{_output_file} {
|
2023-05-18 16:16:05 -04:00
|
|
|
add_children({&tab_view,
|
|
|
|
&viewMain,
|
|
|
|
&viewMore,
|
|
|
|
&button_save});
|
|
|
|
|
|
|
|
button_save.on_select = [this, &nav](Button&) {
|
2023-05-21 16:31:03 -04:00
|
|
|
viewMain.save(input_file, output_file);
|
2023-06-11 12:49:28 -04:00
|
|
|
viewMore.save();
|
2023-05-18 16:16:05 -04:00
|
|
|
std::vector<std::string> messages;
|
|
|
|
messages.push_back(input_file);
|
|
|
|
messages.push_back(output_file);
|
|
|
|
on_changed(messages);
|
|
|
|
nav.pop();
|
|
|
|
};
|
|
|
|
}
|
2022-09-11 10:07:08 -04:00
|
|
|
} /* namespace ui */
|