🧑💻 Anycubic shared code (#25690)
This commit is contained in:
@@ -63,7 +63,7 @@ FileNavigator filenavigator;
|
||||
FileList FileNavigator::filelist; // Instance of the Marlin file API
|
||||
uint16_t FileNavigator::lastpanelindex;
|
||||
uint16_t FileNavigator::currentindex; // override the panel request
|
||||
uint8_t FileNavigator::currentfolderdepth;
|
||||
uint8_t FileNavigator::folderdepth;
|
||||
uint16_t FileNavigator::currentfolderindex[MAX_FOLDER_DEPTH]; // track folder pos for iteration
|
||||
char FileNavigator::currentfoldername[MAX_PATH_LEN + 1]; // Current folder path
|
||||
|
||||
@@ -71,7 +71,7 @@ FileNavigator::FileNavigator() { reset(); }
|
||||
|
||||
void FileNavigator::reset() {
|
||||
currentfoldername[0] = '\0';
|
||||
currentfolderdepth = 0;
|
||||
folderdepth = 0;
|
||||
currentindex = 0;
|
||||
lastpanelindex = 0;
|
||||
ZERO(currentfolderindex);
|
||||
@@ -84,25 +84,25 @@ void FileNavigator::reset() {
|
||||
void FileNavigator::refresh() { filelist.refresh(); }
|
||||
|
||||
void FileNavigator::changeDIR(const char *folder) {
|
||||
if (currentfolderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
|
||||
currentfolderindex[currentfolderdepth] = currentindex;
|
||||
if (folderdepth >= MAX_FOLDER_DEPTH) return; // limit the folder depth
|
||||
currentfolderindex[folderdepth] = currentindex;
|
||||
strcat(currentfoldername, folder);
|
||||
strcat(currentfoldername, "/");
|
||||
filelist.changeDir(folder);
|
||||
currentfolderdepth++;
|
||||
folderdepth++;
|
||||
currentindex = 0;
|
||||
}
|
||||
|
||||
void FileNavigator::upDIR() {
|
||||
if (!filelist.isAtRootDir()) {
|
||||
filelist.upDir();
|
||||
currentfolderdepth--;
|
||||
currentindex = currentfolderindex[currentfolderdepth]; // restore last position in the folder
|
||||
folderdepth--;
|
||||
currentindex = currentfolderindex[folderdepth]; // restore last position in the folder
|
||||
filelist.seek(currentindex); // restore file information
|
||||
}
|
||||
|
||||
// Remove the child folder from the stored path
|
||||
if (currentfolderdepth == 0)
|
||||
if (folderdepth == 0)
|
||||
currentfoldername[0] = '\0';
|
||||
else {
|
||||
char * const pos = strchr(currentfoldername, '/');
|
||||
@@ -122,7 +122,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
|
||||
changeDIR(filelist.shortFilename());
|
||||
} // valid file
|
||||
if (currentindex == filelist.count()) {
|
||||
if (currentfolderdepth > 0) {
|
||||
if (folderdepth > 0) {
|
||||
upDIR();
|
||||
currentindex++;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
|
||||
}
|
||||
lastpanelindex = index;
|
||||
|
||||
if (currentindex == 0 && currentfolderdepth > 0) { // Add a link to go up a folder
|
||||
if (currentindex == 0 && folderdepth > 0) { // Add a link to go up a folder
|
||||
// The new panel ignores entries that don't end in .GCO or .gcode so add and pad them.
|
||||
if (paneltype <= AC_panel_new) {
|
||||
TFTSer.println("<<.GCO");
|
||||
@@ -186,7 +186,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
|
||||
}
|
||||
else { // Not DIR
|
||||
TFTSer.write('/');
|
||||
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
|
||||
if (folderdepth > 0) TFTSer.print(currentfoldername);
|
||||
TFTSer.println(filelist.shortFilename());
|
||||
TFTSer.print(filelist.longFilename());
|
||||
|
||||
@@ -221,7 +221,7 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
|
||||
} // valid file
|
||||
|
||||
if (currentindex == filelist.count()) {
|
||||
if (currentfolderdepth > 0) {
|
||||
if (folderdepth > 0) {
|
||||
upDIR();
|
||||
currentindex++;
|
||||
}
|
||||
@@ -233,9 +233,9 @@ void FileNavigator::skiptofileindex(uint16_t skip) {
|
||||
|
||||
void FileNavigator::sendFile(panel_type_t paneltype) {
|
||||
TFTSer.write('/');
|
||||
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
|
||||
if (folderdepth > 0) TFTSer.print(currentfoldername);
|
||||
TFTSer.println(filelist.shortFilename());
|
||||
if (currentfolderdepth > 0) TFTSer.print(currentfoldername);
|
||||
if (folderdepth > 0) TFTSer.print(currentfoldername);
|
||||
TFTSer.println(filelist.longFilename());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user