Skip to content

Commit

Permalink
Merge pull request #83 from eadmaster/serialcmds
Browse files Browse the repository at this point in the history
added optional file extension filter in the filepicker
  • Loading branch information
pr3y authored Jul 25, 2024
2 parents 1daf0e7 + 1f5ae02 commit b84f61f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
10 changes: 5 additions & 5 deletions src/core/sd_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ void sortList(String fileList[][3], int fileListCount) {
** Function name: sortList
** Description: sort files for name
***************************************************************************************/
void readFs(FS fs, String folder, String result[][3]) {
void readFs(FS fs, String folder, String result[][3], String allowed_ext) {

int allFilesCount = 0;
while(allFilesCount<MAXFILES) {
Expand Down Expand Up @@ -331,7 +331,7 @@ void readFs(FS fs, String folder, String result[][3]) {
result[allFilesCount][2] = "file";
allFilesCount++;
}
else {
else if(allowed_ext=="*" || ext==allowed_ext) {
result[allFilesCount][0] = fileName.substring(fileName.lastIndexOf("/") + 1);
result[allFilesCount][1] = file2.path();
result[allFilesCount][2] = "file";
Expand Down Expand Up @@ -373,7 +373,7 @@ void readFs(FS fs, String folder, String result[][3]) {
** Function: loopSD
** Where you choose what to do with your SD Files
**********************************************************************/
String loopSD(FS &fs, bool filePicker) {
String loopSD(FS &fs, bool filePicker, String allowed_ext) {
String result = "";
bool reload=false;
bool redraw = true;
Expand All @@ -386,7 +386,7 @@ String loopSD(FS &fs, bool filePicker) {
closeSdCard();
setupSdCard();

readFs(fs, Folder, fileList);
readFs(fs, Folder, fileList, allowed_ext);

for(int i=0; i<MAXFILES; i++) if(fileList[i][2]!="") maxFiles++; else break;
while(1){
Expand All @@ -397,7 +397,7 @@ String loopSD(FS &fs, bool filePicker) {
tft.fillScreen(BGCOLOR);
tft.drawRoundRect(5,5,WIDTH-10,HEIGHT-10,5,FGCOLOR);
index=0;
readFs(fs, Folder, fileList);
readFs(fs, Folder, fileList, allowed_ext);
PreFolder = Folder;
maxFiles=0;
for(int i=0; i<MAXFILES; i++) if(fileList[i][2]!="") maxFiles++; else break;
Expand Down
4 changes: 2 additions & 2 deletions src/core/sd_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ bool createFolder(FS fs, String path);

String readLineFromFile(File myFile);

void readFs(FS fs, String folder, String result[][3]);
void readFs(FS fs, String folder, String result[][3], String allowed_ext = "*");

void sortList(String fileList[][3], int fileListCount);

String loopSD(FS &fs, bool filePicker = false);
String loopSD(FS &fs, bool filePicker = false, String allowed_ext = "*");
3 changes: 1 addition & 2 deletions src/modules/others/TV-B-Gone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,7 @@ void otherIRcodes() {
// no need to proceed, go back
}

//filepath = loopSD(*fs, true, "IR");
filepath = loopSD(*fs, true);
filepath = loopSD(*fs, true, "IR");
databaseFile = fs->open(filepath, FILE_READ);
drawMainBorder();
pinMode(IrTx, OUTPUT);
Expand Down
3 changes: 1 addition & 2 deletions src/modules/rf/rf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ void otherRFcodes() {
// no need to proceed, go back
}

//filepath = loopSD(*fs, true, "SUB");
filepath = loopSD(*fs, true);
filepath = loopSD(*fs, true, "SUB");
databaseFile = fs->open(filepath, FILE_READ);
drawMainBorder();

Expand Down

0 comments on commit b84f61f

Please sign in to comment.