|
Marlin parse SD file update LCD July 14, 2015 12:51PM |
Registered: 11 years ago Posts: 126 |
case 23: //M23 - Select file
starpos = (strchr(strchr_pointer + 4,'*'));
if(starpos!=NULL)
*(starpos)='\0';
// my note : add code to count the Z axis commands ( layers ) in the file and the G1 print lines in the file
#ifdef SDSUPPORT
#ifdef ShowLayerCountAndEstTime
CountLinesAndLayers = true;
#endif //layer counter
#endif //SDSUPPORT
break;
ClearToSend();
if(CountLinesAndLayers == true){ // read the SD file and count the lines and layers
CountLinesAndLayers = false;
// update the LCD here and display a message to say "Reading SD file .."
PrintLinesTotal = 0;
LayerCountTotal = 0;
card.openFile(strchr_pointer + 4,true);
chPos = 0; // pointer for position of next char in buffer array
while(!card.eof()){
int16_t n=card.get();
serial_char = (char)n;
if(chPos < 59) SDbuffer[chPos] = serial_char;
if(chPos >= 1 && chPos < 99){ // chPos = 99 is set when X or Z is found, so used to skip the check until the next end of line char
// reset the counters if custom gcode comment ';SLC' that was added in Slic3r at the start of the print job, after the nozzle was positioned
if(chPos == 3){
if(SDbuffer[0] == ';' && SDbuffer[1] == 'S' && SDbuffer[2] == 'L' && SDbuffer[3] == 'C'){ // check if the buffer line starts with ';SLC' ( SLC = Start Layer Count )
LayersToIgnore = LayerCountTotal;
MYSERIAL.print("Set LayersToIgnore = ");
MYSERIAL.println(LayersToIgnore);
PrintLinesTotal=0;
LayerCountTotal=0;
}
}
if(SDbuffer[0] == 'G' && SDbuffer[1] == '1'){ // check if the buffer line starts with 'G1'
if(serial_char == 'X'){
PrintLinesTotal++;
chPos = 99;
}
if(serial_char == 'Z'){
LayerCountTotal++;
MYSERIAL.print("LayerCountTotal = ");
MYSERIAL.println(LayerCountTotal);
chPos = 99;
}
}
}
chPos++;
if(serial_char == '\n'){ // if the character read from the SD card is a line ending
chPos = 0; // reset the position for the next character in the buffer. Set to 0 = empty the buffer.
}
}
card.closefile();
delay(200);
card.openFile(strchr_pointer + 4,true); //this is in M23 - Select file
} // end of : if(CountLinesAndLayers = true)
|
Re: Marlin parse SD file update LCD July 15, 2015 03:33PM |
Registered: 11 years ago Posts: 126 |