|
@@ -82,6 +82,7 @@ char version_string[] = "1.0.0 Alpha 1";
|
82
|
82
|
// M27 - Report SD print status
|
83
|
83
|
// M28 - Start SD write (M28 filename.g)
|
84
|
84
|
// M29 - Stop SD write
|
|
85
|
+// M30 - Output time since last M109 or SD card start to serial
|
85
|
86
|
// M42 - Change pin status via gcode
|
86
|
87
|
// M80 - Turn on Power Supply
|
87
|
88
|
// M81 - Turn off Power Supply
|
|
@@ -172,24 +173,30 @@ bool savetosd = false;
|
172
|
173
|
int16_t n;
|
173
|
174
|
unsigned long autostart_atmillis=0;
|
174
|
175
|
|
175
|
|
-void initsd(){
|
|
176
|
+void initsd()
|
|
177
|
+{
|
176
|
178
|
sdactive = false;
|
177
|
179
|
#if SDSS >- 1
|
178
|
180
|
if(root.isOpen())
|
179
|
181
|
root.close();
|
180
|
|
- if (!card.init(SPI_FULL_SPEED,SDSS)){
|
|
182
|
+ if (!card.init(SPI_FULL_SPEED,SDSS))
|
|
183
|
+ {
|
181
|
184
|
//if (!card.init(SPI_HALF_SPEED,SDSS))
|
182
|
|
- Serial.println("SD init fail");
|
|
185
|
+ SERIAL_ECHOLN("SD init fail");
|
183
|
186
|
}
|
184
|
187
|
else if (!volume.init(&card))
|
185
|
|
- Serial.println("volume.init failed");
|
|
188
|
+ {
|
|
189
|
+ SERIAL_ERRORLN("volume.init failed");
|
|
190
|
+ }
|
186
|
191
|
else if (!root.openRoot(&volume))
|
187
|
|
- Serial.println("openRoot failed");
|
|
192
|
+ {
|
|
193
|
+ SERIAL_ERRORLN("openRoot failed");
|
|
194
|
+ }
|
188
|
195
|
else
|
189
|
|
- {
|
|
196
|
+ {
|
190
|
197
|
sdactive = true;
|
191
|
|
- Serial.println("SD card ok");
|
192
|
|
- }
|
|
198
|
+ SERIAL_ECHOLN("SD card ok");
|
|
199
|
+ }
|
193
|
200
|
#endif //SDSS
|
194
|
201
|
}
|
195
|
202
|
|
|
@@ -214,7 +221,7 @@ inline void write_command(char *buf){
|
214
|
221
|
//Serial.println(begin);
|
215
|
222
|
file.write(begin);
|
216
|
223
|
if (file.writeError){
|
217
|
|
- Serial.println("error writing to file");
|
|
224
|
+ SERIAL_ERRORLN("error writing to file");
|
218
|
225
|
}
|
219
|
226
|
}
|
220
|
227
|
#endif //SDSUPPORT
|
|
@@ -227,7 +234,7 @@ void enquecommand(const char *cmd)
|
227
|
234
|
{
|
228
|
235
|
//this is dangerous if a mixing of serial and this happsens
|
229
|
236
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
230
|
|
- Serial.print("en:");Serial.println(cmdbuffer[bufindw]);
|
|
237
|
+ SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
|
231
|
238
|
bufindw= (bufindw + 1)%BUFSIZE;
|
232
|
239
|
buflen += 1;
|
233
|
240
|
}
|
|
@@ -237,7 +244,7 @@ void setup()
|
237
|
244
|
{
|
238
|
245
|
|
239
|
246
|
Serial.begin(BAUDRATE);
|
240
|
|
- ECHOLN("Marlin "<<version_string);
|
|
247
|
+ SERIAL_ECHOLN("Marlin "<<version_string);
|
241
|
248
|
Serial.println("start");
|
242
|
249
|
#if defined FANCY_LCD || defined SIMPLE_LCD
|
243
|
250
|
lcd_init();
|
|
@@ -478,17 +485,17 @@ inline void get_command()
|
478
|
485
|
sdpos = file.curPosition();
|
479
|
486
|
if(sdpos >= filesize){
|
480
|
487
|
sdmode = false;
|
481
|
|
- Serial.println("Done printing file");
|
482
|
|
- stoptime=millis();
|
483
|
|
- char time[30];
|
484
|
|
- unsigned long t=(stoptime-starttime)/1000;
|
485
|
|
- int sec,min;
|
486
|
|
- min=t/60;
|
487
|
|
- sec=t%60;
|
488
|
|
- sprintf(time,"%i min, %i sec",min,sec);
|
489
|
|
- Serial.println(time);
|
490
|
|
- LCD_MESSAGE(time);
|
491
|
|
- checkautostart(true);
|
|
488
|
+ Serial.println("echo: Done printing file");
|
|
489
|
+ stoptime=millis();
|
|
490
|
+ char time[30];
|
|
491
|
+ unsigned long t=(stoptime-starttime)/1000;
|
|
492
|
+ int sec,min;
|
|
493
|
+ min=t/60;
|
|
494
|
+ sec=t%60;
|
|
495
|
+ sprintf(time,"echo: %i min, %i sec",min,sec);
|
|
496
|
+ Serial.println(time);
|
|
497
|
+ LCD_MESSAGE(time);
|
|
498
|
+ checkautostart(true);
|
492
|
499
|
}
|
493
|
500
|
if(!serial_count) return; //if empty line
|
494
|
501
|
cmdbuffer[bufindw][serial_count] = 0; //terminate string
|
|
@@ -721,7 +728,7 @@ inline void process_commands()
|
721
|
728
|
case 24: //M24 - Start SD print
|
722
|
729
|
if(sdactive){
|
723
|
730
|
sdmode = true;
|
724
|
|
- starttime=millis();
|
|
731
|
+ starttime=millis();
|
725
|
732
|
}
|
726
|
733
|
break;
|
727
|
734
|
case 25: //M25 - Pause SD print
|
|
@@ -774,19 +781,19 @@ inline void process_commands()
|
774
|
781
|
//processed in write to file routine above
|
775
|
782
|
//savetosd = false;
|
776
|
783
|
break;
|
777
|
|
- case 30:
|
778
|
|
- {
|
779
|
|
- stoptime=millis();
|
780
|
|
- char time[30];
|
781
|
|
- unsigned long t=(stoptime-starttime)/1000;
|
782
|
|
- int sec,min;
|
783
|
|
- min=t/60;
|
784
|
|
- sec=t%60;
|
785
|
|
- sprintf(time,"%i min, %i sec",min,sec);
|
786
|
|
- Serial.println(time);
|
787
|
|
- LCD_MESSAGE(time);
|
788
|
|
- }
|
789
|
|
- break;
|
|
784
|
+ case 30: //M30 take time since the start of the SD print or an M109 command
|
|
785
|
+ {
|
|
786
|
+ stoptime=millis();
|
|
787
|
+ char time[30];
|
|
788
|
+ unsigned long t=(stoptime-starttime)/1000;
|
|
789
|
+ int sec,min;
|
|
790
|
+ min=t/60;
|
|
791
|
+ sec=t%60;
|
|
792
|
+ sprintf(time,"echo: time needed %i min, %i sec",min,sec);
|
|
793
|
+ Serial.println(time);
|
|
794
|
+ LCD_MESSAGE(time);
|
|
795
|
+ }
|
|
796
|
+ break;
|
790
|
797
|
#endif //SDSUPPORT
|
791
|
798
|
case 42: //M42 -Change pin status via gcode
|
792
|
799
|
if (code_seen('S'))
|
|
@@ -847,7 +854,7 @@ inline void process_commands()
|
847
|
854
|
Serial.println();
|
848
|
855
|
#endif
|
849
|
856
|
#else
|
850
|
|
- Serial.println("No thermistors - no temp");
|
|
857
|
+ Serial.println("echo: No thermistors - no temp");
|
851
|
858
|
#endif
|
852
|
859
|
return;
|
853
|
860
|
//break;
|
|
@@ -888,7 +895,8 @@ inline void process_commands()
|
888
|
895
|
}
|
889
|
896
|
#endif //TEMP_RESIDENCY_TIME
|
890
|
897
|
}
|
891
|
|
- LCD_MESSAGE("Marlin ready.");
|
|
898
|
+ LCD_MESSAGE("Heating done.");
|
|
899
|
+ starttime=millis();
|
892
|
900
|
}
|
893
|
901
|
break;
|
894
|
902
|
case 190: // M190 - Wait bed for heater to reach target.
|
|
@@ -1063,9 +1071,9 @@ inline void process_commands()
|
1063
|
1071
|
if(code_seen('P')) Kp = code_value();
|
1064
|
1072
|
if(code_seen('I')) Ki = code_value()*PID_dT;
|
1065
|
1073
|
if(code_seen('D')) Kd = code_value()/PID_dT;
|
1066
|
|
-// ECHOLN("Kp "<<_FLOAT(Kp,2));
|
1067
|
|
-// ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
|
1068
|
|
-// ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
|
|
1074
|
+// SERIAL_ECHOLN("Kp "<<_FLOAT(Kp,2));
|
|
1075
|
+// SERIAL_ECHOLN("Ki "<<_FLOAT(Ki/PID_dT,2));
|
|
1076
|
+// SERIAL_ECHOLN("Kd "<<_FLOAT(Kd*PID_dT,2));
|
1069
|
1077
|
|
1070
|
1078
|
// temp_iState_min = 0.0;
|
1071
|
1079
|
// if (Ki!=0) {
|
|
@@ -1093,8 +1101,9 @@ inline void process_commands()
|
1093
|
1101
|
}
|
1094
|
1102
|
}
|
1095
|
1103
|
else{
|
1096
|
|
- Serial.println("Unknown command:");
|
1097
|
|
- Serial.println(cmdbuffer[bufindr]);
|
|
1104
|
+ Serial.print("echo: Unknown command:\"");
|
|
1105
|
+ Serial.print(cmdbuffer[bufindr]);
|
|
1106
|
+ Serial.println("\"");
|
1098
|
1107
|
}
|
1099
|
1108
|
|
1100
|
1109
|
ClearToSend();
|
|
@@ -1288,7 +1297,7 @@ void kill()
|
1288
|
1297
|
disable_e();
|
1289
|
1298
|
|
1290
|
1299
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
1291
|
|
- Serial.println("!! Printer halted. kill() called !!");
|
|
1300
|
+ SERIAL_ERRORLN("Printer halted. kill() called !!");
|
1292
|
1301
|
while(1); // Wait for reset
|
1293
|
1302
|
}
|
1294
|
1303
|
|