From d70e1a6fac29f30ed72732a18ff139f00b9c3c64 Mon Sep 17 00:00:00 2001 From: notpike Date: Mon, 28 Mar 2022 20:53:09 -0700 Subject: [PATCH 1/3] Added Datetime + Freq Filename to Audio App --- .../application/apps/analog_audio_app.cpp | 3 +++ .../application/apps/analog_audio_app.hpp | 9 +++++-- firmware/application/string_format.cpp | 5 ++++ firmware/application/string_format.hpp | 1 + firmware/application/ui_record_view.cpp | 24 ++++++++++++++++++- firmware/application/ui_record_view.hpp | 7 ++++++ 6 files changed, 46 insertions(+), 3 deletions(-) diff --git a/firmware/application/apps/analog_audio_app.cpp b/firmware/application/apps/analog_audio_app.cpp index b8d79e3e..6c4dec74 100644 --- a/firmware/application/apps/analog_audio_app.cpp +++ b/firmware/application/apps/analog_audio_app.cpp @@ -129,6 +129,9 @@ AnalogAudioView::AnalogAudioView( &waterfall }); + //Filename Datetime and Frequency + record_view.set_filename_date_frequency(true); + field_frequency.set_value(receiver_model.tuning_frequency()); field_frequency.set_step(receiver_model.frequency_step()); field_frequency.on_change = [this](rf::Frequency f) { diff --git a/firmware/application/apps/analog_audio_app.hpp b/firmware/application/apps/analog_audio_app.hpp index 728b6277..48119efe 100644 --- a/firmware/application/apps/analog_audio_app.hpp +++ b/firmware/application/apps/analog_audio_app.hpp @@ -28,11 +28,13 @@ #include "ui_receiver.hpp" #include "ui_spectrum.hpp" #include "ui_record_view.hpp" - #include "ui_font_fixed_8x16.hpp" #include "tone_key.hpp" +#include "string_format.hpp" + + namespace ui { constexpr Style style_options_group { @@ -216,7 +218,10 @@ private: RecordView record_view { { 0 * 8, 2 * 16, 30 * 8, 1 * 16 }, - u"AUD_????", RecordView::FileType::WAV, 4096, 4 + u"AUD", + RecordView::FileType::WAV, + 4096, + 4 }; spectrum::WaterfallWidget waterfall { true }; diff --git a/firmware/application/string_format.cpp b/firmware/application/string_format.cpp index 22b02d0b..3529a2d7 100644 --- a/firmware/application/string_format.cpp +++ b/firmware/application/string_format.cpp @@ -129,6 +129,11 @@ std::string to_string_decimal(float decimal, int8_t precision) { return result; } +std::string to_string_freq(const uint64_t f) { + auto final_str = to_string_dec_int(f / 1000000,4) + to_string_dec_int(f % 1000000, 6, '0'); + return final_str; +} + std::string to_string_short_freq(const uint64_t f) { auto final_str = to_string_dec_int(f / 1000000,4) + "." + to_string_dec_int((f / 100) % 10000, 4, '0'); return final_str; diff --git a/firmware/application/string_format.hpp b/firmware/application/string_format.hpp index a588ef95..db32072e 100644 --- a/firmware/application/string_format.hpp +++ b/firmware/application/string_format.hpp @@ -48,6 +48,7 @@ std::string to_string_decimal(float decimal, int8_t precision); std::string to_string_hex(const uint64_t n, const int32_t l = 0); std::string to_string_hex_array(uint8_t * const array, const int32_t l = 0); +std::string to_string_freq(const uint64_t f); std::string to_string_short_freq(const uint64_t f); std::string to_string_time_ms(const uint32_t ms); diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 26d3af43..4b4fdcfb 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -127,6 +127,11 @@ void RecordView::set_sampling_rate(const size_t new_sampling_rate) { } } +// Setter for datetime and frequency filename +void RecordView::set_filename_date_frequency(bool set) { + filename_date_frequency = set; +} + bool RecordView::is_active() const { return (bool)capture_thread; } @@ -149,7 +154,24 @@ void RecordView::start() { return; } - auto base_path = next_filename_stem_matching_pattern(filename_stem_pattern); + // + std::filesystem::path base_path; + if(filename_date_frequency) { + rtcGetTime(&RTCD1, &datetime); + + //ISO 8601 + std::string date_time = to_string_dec_uint(datetime.year(), 4, '0') + + to_string_dec_uint(datetime.month(), 2, '0') + + to_string_dec_uint(datetime.day(), 2, '0') + "T" + + to_string_dec_uint(datetime.hour()) + + to_string_dec_uint(datetime.minute()) + + to_string_dec_uint(datetime.second()); + + base_path = filename_stem_pattern.string() + "_" + date_time + "_" + to_string_freq(receiver_model.tuning_frequency()) + "Hz"; + } else { + base_path = next_filename_stem_matching_pattern(filename_stem_pattern); + } + if( base_path.empty() ) { return; } diff --git a/firmware/application/ui_record_view.hpp b/firmware/application/ui_record_view.hpp index 6f3a6a14..097e52cb 100644 --- a/firmware/application/ui_record_view.hpp +++ b/firmware/application/ui_record_view.hpp @@ -63,6 +63,8 @@ public: bool is_active() const; + void set_filename_date_frequency(bool set); + private: void toggle(); //void toggle_pitch_rssi(); @@ -75,6 +77,11 @@ private: void handle_error(const File::Error error); //bool pitch_rssi_enabled = false; + + // Time Stamp + bool filename_date_frequency = false; + rtc::RTC datetime { }; + const std::filesystem::path filename_stem_pattern; const FileType file_type; const size_t write_size; From aa2c5a4c846f8e860a4e15716eb8e4158516b171 Mon Sep 17 00:00:00 2001 From: NotPike <18655435+notpike@users.noreply.github.com> Date: Tue, 29 Mar 2022 00:34:52 -0400 Subject: [PATCH 2/3] Update analog_audio_app.hpp Forgot to take that include out. >_< --- firmware/application/apps/analog_audio_app.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/firmware/application/apps/analog_audio_app.hpp b/firmware/application/apps/analog_audio_app.hpp index 48119efe..8f62e237 100644 --- a/firmware/application/apps/analog_audio_app.hpp +++ b/firmware/application/apps/analog_audio_app.hpp @@ -32,8 +32,6 @@ #include "tone_key.hpp" -#include "string_format.hpp" - namespace ui { From 7066f931a81220445fc48ffe940532e24fc5cf15 Mon Sep 17 00:00:00 2001 From: NotPike <18655435+notpike@users.noreply.github.com> Date: Tue, 29 Mar 2022 01:16:16 -0400 Subject: [PATCH 3/3] Update ui_record_view.cpp cleanup --- firmware/application/ui_record_view.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firmware/application/ui_record_view.cpp b/firmware/application/ui_record_view.cpp index 4b4fdcfb..687c2964 100644 --- a/firmware/application/ui_record_view.cpp +++ b/firmware/application/ui_record_view.cpp @@ -154,7 +154,7 @@ void RecordView::start() { return; } - // + std::filesystem::path base_path; if(filename_date_frequency) { rtcGetTime(&RTCD1, &datetime);