Fix for #197 Print Menu file list, when there were exactely 3 files or folders on the sd card. This was caused by a misinterpreted comparision between uint16_t and integer.

This commit is contained in:
Knutwurst
2021-09-17 21:28:42 +02:00
parent f8208b7e5e
commit ad974e176c
3 changed files with 38 additions and 32 deletions

View File

@@ -1312,18 +1312,13 @@
#define Z_CLEARANCE_MULTI_PROBE 5 // Z Clearance between multiple probes
//#define Z_AFTER_PROBING 5 // Z position after probing is done
#if ENABLED(KNUTWURST_BLTOUCH)
#define Z_PROBE_LOW_POINT -10 // Farthest distance below the trigger-point to go before stopping
#endif
#if DISABLED(KNUTWURST_BLTOUCH)
#define Z_PROBE_LOW_POINT -12 // Farthest distance below the trigger-point to go before stopping
#endif
#define Z_PROBE_LOW_POINT -12 // Farthest distance below the trigger-point to go before stopping
// For M851 give a range for adjusting the Z probe offset
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20
#define Z_PROBE_OFFSET_RANGE_MIN -30
#define Z_PROBE_OFFSET_RANGE_MAX 30
// Enable the M48 repeatability test to test probe accuracy
#if ENABLED(KNUTWURST_BLTOUCH)

View File

@@ -1134,24 +1134,33 @@ void AnycubicTouchscreenClass::PrintList()
if (card.isMounted())
#endif
{
uint16_t count = filenumber;
uint16_t max_files;
uint16_t MyFileNrCnt = card.countFilesInWorkDir();
int count = filenumber;
int max_files;
int filesOnSDCard = card.countFilesInWorkDir();
// What is this shit? What if there are exactely 3 files+folders?
// TODO: find something better than this crap.
if ((MyFileNrCnt - filenumber) < 4)
if ((filesOnSDCard - filenumber) < 4)
{
max_files = MyFileNrCnt;
max_files = filesOnSDCard;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLN("max_files = filesOnSDCard;");
#endif
}
else
{
max_files = filenumber + 3;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOLN("max_files = filenumber + 3;");
#endif
}
for (count = filenumber; count <= max_files; count++)
{
//max_files = filesOnSDCard;
#ifdef ANYCUBIC_TFT_DEBUG
SERIAL_ECHOPGM("filesOnSDCard: ");
SERIAL_ECHOLN(filesOnSDCard);
SERIAL_ECHOPGM("filenumber: ");
SERIAL_ECHOLN(filenumber);
SERIAL_ECHOPGM("max_files: ");
@@ -1160,6 +1169,8 @@ void AnycubicTouchscreenClass::PrintList()
SERIAL_ECHOLN(count);
#endif
for (count = filenumber; count <= max_files; count++)
{
if (count == 0) // Special Entry
{
if (strcmp(card.getWorkDirName(), "/") == 0)
@@ -1215,23 +1226,23 @@ void AnycubicTouchscreenClass::PrintList()
if (card.flag.filenameIsDir)
{
#if ENABLED(KNUTWURST_DGUS2_TFT)
HARDWARE_SERIAL_PROTOCOLPGM("/");
HARDWARE_SERIAL_PROTOCOL(card.filename);
HARDWARE_SERIAL_PROTOCOLLNPGM(".GCO");
HARDWARE_SERIAL_PROTOCOLPGM("/");
HARDWARE_SERIAL_PROTOCOL(outputString);
HARDWARE_SERIAL_PROTOCOLLNPGM(".gcode");
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
HARDWARE_SERIAL_PROTOCOLPGM("/");
HARDWARE_SERIAL_PROTOCOL(card.filename);
HARDWARE_SERIAL_PROTOCOLLNPGM(".GCO");
HARDWARE_SERIAL_PROTOCOLPGM("/");
HARDWARE_SERIAL_PROTOCOL(outputString);
HARDWARE_SERIAL_PROTOCOLLNPGM(".gcode");
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
#else
HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(card.filename);
HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(outputString);
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(card.filename);
HARDWARE_SERIAL_PROTOCOL("/");
HARDWARE_SERIAL_PROTOCOLLN(outputString);
SERIAL_ECHO(count);
SERIAL_ECHOPGM(": /");
SERIAL_ECHOLN(outputString);
#endif
}
else

View File

@@ -281,7 +281,7 @@ private:
int serial3_count = 0;
char *TFTstrchr_pointer;
char FlagResumFromOutage = 0;
uint16_t filenumber = 0;
int filenumber = 0;
unsigned long starttime = 0;
unsigned long stoptime = 0;
uint8_t tmp_extruder = 0;