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:
gullradriel 2024-03-10 01:45:54 +01:00 committed by GitHub
parent e496f8ecc2
commit 160a778104
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 68 additions and 29 deletions

View file

@ -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