mirror of
https://github.com/justcallmekoko/ESP32Marauder.git
synced 2026-04-28 12:03:07 -07:00
Add remove SD files for Mini
This commit is contained in:
@@ -1245,6 +1245,13 @@ void MenuFunctions::RunSetup()
|
|||||||
#ifdef MARAUDER_MINI
|
#ifdef MARAUDER_MINI
|
||||||
miniKbMenu.list = new LinkedList<MenuNode>();
|
miniKbMenu.list = new LinkedList<MenuNode>();
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAS_ILI9341
|
||||||
|
#ifdef HAS_BUTTONS
|
||||||
|
#ifdef HAS_SD
|
||||||
|
sdDeleteMenu.list = new LinkedList<MenuNode>();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// Bluetooth menu stuff
|
// Bluetooth menu stuff
|
||||||
bluetoothSnifferMenu.list = new LinkedList<MenuNode>();
|
bluetoothSnifferMenu.list = new LinkedList<MenuNode>();
|
||||||
@@ -1283,6 +1290,9 @@ void MenuFunctions::RunSetup()
|
|||||||
#ifdef MARAUDER_MINI
|
#ifdef MARAUDER_MINI
|
||||||
miniKbMenu.name = "Mini Keyboard";
|
miniKbMenu.name = "Mini Keyboard";
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef HAS_ILI9341
|
||||||
|
sdDeleteMenu.name = "Delete SD Files";
|
||||||
|
#endif
|
||||||
|
|
||||||
// Build Main Menu
|
// Build Main Menu
|
||||||
mainMenu.parentMenu = NULL;
|
mainMenu.parentMenu = NULL;
|
||||||
@@ -1553,17 +1563,6 @@ void MenuFunctions::RunSetup()
|
|||||||
this->changeMenu(htmlMenu.parentMenu);
|
this->changeMenu(htmlMenu.parentMenu);
|
||||||
});
|
});
|
||||||
|
|
||||||
/*int loopLimit = min(evil_portal_obj.html_files->size(), BUTTON_ARRAY_LEN);
|
|
||||||
|
|
||||||
for (int i = 0; i < loopLimit - 1; i++) {
|
|
||||||
this->addNodes(&htmlMenu, evil_portal_obj.html_files->get(i), TFT_CYAN, NULL, 0, [this, i]() {
|
|
||||||
evil_portal_obj.target_html_name = (String)evil_portal_obj.html_files->get(i);
|
|
||||||
Serial.println("Set Evil Portal HTML as " + evil_portal_obj.target_html_name);
|
|
||||||
evil_portal_obj.using_serial_html = false;
|
|
||||||
this->changeMenu(htmlMenu.parentMenu);
|
|
||||||
});
|
|
||||||
}*/
|
|
||||||
|
|
||||||
// Select APs on Mini
|
// Select APs on Mini
|
||||||
this->addNodes(&wifiGeneralMenu, text_table1[56], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
|
this->addNodes(&wifiGeneralMenu, text_table1[56], TFT_NAVY, NULL, KEYBOARD_ICO, [this](){
|
||||||
wifiAPMenu.list->clear();
|
wifiAPMenu.list->clear();
|
||||||
@@ -1716,6 +1715,97 @@ void MenuFunctions::RunSetup()
|
|||||||
this->addNodes(&deviceMenu, text08, TFT_NAVY, NULL, KEYBOARD_ICO, [this]() {
|
this->addNodes(&deviceMenu, text08, TFT_NAVY, NULL, KEYBOARD_ICO, [this]() {
|
||||||
this->changeMenu(&settingsMenu);
|
this->changeMenu(&settingsMenu);
|
||||||
});
|
});
|
||||||
|
#ifdef HAS_SD
|
||||||
|
if (sd_obj.supported) {
|
||||||
|
this->addNodes(&deviceMenu, "Delete SD Files", TFT_CYAN, NULL, SD_UPDATE, [this]() {
|
||||||
|
#ifndef HAS_ILI9341
|
||||||
|
#ifdef HAS_BUTTONS
|
||||||
|
this->changeMenu(&sdDeleteMenu);
|
||||||
|
#if !(defined(MARAUDER_V6) || defined(MARAUDER_V6_1))
|
||||||
|
|
||||||
|
bool deleting = true;
|
||||||
|
|
||||||
|
display_obj.tft.setTextWrap(false);
|
||||||
|
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||||
|
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||||
|
display_obj.tft.println("Loading...");
|
||||||
|
|
||||||
|
while (deleting) {
|
||||||
|
// Build list of files
|
||||||
|
sd_obj.sd_files->clear();
|
||||||
|
delete sd_obj.sd_files;
|
||||||
|
|
||||||
|
sd_obj.sd_files = new LinkedList<String>();
|
||||||
|
|
||||||
|
sd_obj.sd_files->add("Back");
|
||||||
|
|
||||||
|
sd_obj.listDirToLinkedList(sd_obj.sd_files);
|
||||||
|
|
||||||
|
int sd_file_index = 0;
|
||||||
|
|
||||||
|
this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL});
|
||||||
|
this->buildButtons(&sdDeleteMenu);
|
||||||
|
this->displayCurrentMenu();
|
||||||
|
|
||||||
|
// Start button loop
|
||||||
|
while(true) {
|
||||||
|
#ifndef MARAUDER_M5STICKC
|
||||||
|
if (u_btn.justPressed()) {
|
||||||
|
if (sd_file_index > 0)
|
||||||
|
sd_file_index--;
|
||||||
|
else
|
||||||
|
sd_file_index = sd_obj.sd_files->size() - 1;
|
||||||
|
|
||||||
|
this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL});
|
||||||
|
this->buildButtons(&sdDeleteMenu);
|
||||||
|
this->displayCurrentMenu();
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
if (d_btn.justPressed()) {
|
||||||
|
if (sd_file_index < sd_obj.sd_files->size() - 1)
|
||||||
|
sd_file_index++;
|
||||||
|
else
|
||||||
|
sd_file_index = 0;
|
||||||
|
|
||||||
|
this->sdDeleteMenu.list->set(0, MenuNode{sd_obj.sd_files->get(sd_file_index), false, TFT_CYAN, 0, NULL, true, NULL});
|
||||||
|
this->buildButtons(&sdDeleteMenu, 0, sd_obj.sd_files->get(sd_file_index));
|
||||||
|
this->displayCurrentMenu();
|
||||||
|
}
|
||||||
|
if (c_btn.justPressed()) {
|
||||||
|
if (sd_obj.sd_files->get(sd_file_index) != "Back") {
|
||||||
|
if (sd_obj.removeFile("/" + sd_obj.sd_files->get(sd_file_index)))
|
||||||
|
Serial.println("Successfully Removed File: /" + sd_obj.sd_files->get(sd_file_index));
|
||||||
|
display_obj.tft.setTextWrap(false);
|
||||||
|
display_obj.tft.setCursor(0, SCREEN_HEIGHT / 3);
|
||||||
|
display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
|
||||||
|
display_obj.tft.println("Deleting /" + sd_obj.sd_files->get(sd_file_index) + "...");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this->changeMenu(sdDeleteMenu.parentMenu);
|
||||||
|
deleting = false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
});
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAS_SD
|
||||||
|
#ifndef ILI9341
|
||||||
|
#ifdef HAS_BUTTONS
|
||||||
|
sdDeleteMenu.parentMenu = &deviceMenu;
|
||||||
|
this->addNodes(&sdDeleteMenu, text09, TFT_LIGHTGREY, NULL, 0, [this]() {
|
||||||
|
this->changeMenu(sdDeleteMenu.parentMenu);
|
||||||
|
});
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
// GPS Menu
|
// GPS Menu
|
||||||
#ifdef HAS_GPS
|
#ifdef HAS_GPS
|
||||||
if (gps_obj.getGpsModuleStatus()) {
|
if (gps_obj.getGpsModuleStatus()) {
|
||||||
|
|||||||
@@ -140,6 +140,7 @@ class MenuFunctions
|
|||||||
Menu specSettingMenu;
|
Menu specSettingMenu;
|
||||||
Menu infoMenu;
|
Menu infoMenu;
|
||||||
Menu languageMenu;
|
Menu languageMenu;
|
||||||
|
Menu sdDeleteMenu;
|
||||||
|
|
||||||
// WiFi menu stuff
|
// WiFi menu stuff
|
||||||
Menu wifiSnifferMenu;
|
Menu wifiSnifferMenu;
|
||||||
|
|||||||
@@ -79,6 +79,10 @@ bool SDInterface::initSD() {
|
|||||||
SD.mkdir("/SCRIPTS");
|
SD.mkdir("/SCRIPTS");
|
||||||
Serial.println("/SCRIPTS created");
|
Serial.println("/SCRIPTS created");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->sd_files = new LinkedList<String>();
|
||||||
|
|
||||||
|
this->sd_files->add("Back");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -98,6 +102,13 @@ File SDInterface::getFile(String path) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SDInterface::removeFile(String file_path) {
|
||||||
|
if (SD.remove(file_path))
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void SDInterface::listDirToLinkedList(LinkedList<String>* file_names, String str_dir, String ext) {
|
void SDInterface::listDirToLinkedList(LinkedList<String>* file_names, String str_dir, String ext) {
|
||||||
if (this->supported) {
|
if (this->supported) {
|
||||||
File dir = SD.open(str_dir);
|
File dir = SD.open(str_dir);
|
||||||
@@ -108,12 +119,18 @@ void SDInterface::listDirToLinkedList(LinkedList<String>* file_names, String str
|
|||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (entry.isDirectory())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
String file_name = entry.name();
|
||||||
if (ext != "") {
|
if (ext != "") {
|
||||||
String file_name = entry.name();
|
|
||||||
if (file_name.endsWith(ext)) {
|
if (file_name.endsWith(ext)) {
|
||||||
file_names->add(file_name);
|
file_names->add(file_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
file_names->add(file_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,12 +43,15 @@ class SDInterface {
|
|||||||
|
|
||||||
bool initSD();
|
bool initSD();
|
||||||
|
|
||||||
|
LinkedList<String>* sd_files;
|
||||||
|
|
||||||
void listDir(String str_dir);
|
void listDir(String str_dir);
|
||||||
void listDirToLinkedList(LinkedList<String>* file_names, String str_dir = "/", String ext = "");
|
void listDirToLinkedList(LinkedList<String>* file_names, String str_dir = "/", String ext = "");
|
||||||
File getFile(String path);
|
File getFile(String path);
|
||||||
void runUpdate();
|
void runUpdate();
|
||||||
void performUpdate(Stream &updateSource, size_t updateSize);
|
void performUpdate(Stream &updateSource, size_t updateSize);
|
||||||
void main();
|
void main();
|
||||||
|
bool removeFile(String file_path);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -20,7 +20,7 @@
|
|||||||
//#define XIAO_ESP32_S3
|
//#define XIAO_ESP32_S3
|
||||||
//// END BOARD TARGETS
|
//// END BOARD TARGETS
|
||||||
|
|
||||||
#define MARAUDER_VERSION "v0.13.8"
|
#define MARAUDER_VERSION "v0.13.9"
|
||||||
|
|
||||||
//// HARDWARE NAMES
|
//// HARDWARE NAMES
|
||||||
#ifdef MARAUDER_M5STICKC
|
#ifdef MARAUDER_M5STICKC
|
||||||
|
|||||||
Reference in New Issue
Block a user