From c8cb3e40ed2773cfbe0c0b873dc1dd8591182136 Mon Sep 17 00:00:00 2001 From: Stefan Mertl Date: Wed, 31 Jan 2018 18:19:56 +0100 Subject: [PATCH] Show the file size of the files in the tmp_dir on the LCD. --- software/c++/ruwaicom/include/root.h | 2 ++ software/c++/ruwaicom/src/root.cpp | 38 ++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/software/c++/ruwaicom/include/root.h b/software/c++/ruwaicom/include/root.h index 91b42d9..190fbaa 100644 --- a/software/c++/ruwaicom/include/root.h +++ b/software/c++/ruwaicom/include/root.h @@ -45,6 +45,7 @@ #include #include #include +#include #undef BOOST_NO_CXX11_SCOPED_ENUMS #undef BOOST_NO_SCOPED_ENUMS @@ -108,6 +109,7 @@ class Root { pga_gain_t translate_pga_gain(double gain); adc_sps_t translate_adc_sps(uint16_t sps); void lcd_status(void); + std::vector get_file_list(const std::string path); }; template diff --git a/software/c++/ruwaicom/src/root.cpp b/software/c++/ruwaicom/src/root.cpp index ec223f6..a171aaf 100644 --- a/software/c++/ruwaicom/src/root.cpp +++ b/software/c++/ruwaicom/src/root.cpp @@ -733,16 +733,50 @@ Root::lcd_status(void) ms_hptime2isotimestr(last_timestamp.time, c_time_string, true); time_string = std::string(c_time_string); display->print(time_string.substr(0, 10), time_string.substr(11)); - - std::this_thread::sleep_for(std::chrono::seconds(2)); + std::this_thread::sleep_for(std::chrono::seconds(3)); stream << "GPS F:" << last_timestamp.gps_fix << " OK:" << last_timestamp.gps_fix_ok; msg1 = stream.str(); + stream.str(""); stream << "SLTS:" << last_timestamp.sec_slts; msg2 = stream.str(); display->print(msg1, msg2); + std::this_thread::sleep_for(std::chrono::seconds(3)); + + + std::string tmp_dir = recorder->get_tmp_dir(); + std::vector rec_files = get_file_list(tmp_dir); + std::sort(rec_files.begin(), rec_files.end()); + stream.str(""); + stream << rec_files.size() << " files"; + msg1 = stream.str(); + + stream.str(""); + for (std::vector::iterator it = rec_files.begin(); it != rec_files.end(); it++) + { + std::string file_path = tmp_dir + "/" + *it; + stream << boost::filesystem::file_size(file_path) / 1024 << "; "; + } + msg2 = stream.str(); + stream.str(""); std::this_thread::sleep_for(std::chrono::seconds(10)); } } + +std::vector +Root::get_file_list(const std::string path) +{ + std::vector m_file_list; + if (!path.empty()) + { + boost::filesystem::path apk_path(path); + + for (auto& entry : boost::make_iterator_range(boost::filesystem::directory_iterator(apk_path), {})) + { + m_file_list.push_back(entry.path().string()); + } + } + return m_file_list; +} -- 2.11.4.GIT