Skip to content

Commit

Permalink
Continued folder names consolidation & GPS default folder (#2042)
Browse files Browse the repository at this point in the history
* Continued folder names consolidation

* Clang
  • Loading branch information
NotherNgineer committed Mar 26, 2024
1 parent d5c8525 commit 264fa9a
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 13 deletions.
2 changes: 1 addition & 1 deletion firmware/application/apps/ble_rx_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ void BLERxView::on_filter_change(std::string value) {
}

void BLERxView::on_file_changed(const std::filesystem::path& new_file_path) {
file_path = fs::path(u"/") + new_file_path;
file_path = new_file_path;
found_count = 0;
total_count = 0;
searchList.clear();
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/ble_tx_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ BLETxView::BLETxView(
}

void BLETxView::on_file_changed(const fs::path& new_file_path) {
file_path = fs::path(u"/") + new_file_path;
file_path = new_file_path;
num_packets = 0;

{ // Get the size of the data file.
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/replay_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void ReplayAppView::set_ready() {
}

void ReplayAppView::on_file_changed(const fs::path& new_file_path) {
file_path = fs::path(u"/") + new_file_path;
file_path = new_file_path;
File::Size file_size{};

{ // Get the size of the data file.
Expand Down
2 changes: 1 addition & 1 deletion firmware/application/apps/ui_recon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ void ReconView::handle_repeat_thread_done(const uint32_t return_code) {
stop_repeat(true);
} else if (return_code == ReplayThread::READ_ERROR) {
stop_repeat(false);
repeat_file_error(u"/" + repeat_rec_path + u"/" + repeat_rec_file, "Can't open file to send.");
repeat_file_error(rawfile, "Can't open file to send.");
}
}

Expand Down
5 changes: 4 additions & 1 deletion firmware/application/external/gpssim/gps_sim_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "io_file.hpp"
#include "metadata_file.hpp"
#include "utility.hpp"
#include "file_path.hpp"

#include "baseband_api.hpp"
#include "portapack.hpp"
Expand All @@ -43,7 +44,7 @@ void GpsSimAppView::set_ready() {
}

void GpsSimAppView::on_file_changed(const fs::path& new_file_path) {
file_path = fs::path(u"/") + new_file_path;
file_path = new_file_path;
File::Size file_size{};

{ // Get the size of the data file.
Expand Down Expand Up @@ -185,6 +186,8 @@ GpsSimAppView::GpsSimAppView(

button_open.on_select = [this, &nav](Button&) {
auto open_view = nav.push<FileLoadView>(".C8");
ensure_directory(gps_dir);
open_view->push_dir(gps_dir);
open_view->on_changed = [this](std::filesystem::path new_file_path) {
on_file_changed(new_file_path);
};
Expand Down
3 changes: 3 additions & 0 deletions firmware/application/file_path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

const std::filesystem::path adsb_dir = u"ADSB";
const std::filesystem::path ais_dir = u"AIS";
const std::filesystem::path apps_dir = u"APPS";
const std::filesystem::path aprs_dir = u"APRS";
const std::filesystem::path audio_dir = u"AUDIO";
const std::filesystem::path blerx_dir = u"BLERX";
Expand All @@ -32,11 +33,13 @@ const std::filesystem::path captures_dir = u"CAPTURES";
const std::filesystem::path debug_dir = u"DEBUG";
const std::filesystem::path firmware_dir = u"FIRMWARE";
const std::filesystem::path freqman_dir = u"FREQMAN";
const std::filesystem::path gps_dir = u"GPS";
const std::filesystem::path logs_dir = u"LOGS";
const std::filesystem::path looking_glass_dir = u"LOOKINGGLASS";
const std::filesystem::path playlist_dir = u"PLAYLIST";
const std::filesystem::path remotes_dir = u"REMOTES";
const std::filesystem::path repeat_rec_path = u"CAPTURES";
const std::filesystem::path samples_dir = u"SAMPLES";
const std::filesystem::path screenshots_dir = u"SCREENSHOTS";
const std::filesystem::path settings_dir = u"SETTINGS";
const std::filesystem::path spectrum_dir = u"SPECTRUM";
Expand Down
3 changes: 3 additions & 0 deletions firmware/application/file_path.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

extern const std::filesystem::path adsb_dir;
extern const std::filesystem::path ais_dir;
extern const std::filesystem::path apps_dir;
extern const std::filesystem::path aprs_dir;
extern const std::filesystem::path audio_dir;
extern const std::filesystem::path blerx_dir;
Expand All @@ -34,11 +35,13 @@ extern const std::filesystem::path captures_dir;
extern const std::filesystem::path debug_dir;
extern const std::filesystem::path firmware_dir;
extern const std::filesystem::path freqman_dir;
extern const std::filesystem::path gps_dir;
extern const std::filesystem::path logs_dir;
extern const std::filesystem::path looking_glass_dir;
extern const std::filesystem::path playlist_dir;
extern const std::filesystem::path remotes_dir;
extern const std::filesystem::path repeat_rec_path;
extern const std::filesystem::path samples_dir;
extern const std::filesystem::path screenshots_dir;
extern const std::filesystem::path settings_dir;
extern const std::filesystem::path spectrum_dir;
Expand Down
13 changes: 7 additions & 6 deletions firmware/application/ui_external_items_menu_loader.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include "ui_external_items_menu_loader.hpp"

#include "sd_card.hpp"
#include "file_path.hpp"

namespace ui {

Expand All @@ -11,8 +12,8 @@ namespace ui {
if (!callback) return;
if (sd_card::status() != sd_card::Status::Mounted)
return;
for (const auto& entry : std::filesystem::directory_iterator(u"APPS", u"*.ppma")) {
auto filePath = u"/APPS/" + entry.path();
for (const auto& entry : std::filesystem::directory_iterator(apps_dir, u"*.ppma")) {
auto filePath = apps_dir / entry.path();
File app;

auto openError = app.open(filePath);
Expand Down Expand Up @@ -52,8 +53,8 @@ namespace ui {
if (sd_card::status() != sd_card::Status::Mounted)
return external_apps;

for (const auto& entry : std::filesystem::directory_iterator(u"APPS", u"*.ppma")) {
auto filePath = u"/APPS/" + entry.path();
for (const auto& entry : std::filesystem::directory_iterator(apps_dir, u"*.ppma")) {
auto filePath = apps_dir / entry.path();
File app;

auto openError = app.open(filePath);
Expand Down Expand Up @@ -86,7 +87,7 @@ namespace ui {

gridItem.on_select = [&nav, app_location, filePath]() {
if (!run_external_app(nav, filePath)) {
nav.display_modal("Error", "The .ppma file in your APPS\nfolder can't be read. Please\nupdate your SD Card content.");
nav.display_modal("Error", "The .ppma file in your " + apps_dir.string() + "\nfolder can't be read. Please\nupdate your SD Card content.");
}
};
} else {
Expand All @@ -95,7 +96,7 @@ namespace ui {
gridItem.bitmap = &bitmap_sd_card_error;

gridItem.on_select = [&nav]() {
nav.display_modal("Error", "The .ppma file in your APPS\nfolder is outdated. Please\nupdate your SD Card content.");
nav.display_modal("Error", "The .ppma file in your " + apps_dir.string() + "\nfolder is outdated. Please\nupdate your SD Card content.");
};
}

Expand Down
4 changes: 3 additions & 1 deletion firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,7 @@ static void add_apps(NavigationView& nav, BtnGridView& grid, app_location_t loc)
};
}

// clang-format off
void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView& grid) {
auto externalItems = ExternalItemsMenuLoader::load_external_items(location, nav);
if (externalItems.empty()) {
Expand All @@ -730,14 +731,15 @@ void addExternalItems(NavigationView& nav, app_location_t location, BtnGridView&
"Notice",
"External app directory empty;\n"
"see Mayhem wiki and copy apps\n"
"to APPS folder of SD card.");
"to " + apps_dir.string() + " folder of SD card.");
}});
} else {
for (auto const& gridItem : externalItems) {
grid.add_item(gridItem);
}
}
}
// clang-format on

/* ReceiversMenuView *****************************************************/

Expand Down
2 changes: 1 addition & 1 deletion firmware/application/usb_serial_shell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ static void cmd_appstart(BaseSequentialStream* chp, int argc, char* argv[]) {
return;
}
// since ext app loader changed, we can just pass the string to it, and it"ll return if started or not.
std::string appwithpath = "/APPS/";
std::string appwithpath = "/" + apps_dir.string() + "/";
appwithpath += argv[0];
appwithpath += ".ppma";
bool ret = ui::ExternalItemsMenuLoader::run_external_app(*nav, path_from_string8((char*)appwithpath.c_str()));
Expand Down

0 comments on commit 264fa9a

Please sign in to comment.