Merge pull request #473 from stklcode/fix/render-current-folder
use static initialization for output string in RenderCurrentFolder
This commit is contained in:
@@ -830,7 +830,6 @@ void AnycubicTouchscreenClass::RenderSpecialMenu(uint16_t selectedNumber) {
|
||||
|
||||
void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
|
||||
FileList currentFileList;
|
||||
uint16_t count = selectedNumber;
|
||||
uint16_t max_files;
|
||||
uint16_t filesOnSDCard = currentFileList.count();
|
||||
|
||||
@@ -850,7 +849,7 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
|
||||
selectedNumber = 0;
|
||||
}
|
||||
|
||||
for (count = selectedNumber; count <= max_files; count++) {
|
||||
for (uint16_t count = selectedNumber; count <= max_files; count++) {
|
||||
if (count == 0) { // Special Entry
|
||||
if (currentFileList.isAtRootDir()) {
|
||||
SENDLINE_PGM(SM_SPECIAL_MENU_S);
|
||||
@@ -877,7 +876,7 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
|
||||
#endif
|
||||
|
||||
const char* fileName = currentFileList.filename();
|
||||
int fileNameLen = strlen(fileName);
|
||||
unsigned int fileNameLen = strlen(fileName);
|
||||
|
||||
// Cut off too long filenames.
|
||||
// They don't fit on the screen anyway.
|
||||
@@ -887,14 +886,11 @@ void AnycubicTouchscreenClass::RenderCurrentFolder(uint16_t selectedNumber) {
|
||||
fileNameWasCut = true;
|
||||
fileNameLen = MAX_PRINTABLE_FILENAME_LEN;
|
||||
}
|
||||
char outputString[MAX_PRINTABLE_FILENAME_LEN] = {'\0'};
|
||||
#else
|
||||
char outputString[fileNameLen] = {'\0'};
|
||||
#endif
|
||||
|
||||
// Bugfix for non-printable special characters
|
||||
// which are now replaced by underscores.
|
||||
for (unsigned char i = 0; i <= fileNameLen; i++) {
|
||||
// Bugfix for non-printable special characters which are now replaced by underscores.
|
||||
static char outputString[MAX_PRINTABLE_FILENAME_LEN] = {'\0'};
|
||||
for (unsigned int i = 0; i <= fileNameLen; i++) {
|
||||
if (isPrintable(fileName[i])) {
|
||||
outputString[i] = fileName[i];
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user