mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-10-01 01:26:06 -04:00
Recon repeat auto recorded file mode (#1960)
* added everything needed to have a repeated file mode option to keep or delete files * automatic filename for keep file * fixing restart after replay * fixed auto record replay/repeat restart --------- Co-authored-by: GullCode <gullradriel@hotmail.com>
This commit is contained in:
parent
e496f8ecc2
commit
160a778104
@ -49,7 +49,13 @@ namespace fs = std::filesystem;
|
||||
namespace ui {
|
||||
|
||||
void ReconView::reload_restart_recon() {
|
||||
// force reload of current
|
||||
change_mode(field_mode.selected_index_value());
|
||||
uint8_t previous_index = current_index;
|
||||
reset_indexes();
|
||||
frequency_file_load();
|
||||
current_index = previous_index;
|
||||
handle_retune();
|
||||
if (frequency_list.size() > 0) {
|
||||
if (fwd) {
|
||||
button_dir.set_text("FW>");
|
||||
@ -104,18 +110,19 @@ void ReconView::set_loop_config(bool v) {
|
||||
|
||||
void ReconView::recon_stop_recording(bool exiting) {
|
||||
if (is_recording) {
|
||||
if (field_mode.selected_index_value() == SPEC_MODULATION)
|
||||
button_audio_app.set_text("RAW");
|
||||
else
|
||||
button_audio_app.set_text("AUDIO");
|
||||
button_audio_app.set_style(&Styles::white);
|
||||
record_view->stop();
|
||||
button_config.set_style(&Styles::white);
|
||||
is_recording = false;
|
||||
// repeater mode
|
||||
if (!exiting && persistent_memory::recon_repeat_recorded()) {
|
||||
start_repeat();
|
||||
if (field_mode.selected_index_value() == SPEC_MODULATION) {
|
||||
button_audio_app.set_text("RAW");
|
||||
// repeater mode
|
||||
if (!exiting && persistent_memory::recon_repeat_recorded()) {
|
||||
start_repeat();
|
||||
}
|
||||
} else {
|
||||
button_audio_app.set_text("AUDIO");
|
||||
}
|
||||
button_audio_app.set_style(&Styles::white);
|
||||
button_config.set_style(&Styles::white);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1148,7 +1155,7 @@ void ReconView::on_stepper_delta(int32_t v) {
|
||||
}
|
||||
|
||||
size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
if (recon_tx || is_repeat_active())
|
||||
if (recon_tx || is_repeat_active() || is_recording)
|
||||
return 0;
|
||||
field_mode.on_change = [this](size_t, OptionsField::value_t) {};
|
||||
field_bw.on_change = [this](size_t, OptionsField::value_t) {};
|
||||
@ -1157,16 +1164,21 @@ size_t ReconView::change_mode(freqman_index_t new_mod) {
|
||||
remove_child(record_view.get());
|
||||
record_view.reset();
|
||||
}
|
||||
if (persistent_memory::recon_repeat_recorded()) {
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"RECON_REPEAT.C16", u"CAPTURES",
|
||||
RecordView::FileType::RawS16, 16384, 3);
|
||||
record_view->set_filename_as_is(true);
|
||||
} else if (new_mod == SPEC_MODULATION) {
|
||||
if (field_mode.selected_index_value() != SPEC_MODULATION) {
|
||||
audio::output::stop();
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_RAW", u"CAPTURES",
|
||||
RecordView::FileType::RawS16, 16384, 3);
|
||||
}
|
||||
if (new_mod == SPEC_MODULATION) {
|
||||
if (persistent_memory::recon_repeat_recorded()) {
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"RECON_REPEAT.C16", u"CAPTURES",
|
||||
RecordView::FileType::RawS16, 16384, 3);
|
||||
record_view->set_filename_as_is(true);
|
||||
} else {
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_RAW", u"CAPTURES",
|
||||
RecordView::FileType::RawS16, 16384, 3);
|
||||
record_view->set_filename_date_frequency(true);
|
||||
}
|
||||
} else {
|
||||
record_view = std::make_unique<RecordView>(Rect{0, 0, 30 * 8, 1 * 16},
|
||||
u"AUTO_AUDIO", u"AUDIO",
|
||||
@ -1314,9 +1326,6 @@ bool ReconView::is_repeat_active() const {
|
||||
|
||||
void ReconView::start_repeat() {
|
||||
// Prepare to send a file.
|
||||
std::filesystem::path rawfile = u"/" + repeat_rec_path + u"/" + repeat_rec_file;
|
||||
std::filesystem::path rawmeta = u"/" + repeat_rec_path + u"/" + repeat_rec_meta;
|
||||
|
||||
if (recon_tx == false) {
|
||||
recon_tx = true;
|
||||
|
||||
@ -1434,6 +1443,12 @@ void ReconView::stop_repeat(const bool do_loop) {
|
||||
} else {
|
||||
repeat_cur_rep = 0;
|
||||
recon_tx = false;
|
||||
if (persistent_memory::recon_repeat_recorded_file_mode() == RECON_REPEAT_AND_KEEP) {
|
||||
// rename file here to keep
|
||||
std::filesystem::path base_path = next_filename_matching_pattern(repeat_rec_path / u"REC_????.*");
|
||||
rename_file(rawfile, base_path.replace_extension(u".C16"));
|
||||
rename_file(rawmeta, base_path.replace_extension(u".TXT"));
|
||||
}
|
||||
reload_restart_recon();
|
||||
progressbar.hidden(true);
|
||||
set_dirty(); // fix progressbar no hiding
|
||||
|
@ -198,6 +198,9 @@ class ReconView : public View {
|
||||
bool repeat_ready_signal{false};
|
||||
bool recon_tx{false};
|
||||
|
||||
std::filesystem::path rawfile = u"/" + repeat_rec_path + u"/" + repeat_rec_file;
|
||||
std::filesystem::path rawmeta = u"/" + repeat_rec_path + u"/" + repeat_rec_meta;
|
||||
|
||||
// Persisted settings.
|
||||
SettingsStore ui_settings{
|
||||
"recon"sv,
|
||||
|
@ -103,6 +103,7 @@ void ReconSetupViewMore::save() {
|
||||
persistent_memory::set_recon_update_ranges_when_recon(checkbox_update_ranges_when_recon.value());
|
||||
persistent_memory::set_recon_auto_record_locked(checkbox_auto_record_locked.value());
|
||||
persistent_memory::set_recon_repeat_recorded(checkbox_repeat_recorded.value());
|
||||
persistent_memory::set_recon_repeat_recorded_file_mode(field_repeat_file_mode.selected_index_value());
|
||||
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());
|
||||
@ -125,6 +126,7 @@ ReconSetupViewMore::ReconSetupViewMore(NavigationView& nav, Rect parent_rect)
|
||||
&checkbox_update_ranges_when_recon,
|
||||
&checkbox_auto_record_locked,
|
||||
&checkbox_repeat_recorded,
|
||||
&field_repeat_file_mode,
|
||||
&text_repeat_nb,
|
||||
&field_repeat_nb,
|
||||
&checkbox_repeat_amp,
|
||||
@ -135,6 +137,7 @@ ReconSetupViewMore::ReconSetupViewMore(NavigationView& nav, Rect parent_rect)
|
||||
|
||||
// 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);
|
||||
field_repeat_file_mode.set_style(&Styles::yellow);
|
||||
text_repeat_nb.set_style(&Styles::yellow);
|
||||
field_repeat_nb.set_style(&Styles::yellow);
|
||||
checkbox_repeat_amp.set_style(&Styles::yellow);
|
||||
@ -150,6 +153,7 @@ ReconSetupViewMore::ReconSetupViewMore(NavigationView& nav, Rect parent_rect)
|
||||
checkbox_update_ranges_when_recon.set_value(persistent_memory::recon_update_ranges_when_recon());
|
||||
checkbox_auto_record_locked.set_value(persistent_memory::recon_auto_record_locked());
|
||||
checkbox_repeat_recorded.set_value(persistent_memory::recon_repeat_recorded());
|
||||
field_repeat_file_mode.set_selected_index(persistent_memory::recon_repeat_recorded_file_mode());
|
||||
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());
|
||||
|
@ -38,16 +38,19 @@
|
||||
#endif
|
||||
#define OneMHz 1000000
|
||||
|
||||
// modes
|
||||
// main app mode
|
||||
#define RECON_MATCH_CONTINUOUS 0
|
||||
#define RECON_MATCH_SPARSE 1
|
||||
|
||||
// repeater mode
|
||||
#define RECON_REPEAT_AND_DELETE 0
|
||||
#define RECON_REPEAT_AND_KEEP 1
|
||||
|
||||
// statistics update interval in ms (change here if the statistics API is changing it's pace)
|
||||
#define STATS_UPDATE_INTERVAL 100
|
||||
|
||||
// maximum lock duration
|
||||
#define RECON_MAX_LOCK_DURATION 9900
|
||||
|
||||
#define RECON_DEF_SQUELCH -14
|
||||
|
||||
// default number of match to have a lock
|
||||
@ -150,15 +153,21 @@ class ReconSetupViewMore : public View {
|
||||
|
||||
Checkbox checkbox_repeat_recorded{
|
||||
{1 * 8, 162},
|
||||
3,
|
||||
"repeater,"};
|
||||
0,
|
||||
""};
|
||||
|
||||
OptionsField field_repeat_file_mode{
|
||||
{4 * 8 + 3, 165},
|
||||
13,
|
||||
{{"repeat,delete", RECON_REPEAT_AND_DELETE},
|
||||
{"repeat,keep ", RECON_REPEAT_AND_KEEP}}};
|
||||
|
||||
Text text_repeat_nb{
|
||||
{14 * 8, 165, 3 * 8, 22},
|
||||
{20 * 8, 165, 3 * 8, 22},
|
||||
"nb:"};
|
||||
|
||||
NumberField field_repeat_nb{
|
||||
{17 * 8, 165},
|
||||
{23 * 8, 165},
|
||||
2,
|
||||
{1, 99},
|
||||
1,
|
||||
|
@ -435,6 +435,7 @@ void defaults() {
|
||||
set_recon_load_hamradios(true);
|
||||
set_recon_match_mode(0);
|
||||
set_recon_repeat_recorded(false);
|
||||
set_recon_repeat_recorded_file_mode(false); // false delete repeater , true keep repeated
|
||||
set_recon_repeat_amp(false);
|
||||
set_recon_repeat_gain(35);
|
||||
set_recon_repeat_nb(3);
|
||||
@ -832,7 +833,9 @@ bool recon_repeat_amp() {
|
||||
bool recon_load_repeaters() {
|
||||
return (data->recon_config & 0x00080000UL) ? true : false;
|
||||
}
|
||||
|
||||
bool recon_repeat_recorded_file_mode() {
|
||||
return (data->recon_config & 0x00040000UL) ? true : false;
|
||||
}
|
||||
void set_recon_autosave_freqs(const bool v) {
|
||||
data->recon_config = (data->recon_config & ~0x80000000UL) | (v << 31);
|
||||
}
|
||||
@ -881,6 +884,9 @@ void set_recon_repeat_amp(const bool v) {
|
||||
void set_recon_load_repeaters(const bool v) {
|
||||
data->recon_config = (data->recon_config & ~0x00080000UL) | (v << 19);
|
||||
}
|
||||
void set_recon_repeat_recorded_file_mode(const bool v) {
|
||||
data->recon_config = (data->recon_config & ~0x00040000UL) | (v << 18);
|
||||
}
|
||||
|
||||
/* UI Config 2 */
|
||||
bool ui_hide_speaker() {
|
||||
|
@ -298,6 +298,7 @@ bool recon_load_ranges();
|
||||
bool recon_update_ranges_when_recon();
|
||||
bool recon_auto_record_locked();
|
||||
bool recon_repeat_recorded();
|
||||
bool recon_repeat_recorded_file_mode();
|
||||
int8_t recon_repeat_nb();
|
||||
int8_t recon_repeat_gain();
|
||||
bool recon_repeat_amp();
|
||||
@ -313,6 +314,7 @@ void set_recon_load_ranges(const bool v);
|
||||
void set_recon_update_ranges_when_recon(const bool v);
|
||||
void set_recon_auto_record_locked(const bool v);
|
||||
void set_recon_repeat_recorded(const bool v);
|
||||
void set_recon_repeat_recorded_file_mode(const bool v);
|
||||
void set_recon_repeat_nb(const int8_t v);
|
||||
void set_recon_repeat_gain(const int8_t v);
|
||||
void set_recon_repeat_amp(const bool v);
|
||||
|
Loading…
Reference in New Issue
Block a user