Remove 8+3 filename crap when usind longer files on Anycubic 0.0.2 Display. It's now cut off at 26 characters but still displayed.

This commit is contained in:
Knutwurst
2022-02-04 23:36:04 +01:00
parent b217d9fe69
commit ff88387916
2 changed files with 26 additions and 14 deletions

View File

@@ -1177,17 +1177,22 @@ void AnycubicTouchscreenClass::PrintList() {
else { else {
card.selectFileByIndex(count - 1); card.selectFileByIndex(count - 1);
// Bugfix for non-printable special characters
// which are now replaced by underscores.
int fileNameLen = strlen(card.longFilename); int fileNameLen = strlen(card.longFilename);
bool fileNameWasCut = false;
// Cut off too long filenames. // Cut off too long filenames.
// They don't fit on the screen anyways. // They don't fit on the screen anyway.
//if (fileNameLen > MAX_PRINTABLE_FILENAME_LEN) #if ENABLED(KNUTWURST_DGUS2_TFT)
// fileNameLen = MAX_PRINTABLE_FILENAME_LEN; if (fileNameLen >= MAX_PRINTABLE_FILENAME_LEN) {
fileNameWasCut = true;
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
}
#endif
char outputString[fileNameLen]; char outputString[fileNameLen];
// Bugfix for non-printable special characters
// which are now replaced by underscores.
for (unsigned char i = 0; i <= fileNameLen; i++) { for (unsigned char i = 0; i <= fileNameLen; i++) {
if (i >= fileNameLen) { if (i >= fileNameLen) {
outputString[i] = ' '; outputString[i] = ' ';
@@ -1200,6 +1205,17 @@ void AnycubicTouchscreenClass::PrintList() {
} }
} }
// I know, it's ugly, but it's faster than a string lib
if(fileNameWasCut) {
outputString[fileNameLen-7] = '~';
outputString[fileNameLen-6] = '.';
outputString[fileNameLen-5] = 'g';
outputString[fileNameLen-4] = 'c';
outputString[fileNameLen-3] = 'o';
outputString[fileNameLen-2] = 'd';
outputString[fileNameLen-1] = 'e';
}
outputString[fileNameLen] = '\0'; outputString[fileNameLen] = '\0';
if (card.flag.filenameIsDir) { if (card.flag.filenameIsDir) {
@@ -1210,20 +1226,16 @@ void AnycubicTouchscreenClass::PrintList() {
HARDWARE_SERIAL_PROTOCOLPGM("/"); HARDWARE_SERIAL_PROTOCOLPGM("/");
HARDWARE_SERIAL_PROTOCOL(outputString); HARDWARE_SERIAL_PROTOCOL(outputString);
HARDWARE_SERIAL_PROTOCOLLNPGM(".gcode"); HARDWARE_SERIAL_PROTOCOLLNPGM(".gcode");
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
#else #else
HARDWARE_SERIAL_PROTOCOL("/"); HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(card.filename); HARDWARE_SERIAL_PROTOCOLLN(card.filename);
HARDWARE_SERIAL_PROTOCOL("/"); HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(outputString); HARDWARE_SERIAL_PROTOCOLLN(outputString);
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
#endif #endif
} SERIAL_ECHO(count);
else { SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
} else {
HARDWARE_SERIAL_PROTOCOLLN(card.filename); HARDWARE_SERIAL_PROTOCOLLN(card.filename);
HARDWARE_SERIAL_PROTOCOLLN(outputString); HARDWARE_SERIAL_PROTOCOLLN(outputString);
SERIAL_ECHO(count); SERIAL_ECHO(count);

View File

@@ -46,7 +46,7 @@ char *ftostr32(const float &);
#define TFTBUFSIZE 4 #define TFTBUFSIZE 4
#define TFT_MAX_CMD_SIZE 96 #define TFT_MAX_CMD_SIZE 96
#define MSG_MY_VERSION CUSTOM_BUILD_VERSION #define MSG_MY_VERSION CUSTOM_BUILD_VERSION
#define MAX_PRINTABLE_FILENAME_LEN 30 #define MAX_PRINTABLE_FILENAME_LEN 26
#if ENABLED(KNUTWURST_CHIRON) #if ENABLED(KNUTWURST_CHIRON)
#define FILAMENT_RUNOUT_PIN 33 #define FILAMENT_RUNOUT_PIN 33