Commit d344f75a authored by MagoKimbra's avatar MagoKimbra

Fix cardreader.cpp

parent dcca8c7e
...@@ -5621,16 +5621,9 @@ inline void gcode_M220() { ...@@ -5621,16 +5621,9 @@ inline void gcode_M220() {
* M221: Set extrusion percentage (M221 T0 S95) * M221: Set extrusion percentage (M221 T0 S95)
*/ */
inline void gcode_M221() { inline void gcode_M221() {
if (code_seen('S')) {
int sval = code_value();
if (code_seen('T')) {
if (setTargetedExtruder(221)) return; if (setTargetedExtruder(221)) return;
extruder_multiplier[target_extruder] = sval;
} if (code_seen('S')) extruder_multiplier[target_extruder] = code_value();
else {
extruder_multiplier[active_extruder] = sval;
}
}
} }
/** /**
...@@ -5639,9 +5632,7 @@ inline void gcode_M221() { ...@@ -5639,9 +5632,7 @@ inline void gcode_M221() {
inline void gcode_M222() { inline void gcode_M222() {
if (setTargetedExtruder(222)) return; if (setTargetedExtruder(222)) return;
if (code_seen('S')) { if (code_seen('S')) density_multiplier[target_extruder] = code_value();
density_multiplier[target_extruder] = code_value();
}
} }
/** /**
......
...@@ -99,8 +99,9 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma ...@@ -99,8 +99,9 @@ void CardReader::lsDive(const char* prepend, SdFile parent, const char* const ma
nrFiles++; nrFiles++;
break; break;
case LS_SerialPrint: case LS_SerialPrint:
createFilename(filename, p);
ECHO_T(prepend); ECHO_T(prepend);
ECHO_ET(longFilename); ECHO_ET(filename);
break; break;
case LS_GetFilename: case LS_GetFilename:
createFilename(filename, p); createFilename(filename, p);
...@@ -328,39 +329,15 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, ...@@ -328,39 +329,15 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
else // relative path else // relative path
curDir = &workDir; curDir = &workDir;
char newName[FILENAME_LENGTH + 2];
if (strlen((char *)fname) >= 9) {
// Generate 8.3 from longfile name
char *pExt, szExt[5];
if ((pExt = strchr((char *)fname, '.')) != NULL) {
strncpy(szExt, pExt, 4);
szExt[4] = 0;
if (pExt > (char*)fname + 6) pExt = (char*)fname + 6;
}
else {
szExt[0] = 0;
pExt = (char*)fname + 6;
}
uint8_t cb = pExt - (char *)fname;
memcpy(newName, fname, cb);
newName[cb] = 0;
strcat(newName, "~1");
strcat(newName, szExt);
}
else {
memcpy(newName, fname, FILENAME_LENGTH + 2);
}
if (read) { if (read) {
if (file.open(curDir, newName, O_READ)) { if (file.open(curDir, fname, O_READ)) {
filesize = file.fileSize(); filesize = file.fileSize();
ECHO_MT(SERIAL_SD_FILE_OPENED, fname); ECHO_MT(SERIAL_SD_FILE_OPENED, fname);
ECHO_EMV(SERIAL_SD_SIZE, filesize); ECHO_EMV(SERIAL_SD_SIZE, filesize);
sdpos = 0; sdpos = 0;
ECHO_EM(SERIAL_SD_FILE_SELECTED); ECHO_EM(SERIAL_SD_FILE_SELECTED);
getfilename(0, newName); getfilename(0, fname);
if(lcd_status) lcd_setstatus(longFilename[0] ? longFilename : fname); if(lcd_status) lcd_setstatus(longFilename[0] ? longFilename : fname);
} }
else { else {
...@@ -368,7 +345,7 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/, ...@@ -368,7 +345,7 @@ void CardReader::openFile(char* name, bool read, bool replace_current/*=true*/,
} }
} }
else { //write else { //write
if (!file.open(curDir, newName, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) { if (!file.open(curDir, fname, O_CREAT | O_APPEND | O_WRITE | O_TRUNC)) {
ECHO_LMT(ER, SERIAL_SD_OPEN_FILE_FAIL, fname); ECHO_LMT(ER, SERIAL_SD_OPEN_FILE_FAIL, fname);
} }
else { else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment