Skip to content

Commit

Permalink
Declare all folder names in a single source file (#2039)
Browse files Browse the repository at this point in the history
  • Loading branch information
NotherNgineer authored Mar 25, 2024
1 parent d9bbd1b commit d5c8525
Show file tree
Hide file tree
Showing 56 changed files with 224 additions and 105 deletions.
1 change: 1 addition & 0 deletions firmware/application/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ set(CPPSRC
event_m0.cpp
file_reader.cpp
file.cpp
file_path.cpp
freqman_db.cpp
freqman.cpp
io_convert.cpp
Expand Down
5 changes: 3 additions & 2 deletions firmware/application/app_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "portapack.hpp"
#include "portapack_persistent_memory.hpp"
#include "utility.hpp"
#include "file_path.hpp"

#include <algorithm>
#include <cstring>
Expand All @@ -40,7 +41,7 @@ using namespace portapack;

namespace {
fs::path get_settings_path(const std::string& app_name) {
return fs::path{SETTINGS_DIR} / app_name + u".ini";
return settings_dir / app_name + u".ini";
}
} // namespace

Expand Down Expand Up @@ -156,7 +157,7 @@ bool save_settings(std::string_view store_name, const SettingBindings& bindings)
File f;
auto path = get_settings_path(std::string{store_name});

ensure_directory(SETTINGS_DIR);
ensure_directory(settings_dir);
auto error = f.create(path);
if (error)
return false;
Expand Down
3 changes: 0 additions & 3 deletions firmware/application/app_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,6 @@
#include "max283x.hpp"
#include "string_format.hpp"

// Folder to store app settings, pmem_fileflag, and date_fileflag
#define SETTINGS_DIR u"/SETTINGS"

// Bring in the string_view literal.
using std::literals::operator""sv;

Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/acars_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "baseband_api.hpp"
#include "portapack_persistent_memory.hpp"
#include "file_path.hpp"

using namespace portapack;
using namespace acars;
Expand Down Expand Up @@ -77,7 +78,7 @@ ACARSAppView::ACARSAppView(NavigationView& nav)

logger = std::make_unique<ACARSLogger>();
if (logger)
logger->append(LOG_ROOT_DIR "/ACARS.TXT");
logger->append(logs_dir / u"ACARS.TXT");
}

ACARSAppView::~ACARSAppView() {
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/acars_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

class ACARSLogger {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/ais_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#include "string_format.hpp"
#include "database.hpp"
#include "file_path.hpp"

#include "baseband_api.hpp"

Expand Down Expand Up @@ -399,7 +400,7 @@ AISAppView::AISAppView(NavigationView& nav)

logger = std::make_unique<AISLogger>();
if (logger) {
logger->append(LOG_ROOT_DIR "/AIS.TXT");
logger->append(logs_dir / u"AIS.TXT");
}
}

Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/ble_comm_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "ui_text.hpp"
#include "file_path.hpp"

using namespace portapack;
using namespace modems;
Expand Down Expand Up @@ -100,7 +101,7 @@ BLECommView::BLECommView(NavigationView& nav)
logging = v;

if (logger && logging)
logger->append(LOG_ROOT_DIR "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
logger->append(logs_dir.string() + "/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
};

options_channel.on_change = [this](size_t, int32_t i) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/ble_comm_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

class BLECommLogger {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down
5 changes: 1 addition & 4 deletions firmware/application/apps/ble_rx_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,10 +470,7 @@ BLERxView::BLERxView(NavigationView& nav)
logging = v;

if (logger && logging)
logger->append(
"BLERX/Logs"
"/BLELOG_" +
to_string_timestamp(rtc_time::now()) + ".TXT");
logger->append(blerx_dir.string() + "/Logs/BLELOG_" + to_string_timestamp(rtc_time::now()) + ".TXT");
};
check_log.set_value(logging);

Expand Down
11 changes: 6 additions & 5 deletions firmware/application/apps/ble_rx_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,13 @@
#include "log_file.hpp"
#include "utility.hpp"
#include "usb_serial_thread.hpp"
#include "file_path.hpp"

#include "recent_entries.hpp"

class BLELogger {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down Expand Up @@ -133,7 +134,7 @@ class BleRecentEntryDetailView : public View {
void on_save_file(const std::string value, BLETxPacket packetToSave);
bool saveFile(const std::filesystem::path& path, BLETxPacket packetToSave);
std::string packetFileBuffer{};
std::filesystem::path packet_save_path{u"BLERX/Lists/????.csv"};
std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};

static constexpr uint8_t total_data_lines{5};

Expand Down Expand Up @@ -250,9 +251,9 @@ class BLERxView : public View {
uint64_t total_count = 0;
std::vector<std::string> searchList{};

std::filesystem::path find_packet_path{u"BLERX/Find/????.TXT"};
std::filesystem::path log_packets_path{u"BLERX/Logs/????.TXT"};
std::filesystem::path packet_save_path{u"BLERX/Lists/????.csv"};
std::filesystem::path find_packet_path{blerx_dir / u"Find/????.TXT"};
std::filesystem::path log_packets_path{blerx_dir / u"Logs/????.TXT"};
std::filesystem::path packet_save_path{blerx_dir / u"Lists/????.csv"};

static constexpr auto header_height = 4 * 16;
static constexpr auto switch_button_height = 3 * 16;
Expand Down
1 change: 1 addition & 0 deletions firmware/application/apps/ble_tx_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "portapack_persistent_memory.hpp"
#include "rtc_time.hpp"
#include "string_format.hpp"
#include "file_path.hpp"

using namespace portapack;
using namespace modems;
Expand Down
7 changes: 4 additions & 3 deletions firmware/application/apps/ble_tx_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "replay_thread.hpp"
#include "log_file.hpp"
#include "utility.hpp"
#include "file_path.hpp"

#include "recent_entries.hpp"

Expand All @@ -44,7 +45,7 @@

class BLELoggerTx {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down Expand Up @@ -138,7 +139,7 @@ class BLETxView : public View {
uint32_t prev_value{0};

std::filesystem::path file_path{};
std::filesystem::path packet_save_path{u"BLETX/BLETX_????.TXT"};
std::filesystem::path packet_save_path{bletx_dir / u"BLETX_????.TXT"};
uint8_t channel_number = 37;
bool auto_channel = false;

Expand All @@ -165,7 +166,7 @@ class BLETxView : public View {

std::unique_ptr<FileWrapper> dataFileWrapper{};
File dataFile{};
std::filesystem::path dataTempFilePath{u"BLETX/dataFileTemp.TXT"};
std::filesystem::path dataTempFilePath{bletx_dir / u"dataFileTemp.TXT"};
std::vector<uint16_t> markedBytes{};
CursorPos cursor_pos{};
uint8_t marked_counter = 0;
Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/capture_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "ui_spectrum.hpp"
#include "app_settings.hpp"
#include "radio_state.hpp"
#include "file_path.hpp"

namespace ui {

Expand Down Expand Up @@ -101,7 +102,7 @@ class CaptureAppView : public View {
RecordView record_view{
{0 * 8, 2 * 16, 30 * 8, 1 * 16},
u"BBD_????.*",
u"CAPTURES",
captures_dir,
RecordView::FileType::RawS16,
16384,
3};
Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/ert_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ using namespace portapack;

#include "crc.hpp"
#include "string_format.hpp"
#include "file_path.hpp"

namespace ert {

Expand Down Expand Up @@ -129,7 +130,7 @@ ERTAppView::ERTAppView(NavigationView& nav)

logger = std::make_unique<ERTLogger>();
if (logger) {
logger->append(LOG_ROOT_DIR "/ERT.TXT");
logger->append(logs_dir / u"ERT.TXT");
}
}

Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/pocsag_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "portapack_persistent_memory.hpp"
#include "string_format.hpp"
#include "utility.hpp"
#include "file_path.hpp"

using namespace portapack;
using namespace pocsag;
Expand Down Expand Up @@ -115,7 +116,7 @@ POCSAGAppView::POCSAGAppView(NavigationView& nav)
: FILTER_DROP;
}

logger.append(LOG_ROOT_DIR "/POCSAG.TXT");
logger.append(logs_dir / u"POCSAG.TXT");

field_squelch.set_value(receiver_model.squelch_level());
field_squelch.on_change = [this](int32_t v) {
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/pocsag_app.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

class POCSAGLogger {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down
5 changes: 3 additions & 2 deletions firmware/application/apps/soundboard_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "tonesets.hpp"
#include "ui_tone_key.hpp"
#include "audio.hpp"
#include "file_path.hpp"

using namespace tonekey;
using namespace portapack;
Expand Down Expand Up @@ -164,7 +165,7 @@ void SoundBoardView::refresh_list() {

// List directories and files, put directories up top
uint32_t count = 0;
for (const auto& entry : std::filesystem::directory_iterator(u"WAV", u"*")) {
for (const auto& entry : std::filesystem::directory_iterator(wav_dir, u"*")) {
if (std::filesystem::is_regular_file(entry.status())) {
if (entry.path().string().length()) {
auto entry_extension = entry.path().extension().string();
Expand All @@ -173,7 +174,7 @@ void SoundBoardView::refresh_list() {
c = toupper(c);

if (entry_extension == ".WAV") {
if (reader->open(u"/WAV/" + entry.path().native())) {
if (reader->open(wav_dir / entry.path())) {
if ((reader->channels() == 1) && ((reader->bits_per_sample() == 8) || (reader->bits_per_sample() == 16))) {
// sounds[c].ms_duration = reader->ms_duration();
// sounds[c].path = u"WAV/" + entry.path().native();
Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/tpms_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ using namespace portapack;
#include "string_format.hpp"

#include "utility.hpp"
#include "file_path.hpp"

namespace tpms {

Expand Down Expand Up @@ -176,7 +177,7 @@ TPMSAppView::TPMSAppView(NavigationView&) {

logger = std::make_unique<TPMSLogger>();
if (logger) {
logger->append(LOG_ROOT_DIR "/TPMS.TXT");
logger->append(logs_dir / u"TPMS.TXT");
}
}

Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/ui_adsb_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "portapack_persistent_memory.hpp"
#include "rtc_time.hpp"
#include "string_format.hpp"
#include "file_path.hpp"

using namespace portapack;

Expand Down Expand Up @@ -390,7 +391,7 @@ ADSBRxView::ADSBRxView(NavigationView& nav) {
};

logger = std::make_unique<ADSBLogger>();
logger->append(LOG_ROOT_DIR "/ADSB.TXT");
logger->append(logs_dir / u"ADSB.TXT");

receiver_model.enable();
baseband::set_adsb();
Expand Down
3 changes: 2 additions & 1 deletion firmware/application/apps/ui_aprs_rx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "baseband_api.hpp"
#include "string_format.hpp"
#include "portapack_persistent_memory.hpp"
#include "file_path.hpp"

using namespace portapack;

Expand Down Expand Up @@ -111,7 +112,7 @@ APRSRxView::APRSRxView(NavigationView& nav, Rect parent_rect)

logger = std::make_unique<APRSLogger>();
if (logger)
logger->append(LOG_ROOT_DIR "/APRS.TXT");
logger->append(logs_dir / u"APRS.TXT");

baseband::set_aprs(1200);

Expand Down
5 changes: 3 additions & 2 deletions firmware/application/apps/ui_aprs_rx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@

#include "log_file.hpp"
#include "utility.hpp"
#include "file_path.hpp"

class APRSLogger {
public:
Optional<File::Error> append(const std::string& filename) {
Optional<File::Error> append(const std::filesystem::path& filename) {
return log_file.append(filename);
}

Expand Down Expand Up @@ -232,7 +233,7 @@ class APRSRxView : public View {
RecordView record_view{
{0 * 8, 1 * 16, 30 * 8, 1 * 16},
u"AFS_????.WAV",
u"APRS",
aprs_dir,
RecordView::FileType::WAV,
4096,
4};
Expand Down
Loading

0 comments on commit d5c8525

Please sign in to comment.