diff --git a/firmware/application/file.cpp b/firmware/application/file.cpp index 7349ba27..95069669 100644 --- a/firmware/application/file.cpp +++ b/firmware/application/file.cpp @@ -166,23 +166,15 @@ std::filesystem::path next_filename_stem_matching_pattern(std::filesystem::path } } -std::vector scan_root_files(const TCHAR* directory, const std::string& extension) { +std::vector scan_root_files(const std::filesystem::path& directory, + const std::filesystem::path& extension) { + std::vector file_list { }; - std::filesystem::path file_path; - FRESULT res; - DIR dir; - static FILINFO fno; - - res = f_opendir(&dir, directory); - if (res == FR_OK) { - for (;;) { - res = f_readdir(&dir, &fno); - if (res != FR_OK || fno.fname[0] == 0) break; - file_path = fno.fname; - if (file_path.extension().string() == extension) - file_list.push_back(file_path); + + for(const auto& entry : std::filesystem::directory_iterator(directory, extension)) { + if( std::filesystem::is_regular_file(entry.status()) ) { + file_list.push_back(entry.path()); } - f_closedir(&dir); } return file_list; diff --git a/firmware/application/file.hpp b/firmware/application/file.hpp index 9bb79d52..ddeb4e65 100644 --- a/firmware/application/file.hpp +++ b/firmware/application/file.hpp @@ -233,7 +233,7 @@ space_info space(const path& p); } /* namespace filesystem */ } /* namespace std */ -std::vector scan_root_files(const TCHAR* directory, const std::string& extension); +std::vector scan_root_files(const std::filesystem::path& directory, const std::filesystem::path& extension); std::filesystem::path next_filename_stem_matching_pattern(std::filesystem::path filename_stem_pattern); /* Values added to FatFs FRESULT enum, values outside the FRESULT data type */ diff --git a/firmware/application/io_wave.hpp b/firmware/application/io_wave.hpp index 41805633..0cca3a46 100644 --- a/firmware/application/io_wave.hpp +++ b/firmware/application/io_wave.hpp @@ -125,13 +125,13 @@ private: data_t data; }; - header_t header; + header_t header { }; - File file; - uint32_t data_start; - uint32_t bytes_per_sample; - uint32_t data_size_; - uint32_t sample_rate_; + File file { }; + uint32_t data_start { }; + uint32_t bytes_per_sample { }; + uint32_t data_size_ { 0 }; + uint32_t sample_rate_ { }; std::filesystem::path last_path { }; }; diff --git a/firmware/application/ui_soundboard.cpp b/firmware/application/ui_soundboard.cpp index ecb4f9f3..b7d58739 100644 --- a/firmware/application/ui_soundboard.cpp +++ b/firmware/application/ui_soundboard.cpp @@ -89,9 +89,8 @@ void SoundBoardView::prepare_audio() { void SoundBoardView::focus() { buttons[0].focus(); - if (!max_sound) { + if (!max_sound) nav_.display_modal("No files", "No files in /wav/ directory", ABORT, nullptr); - } } void SoundBoardView::on_tuning_frequency_changed(rf::Frequency f) { @@ -157,7 +156,7 @@ void SoundBoardView::refresh_buttons(uint16_t id) { button.id = n_sound; if (n_sound < max_sound) { - button.set_text(sounds[n_sound].path.stem().string()); + button.set_text(sounds[n_sound].path.stem().string().substr(0, 8)); button.set_style(styles[sounds[n_sound].path.stem().string()[0] & 3]); } else { button.set_text("- - -"); @@ -204,11 +203,11 @@ SoundBoardView::SoundBoardView( reader = std::make_unique(); - file_list = scan_root_files(reinterpret_cast("/wav"), ".WAV"); + file_list = scan_root_files(u"wav", u"*.WAV"); c = 0; for (auto& path : file_list) { - if (reader->open(path)) { + if (reader->open(u"wav/" + path.native())) { if (reader->channels() == 1) { sounds[c].size = reader->data_size(); sounds[c].sample_duration = reader->data_size() / (reader->bits_per_sample() / 8); @@ -234,7 +233,7 @@ SoundBoardView::SoundBoardView( &field_frequency, &number_bw, &text_kHz, - &options_ctcss, + //&options_ctcss, &text_page, &text_duration, &pbar, @@ -243,7 +242,7 @@ SoundBoardView::SoundBoardView( &button_exit }); - ctcss_options.emplace_back(std::make_pair("None", 0)); + /*ctcss_options.emplace_back(std::make_pair("None", 0)); for (c = 0; c < CTCSS_TONES_NB; c++) ctcss_options.emplace_back(std::make_pair(ctcss_tones[c].PL_code, c)); @@ -253,7 +252,7 @@ SoundBoardView::SoundBoardView( options_ctcss.on_change = [this](size_t, OptionsField::value_t v) { this->on_ctcss_changed(v); }; - options_ctcss.set_selected_index(0); + options_ctcss.set_selected_index(0);*/ const auto button_fn = [this](Button& button) { tx_mode = NORMAL; diff --git a/firmware/application/ui_soundboard.hpp b/firmware/application/ui_soundboard.hpp index 0eebb0e7..dcf9798d 100644 --- a/firmware/application/ui_soundboard.hpp +++ b/firmware/application/ui_soundboard.hpp @@ -69,19 +69,19 @@ private: uint32_t ms_duration = 0; }; - uint32_t sample_counter; - uint32_t sample_duration; + uint32_t sample_counter { 0 }; + uint32_t sample_duration { 0 }; uint8_t page = 0; uint16_t lfsr_v = 0x1337; - std::unique_ptr reader; + std::unique_ptr reader { }; sound sounds[105]; - uint8_t max_sound; - uint8_t max_page; + uint8_t max_sound { 0 }; + uint8_t max_page { 0 }; - uint32_t _ctcss_freq; + uint32_t _ctcss_freq { 0 }; int8_t audio_buffer[1024]; @@ -106,7 +106,7 @@ private: .foreground = { 153, 102, 255 } }; - std::array buttons; + std::array buttons { }; const Style * styles[4] = { &style_a, &style_b, &style_c, &style_d }; void on_tuning_frequency_changed(rf::Frequency f); diff --git a/firmware/baseband/proc_pocsag.cpp b/firmware/baseband/proc_pocsag.cpp index f90e4db8..ad80faf9 100644 --- a/firmware/baseband/proc_pocsag.cpp +++ b/firmware/baseband/proc_pocsag.cpp @@ -47,11 +47,12 @@ void POCSAGProcessor::execute(const buffer_c8_t& buffer) { const auto channel_out = channel_filter.execute(decim_1_out, dst_buffer); auto audio = demod.execute(channel_out, audio_buffer); - // End up with 16 samples + // End up with 32 samples ? for (uint32_t c = 0; c < 16; c++) { - const int32_t audio_sample = audio.p[c] * 32768.0f; - //const int32_t audio_sample = __SSAT(sample_int, 16); + const int32_t sample_int = audio.p[c] * 32768.0f; + //const int32_t audio_sample = audio.p[c] * 32768.0f; + const int32_t audio_sample = __SSAT(sample_int, 16); slicer_sr <<= 1; slicer_sr |= (audio_sample < 0); diff --git a/firmware/portapack-h1-havoc.bin b/firmware/portapack-h1-havoc.bin index 5d990993..d9607170 100644 Binary files a/firmware/portapack-h1-havoc.bin and b/firmware/portapack-h1-havoc.bin differ