|
|
@ -82,6 +82,7 @@ char version_string[] = "1.0.0 Alpha 1";
|
|
|
|
// M27 - Report SD print status
|
|
|
|
// M27 - Report SD print status
|
|
|
|
// M28 - Start SD write (M28 filename.g)
|
|
|
|
// M28 - Start SD write (M28 filename.g)
|
|
|
|
// M29 - Stop SD write
|
|
|
|
// M29 - Stop SD write
|
|
|
|
|
|
|
|
// M30 - Output time since last M109 or SD card start to serial
|
|
|
|
// M42 - Change pin status via gcode
|
|
|
|
// M42 - Change pin status via gcode
|
|
|
|
// M80 - Turn on Power Supply
|
|
|
|
// M80 - Turn on Power Supply
|
|
|
|
// M81 - Turn off Power Supply
|
|
|
|
// M81 - Turn off Power Supply
|
|
|
@ -172,24 +173,30 @@ bool savetosd = false;
|
|
|
|
int16_t n;
|
|
|
|
int16_t n;
|
|
|
|
unsigned long autostart_atmillis=0;
|
|
|
|
unsigned long autostart_atmillis=0;
|
|
|
|
|
|
|
|
|
|
|
|
void initsd(){
|
|
|
|
void initsd()
|
|
|
|
|
|
|
|
{
|
|
|
|
sdactive = false;
|
|
|
|
sdactive = false;
|
|
|
|
#if SDSS >- 1
|
|
|
|
#if SDSS >- 1
|
|
|
|
if(root.isOpen())
|
|
|
|
if(root.isOpen())
|
|
|
|
root.close();
|
|
|
|
root.close();
|
|
|
|
if (!card.init(SPI_FULL_SPEED,SDSS)){
|
|
|
|
if (!card.init(SPI_FULL_SPEED,SDSS))
|
|
|
|
|
|
|
|
{
|
|
|
|
//if (!card.init(SPI_HALF_SPEED,SDSS))
|
|
|
|
//if (!card.init(SPI_HALF_SPEED,SDSS))
|
|
|
|
Serial.println("SD init fail");
|
|
|
|
SERIAL_ECHOLN("SD init fail");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (!volume.init(&card))
|
|
|
|
else if (!volume.init(&card))
|
|
|
|
Serial.println("volume.init failed");
|
|
|
|
{
|
|
|
|
|
|
|
|
SERIAL_ERRORLN("volume.init failed");
|
|
|
|
|
|
|
|
}
|
|
|
|
else if (!root.openRoot(&volume))
|
|
|
|
else if (!root.openRoot(&volume))
|
|
|
|
Serial.println("openRoot failed");
|
|
|
|
{
|
|
|
|
|
|
|
|
SERIAL_ERRORLN("openRoot failed");
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
sdactive = true;
|
|
|
|
sdactive = true;
|
|
|
|
Serial.println("SD card ok");
|
|
|
|
SERIAL_ECHOLN("SD card ok");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif //SDSS
|
|
|
|
#endif //SDSS
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -214,7 +221,7 @@ inline void write_command(char *buf){
|
|
|
|
//Serial.println(begin);
|
|
|
|
//Serial.println(begin);
|
|
|
|
file.write(begin);
|
|
|
|
file.write(begin);
|
|
|
|
if (file.writeError){
|
|
|
|
if (file.writeError){
|
|
|
|
Serial.println("error writing to file");
|
|
|
|
SERIAL_ERRORLN("error writing to file");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
#endif //SDSUPPORT
|
|
|
@ -227,7 +234,7 @@ void enquecommand(const char *cmd)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//this is dangerous if a mixing of serial and this happsens
|
|
|
|
//this is dangerous if a mixing of serial and this happsens
|
|
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
|
|
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
|
|
|
Serial.print("en:");Serial.println(cmdbuffer[bufindw]);
|
|
|
|
SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
|
|
|
|
bufindw= (bufindw + 1)%BUFSIZE;
|
|
|
|
bufindw= (bufindw + 1)%BUFSIZE;
|
|
|
|
buflen += 1;
|
|
|
|
buflen += 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -237,7 +244,7 @@ void setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
Serial.begin(BAUDRATE);
|
|
|
|
Serial.begin(BAUDRATE);
|
|
|
|
ECHOLN("Marlin "<<version_string);
|
|
|
|
SERIAL_ECHOLN("Marlin "<<version_string);
|
|
|
|
Serial.println("start");
|
|
|
|
Serial.println("start");
|
|
|
|
#if defined FANCY_LCD || defined SIMPLE_LCD
|
|
|
|
#if defined FANCY_LCD || defined SIMPLE_LCD
|
|
|
|
lcd_init();
|
|
|
|
lcd_init();
|
|
|
@ -478,17 +485,17 @@ inline void get_command()
|
|
|
|
sdpos = file.curPosition();
|
|
|
|
sdpos = file.curPosition();
|
|
|
|
if(sdpos >= filesize){
|
|
|
|
if(sdpos >= filesize){
|
|
|
|
sdmode = false;
|
|
|
|
sdmode = false;
|
|
|
|
Serial.println("Done printing file");
|
|
|
|
Serial.println("echo: Done printing file");
|
|
|
|
stoptime=millis();
|
|
|
|
stoptime=millis();
|
|
|
|
char time[30];
|
|
|
|
char time[30];
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
int sec,min;
|
|
|
|
int sec,min;
|
|
|
|
min=t/60;
|
|
|
|
min=t/60;
|
|
|
|
sec=t%60;
|
|
|
|
sec=t%60;
|
|
|
|
sprintf(time,"%i min, %i sec",min,sec);
|
|
|
|
sprintf(time,"echo: %i min, %i sec",min,sec);
|
|
|
|
Serial.println(time);
|
|
|
|
Serial.println(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
checkautostart(true);
|
|
|
|
checkautostart(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!serial_count) return; //if empty line
|
|
|
|
if(!serial_count) return; //if empty line
|
|
|
|
cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
|
|
|
cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
|
|
@ -721,7 +728,7 @@ inline void process_commands()
|
|
|
|
case 24: //M24 - Start SD print
|
|
|
|
case 24: //M24 - Start SD print
|
|
|
|
if(sdactive){
|
|
|
|
if(sdactive){
|
|
|
|
sdmode = true;
|
|
|
|
sdmode = true;
|
|
|
|
starttime=millis();
|
|
|
|
starttime=millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 25: //M25 - Pause SD print
|
|
|
|
case 25: //M25 - Pause SD print
|
|
|
@ -774,19 +781,19 @@ inline void process_commands()
|
|
|
|
//processed in write to file routine above
|
|
|
|
//processed in write to file routine above
|
|
|
|
//savetosd = false;
|
|
|
|
//savetosd = false;
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 30:
|
|
|
|
case 30: //M30 take time since the start of the SD print or an M109 command
|
|
|
|
{
|
|
|
|
{
|
|
|
|
stoptime=millis();
|
|
|
|
stoptime=millis();
|
|
|
|
char time[30];
|
|
|
|
char time[30];
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
unsigned long t=(stoptime-starttime)/1000;
|
|
|
|
int sec,min;
|
|
|
|
int sec,min;
|
|
|
|
min=t/60;
|
|
|
|
min=t/60;
|
|
|
|
sec=t%60;
|
|
|
|
sec=t%60;
|
|
|
|
sprintf(time,"%i min, %i sec",min,sec);
|
|
|
|
sprintf(time,"echo: time needed %i min, %i sec",min,sec);
|
|
|
|
Serial.println(time);
|
|
|
|
Serial.println(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
LCD_MESSAGE(time);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
#endif //SDSUPPORT
|
|
|
|
case 42: //M42 -Change pin status via gcode
|
|
|
|
case 42: //M42 -Change pin status via gcode
|
|
|
|
if (code_seen('S'))
|
|
|
|
if (code_seen('S'))
|
|
|
@ -847,7 +854,7 @@ inline void process_commands()
|
|
|
|
Serial.println();
|
|
|
|
Serial.println();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
Serial.println("No thermistors - no temp");
|
|
|
|
Serial.println("echo: No thermistors - no temp");
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
//break;
|
|
|
|
//break;
|
|
|
@ -888,7 +895,8 @@ inline void process_commands()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
#endif //TEMP_RESIDENCY_TIME
|
|
|
|
}
|
|
|
|
}
|
|
|
|
LCD_MESSAGE("Marlin ready.");
|
|
|
|
LCD_MESSAGE("Heating done.");
|
|
|
|
|
|
|
|
starttime=millis();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
case 190: // M190 - Wait bed for heater to reach target.
|
|
|
|
case 190: // M190 - Wait bed for heater to reach target.
|
|
|
@ -1063,9 +1071,9 @@ inline void process_commands()
|
|
|
|
if(code_seen('P')) Kp = code_value();
|
|
|
|
if(code_seen('P')) Kp = code_value();
|
|
|
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
|
|
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
|
|
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
|
|
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
|
|
|
// ECHOLN("Kp "<<_FLOAT(Kp,2));
|
|
|
|
// SERIAL_ECHOLN("Kp "<<_FLOAT(Kp,2));
|
|
|
|
// ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
|
|
|
|
// SERIAL_ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
|
|
|
|
// ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
|
|
|
|
// SERIAL_ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
|
|
|
|
|
|
|
|
|
|
|
|
// temp_iState_min = 0.0;
|
|
|
|
// temp_iState_min = 0.0;
|
|
|
|
// if (Ki!=0) {
|
|
|
|
// if (Ki!=0) {
|
|
|
@ -1093,8 +1101,9 @@ inline void process_commands()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
else{
|
|
|
|
Serial.println("Unknown command:");
|
|
|
|
Serial.print("echo: Unknown command:\"");
|
|
|
|
Serial.println(cmdbuffer[bufindr]);
|
|
|
|
Serial.print(cmdbuffer[bufindr]);
|
|
|
|
|
|
|
|
Serial.println("\"");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ClearToSend();
|
|
|
|
ClearToSend();
|
|
|
@ -1288,7 +1297,7 @@ void kill()
|
|
|
|
disable_e();
|
|
|
|
disable_e();
|
|
|
|
|
|
|
|
|
|
|
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
|
|
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
|
|
|
Serial.println("!! Printer halted. kill() called !!");
|
|
|
|
SERIAL_ERRORLN("Printer halted. kill() called !!");
|
|
|
|
while(1); // Wait for reset
|
|
|
|
while(1); // Wait for reset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|