|
@@ -101,7 +101,7 @@ char version_string[] = "1.0.0 Alpha 1";
|
101
|
101
|
// M220 - set speed factor override percentage S:factor in percent
|
102
|
102
|
// M301 - Set PID parameters P I and D
|
103
|
103
|
// M500 - stores paramters in EEPROM
|
104
|
|
-// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). D
|
|
104
|
+// M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily).
|
105
|
105
|
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
106
|
106
|
|
107
|
107
|
//Stepper Movement Variables
|
|
@@ -199,7 +199,10 @@ void enquecommand(const char *cmd)
|
199
|
199
|
{
|
200
|
200
|
//this is dangerous if a mixing of serial and this happsens
|
201
|
201
|
strcpy(&(cmdbuffer[bufindw][0]),cmd);
|
202
|
|
- SERIAL_ECHOLN("enqueing \""<<cmdbuffer[bufindw]<<"\"");
|
|
202
|
+ SERIAL_ECHO_START;
|
|
203
|
+ SERIAL_ECHOPGM("enqueing \"");
|
|
204
|
+ SERIAL_ECHO(cmdbuffer[bufindw]);
|
|
205
|
+ SERIAL_ECHOLNPGM("\"");
|
203
|
206
|
bufindw= (bufindw + 1)%BUFSIZE;
|
204
|
207
|
buflen += 1;
|
205
|
208
|
}
|
|
@@ -208,10 +211,13 @@ void enquecommand(const char *cmd)
|
208
|
211
|
void setup()
|
209
|
212
|
{
|
210
|
213
|
Serial.begin(BAUDRATE);
|
211
|
|
- SERIAL_ECHOLN("Marlin "<<version_string);
|
212
|
|
- SERIAL_PROTOCOLLN("start");
|
213
|
|
- Serial.print("echo: Free Memory:");
|
214
|
|
- serial.println(freeMemory());
|
|
214
|
+ SERIAL_ECHO_START;
|
|
215
|
+ SERIAL_ECHOPGM("Marlin ");
|
|
216
|
+ SERIAL_ECHOLN(version_string);
|
|
217
|
+ SERIAL_PROTOCOLLNPGM("start");
|
|
218
|
+ SERIAL_ECHO_START;
|
|
219
|
+ SERIAL_ECHOPGM("Free Memory:");
|
|
220
|
+ SERIAL_ECHOLN(freeMemory());
|
215
|
221
|
for(int8_t i = 0; i < BUFSIZE; i++)
|
216
|
222
|
{
|
217
|
223
|
fromsd[i] = false;
|
|
@@ -244,12 +250,12 @@ void loop()
|
244
|
250
|
if(strstr(cmdbuffer[bufindr],"M29") == NULL)
|
245
|
251
|
{
|
246
|
252
|
card.write_command(cmdbuffer[bufindr]);
|
247
|
|
- SERIAL_PROTOCOLLN("ok");
|
|
253
|
+ SERIAL_PROTOCOLLNPGM("ok");
|
248
|
254
|
}
|
249
|
255
|
else
|
250
|
256
|
{
|
251
|
257
|
card.closefile();
|
252
|
|
- SERIAL_PROTOCOLLN("Done saving file.");
|
|
258
|
+ SERIAL_PROTOCOLLNPGM("Done saving file.");
|
253
|
259
|
}
|
254
|
260
|
}
|
255
|
261
|
else
|
|
@@ -284,7 +290,9 @@ inline void get_command()
|
284
|
290
|
strchr_pointer = strchr(cmdbuffer[bufindw], 'N');
|
285
|
291
|
gcode_N = (strtol(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL, 10));
|
286
|
292
|
if(gcode_N != gcode_LastN+1 && (strstr(cmdbuffer[bufindw], "M110") == NULL) ) {
|
287
|
|
- SERIAL_ERRORLN("Line Number is not Last Line Number+1, Last Line:"<<gcode_LastN);
|
|
293
|
+ SERIAL_ERROR_START;
|
|
294
|
+ SERIAL_ERRORPGM("Line Number is not Last Line Number+1, Last Line:");
|
|
295
|
+ SERIAL_ERRORLN(gcode_LastN);
|
288
|
296
|
//Serial.println(gcode_N);
|
289
|
297
|
FlushSerialRequestResend();
|
290
|
298
|
serial_count = 0;
|
|
@@ -299,7 +307,9 @@ inline void get_command()
|
299
|
307
|
strchr_pointer = strchr(cmdbuffer[bufindw], '*');
|
300
|
308
|
|
301
|
309
|
if( (int)(strtod(&cmdbuffer[bufindw][strchr_pointer - cmdbuffer[bufindw] + 1], NULL)) != checksum) {
|
302
|
|
- SERIAL_ERRORLN("checksum mismatch, Last Line:"<<gcode_LastN);
|
|
310
|
+ SERIAL_ERROR_START;
|
|
311
|
+ SERIAL_ERRORPGM("checksum mismatch, Last Line:");
|
|
312
|
+ SERIAL_ERRORLN(gcode_LastN);
|
303
|
313
|
FlushSerialRequestResend();
|
304
|
314
|
serial_count = 0;
|
305
|
315
|
return;
|
|
@@ -308,7 +318,9 @@ inline void get_command()
|
308
|
318
|
}
|
309
|
319
|
else
|
310
|
320
|
{
|
311
|
|
- SERIAL_ERRORLN("No Checksum with line number, Last Line:"<<gcode_LastN);
|
|
321
|
+ SERIAL_ERROR_START;
|
|
322
|
+ SERIAL_ERRORPGM("No Checksum with line number, Last Line:");
|
|
323
|
+ SERIAL_ERRORLN(gcode_LastN);
|
312
|
324
|
FlushSerialRequestResend();
|
313
|
325
|
serial_count = 0;
|
314
|
326
|
return;
|
|
@@ -321,7 +333,9 @@ inline void get_command()
|
321
|
333
|
{
|
322
|
334
|
if((strstr(cmdbuffer[bufindw], "*") != NULL))
|
323
|
335
|
{
|
324
|
|
- SERIAL_ERRORLN("No Line Number with checksum, Last Line:"<<gcode_LastN);
|
|
336
|
+ SERIAL_ERROR_START;
|
|
337
|
+ SERIAL_ERRORPGM("No Line Number with checksum, Last Line:");
|
|
338
|
+ SERIAL_ERRORLN(gcode_LastN);
|
325
|
339
|
serial_count = 0;
|
326
|
340
|
return;
|
327
|
341
|
}
|
|
@@ -337,7 +351,7 @@ inline void get_command()
|
337
|
351
|
if(card.saving)
|
338
|
352
|
break;
|
339
|
353
|
#endif //SDSUPPORT
|
340
|
|
- SERIAL_PROTOCOLLN("ok");
|
|
354
|
+ SERIAL_PROTOCOLLNPGM("ok");
|
341
|
355
|
break;
|
342
|
356
|
default:
|
343
|
357
|
break;
|
|
@@ -362,14 +376,14 @@ inline void get_command()
|
362
|
376
|
return;
|
363
|
377
|
}
|
364
|
378
|
while( !card.eof() && buflen < BUFSIZE) {
|
365
|
|
-
|
366
|
|
- serial_char = card.get();
|
367
|
|
- if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1))
|
|
379
|
+ int16_t n=card.get();
|
|
380
|
+ serial_char = (char)n;
|
|
381
|
+ if(serial_char == '\n' || serial_char == '\r' || serial_char == ':' || serial_count >= (MAX_CMD_SIZE - 1)||n==-1)
|
368
|
382
|
{
|
369
|
383
|
|
370
|
384
|
if(card.eof()){
|
371
|
385
|
card.sdprinting = false;
|
372
|
|
- SERIAL_PROTOCOL("Done printing file");
|
|
386
|
+ SERIAL_PROTOCOLLNPGM("Done printing file");
|
373
|
387
|
stoptime=millis();
|
374
|
388
|
char time[30];
|
375
|
389
|
unsigned long t=(stoptime-starttime)/1000;
|
|
@@ -377,6 +391,7 @@ inline void get_command()
|
377
|
391
|
min=t/60;
|
378
|
392
|
sec=t%60;
|
379
|
393
|
sprintf(time,"%i min, %i sec",min,sec);
|
|
394
|
+ SERIAL_ECHO_START;
|
380
|
395
|
SERIAL_ECHOLN(time);
|
381
|
396
|
LCD_MESSAGE(time);
|
382
|
397
|
card.checkautostart(true);
|
|
@@ -398,6 +413,7 @@ inline void get_command()
|
398
|
413
|
if(!comment_mode) cmdbuffer[bufindw][serial_count++] = serial_char;
|
399
|
414
|
}
|
400
|
415
|
}
|
|
416
|
+
|
401
|
417
|
#endif //SDSUPPORT
|
402
|
418
|
|
403
|
419
|
}
|
|
@@ -473,6 +489,7 @@ inline void process_commands()
|
473
|
489
|
previous_millis_cmd = millis();
|
474
|
490
|
return;
|
475
|
491
|
case 4: // G4 dwell
|
|
492
|
+ LCD_MESSAGEPGM("DWELL...");
|
476
|
493
|
codenum = 0;
|
477
|
494
|
if(code_seen('P')) codenum = code_value(); // milliseconds to wait
|
478
|
495
|
if(code_seen('S')) codenum = code_value() * 1000; // seconds to wait
|
|
@@ -533,13 +550,14 @@ inline void process_commands()
|
533
|
550
|
#ifdef SDSUPPORT
|
534
|
551
|
|
535
|
552
|
case 20: // M20 - list SD card
|
536
|
|
- SERIAL_PROTOCOLLN("Begin file list");
|
|
553
|
+ SERIAL_PROTOCOLLNPGM("Begin file list");
|
537
|
554
|
card.ls();
|
538
|
|
- SERIAL_PROTOCOLLN("End file list");
|
|
555
|
+ SERIAL_PROTOCOLLNPGM("End file list");
|
539
|
556
|
break;
|
540
|
557
|
case 21: // M21 - init SD card
|
541
|
558
|
|
542
|
559
|
card.initsd();
|
|
560
|
+
|
543
|
561
|
break;
|
544
|
562
|
case 22: //M22 - release SD card
|
545
|
563
|
card.release();
|
|
@@ -592,7 +610,8 @@ inline void process_commands()
|
592
|
610
|
min=t/60;
|
593
|
611
|
sec=t%60;
|
594
|
612
|
sprintf(time,"%i min, %i sec",min,sec);
|
595
|
|
- SERIAL_ERRORLN(time);
|
|
613
|
+ SERIAL_ECHO_START;
|
|
614
|
+ SERIAL_ECHOLN(time);
|
596
|
615
|
LCD_MESSAGE(time);
|
597
|
616
|
}
|
598
|
617
|
break;
|
|
@@ -637,7 +656,7 @@ inline void process_commands()
|
637
|
656
|
bt = degBed();
|
638
|
657
|
#endif
|
639
|
658
|
#if (TEMP_0_PIN > -1) || defined (HEATER_USES_AD595)
|
640
|
|
- SERIAL_PROTOCOL("ok T:");
|
|
659
|
+ SERIAL_PROTOCOLPGM("ok T:");
|
641
|
660
|
SERIAL_PROTOCOL(tt);
|
642
|
661
|
#if TEMP_1_PIN > -1
|
643
|
662
|
#ifdef PIDTEMP
|
|
@@ -654,13 +673,14 @@ inline void process_commands()
|
654
|
673
|
SERIAL_PROTOCOLLN("");
|
655
|
674
|
#endif //TEMP_1_PIN
|
656
|
675
|
#else
|
657
|
|
- SERIAL_ERRORLN("No thermistors - no temp");
|
|
676
|
+ SERIAL_ERROR_START;
|
|
677
|
+ SERIAL_ERRORLNPGM("No thermistors - no temp");
|
658
|
678
|
#endif
|
659
|
679
|
return;
|
660
|
680
|
break;
|
661
|
681
|
case 109:
|
662
|
682
|
{// M109 - Wait for extruder heater to reach target.
|
663
|
|
- LCD_MESSAGE("Heating...");
|
|
683
|
+ LCD_MESSAGEPGM("Heating...");
|
664
|
684
|
if (code_seen('S')) setTargetHotend0(code_value());
|
665
|
685
|
|
666
|
686
|
setWatch();
|
|
@@ -681,7 +701,8 @@ inline void process_commands()
|
681
|
701
|
#endif //TEMP_RESIDENCY_TIME
|
682
|
702
|
if( (millis() - codenum) > 1000 )
|
683
|
703
|
{ //Print Temp Reading every 1 second while heating up/cooling down
|
684
|
|
- SERIAL_PROTOCOLLN("T:"<< degHotend0() );
|
|
704
|
+ SERIAL_PROTOCOLPGM("T:");
|
|
705
|
+ SERIAL_PROTOCOLLN( degHotend0() );
|
685
|
706
|
codenum = millis();
|
686
|
707
|
}
|
687
|
708
|
manage_heater();
|
|
@@ -697,12 +718,13 @@ inline void process_commands()
|
697
|
718
|
}
|
698
|
719
|
#endif //TEMP_RESIDENCY_TIME
|
699
|
720
|
}
|
700
|
|
- LCD_MESSAGE("Heating done.");
|
|
721
|
+ LCD_MESSAGEPGM("Heating done.");
|
701
|
722
|
starttime=millis();
|
702
|
723
|
}
|
703
|
724
|
break;
|
704
|
725
|
case 190: // M190 - Wait bed for heater to reach target.
|
705
|
726
|
#if TEMP_1_PIN > -1
|
|
727
|
+ LCD_MESSAGEPGM("Bed Heating.");
|
706
|
728
|
if (code_seen('S')) setTargetBed(code_value());
|
707
|
729
|
codenum = millis();
|
708
|
730
|
while(isHeatingBed())
|
|
@@ -710,12 +732,17 @@ inline void process_commands()
|
710
|
732
|
if( (millis()-codenum) > 1000 ) //Print Temp Reading every 1 second while heating up.
|
711
|
733
|
{
|
712
|
734
|
float tt=degHotend0();
|
713
|
|
- SERIAL_PROTOCOLLN("T:"<<tt );
|
714
|
|
- SERIAL_PROTOCOLLN("ok T:"<<tt <<" B:"<<degBed() );
|
|
735
|
+ SERIAL_PROTOCOLPGM("T:");
|
|
736
|
+ SERIAL_PROTOCOLLN(tt );
|
|
737
|
+ SERIAL_PROTOCOLPGM("ok T:");
|
|
738
|
+ SERIAL_PROTOCOL(tt );
|
|
739
|
+ SERIAL_PROTOCOLPGM(" B:");
|
|
740
|
+ SERIAL_PROTOCOLLN(degBed() );
|
715
|
741
|
codenum = millis();
|
716
|
742
|
}
|
717
|
743
|
manage_heater();
|
718
|
744
|
}
|
|
745
|
+ LCD_MESSAGEPGM("Bed done.");
|
719
|
746
|
#endif
|
720
|
747
|
break;
|
721
|
748
|
|
|
@@ -759,6 +786,7 @@ inline void process_commands()
|
759
|
786
|
}
|
760
|
787
|
else
|
761
|
788
|
{
|
|
789
|
+ LCD_MESSAGEPGM("Free move.");
|
762
|
790
|
st_synchronize();
|
763
|
791
|
disable_x();
|
764
|
792
|
disable_y();
|
|
@@ -778,50 +806,50 @@ inline void process_commands()
|
778
|
806
|
}
|
779
|
807
|
break;
|
780
|
808
|
case 115: // M115
|
781
|
|
- SERIAL_PROTOCOLLN("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
|
|
809
|
+ SerialprintPGM("FIRMWARE_NAME:Marlin; Sprinter/grbl mashup for gen6 FIRMWARE_URL:http://www.mendel-parts.com PROTOCOL_VERSION:1.0 MACHINE_TYPE:Mendel EXTRUDER_COUNT:1");
|
782
|
810
|
break;
|
783
|
811
|
case 114: // M114
|
784
|
|
- SERIAL_PROTOCOL("X:");
|
|
812
|
+ SERIAL_PROTOCOLPGM("X:");
|
785
|
813
|
SERIAL_PROTOCOL(current_position[X_AXIS]);
|
786
|
|
- SERIAL_PROTOCOL("Y:");
|
|
814
|
+ SERIAL_PROTOCOLPGM("Y:");
|
787
|
815
|
SERIAL_PROTOCOL(current_position[Y_AXIS]);
|
788
|
|
- SERIAL_PROTOCOL("Z:");
|
|
816
|
+ SERIAL_PROTOCOLPGM("Z:");
|
789
|
817
|
SERIAL_PROTOCOL(current_position[Z_AXIS]);
|
790
|
|
- SERIAL_PROTOCOL("E:");
|
|
818
|
+ SERIAL_PROTOCOLPGM("E:");
|
791
|
819
|
SERIAL_PROTOCOL(current_position[E_AXIS]);
|
792
|
820
|
#ifdef DEBUG_STEPS
|
793
|
|
- SERIAL_PROTOCOL(" Count X:");
|
|
821
|
+ SERIAL_PROTOCOLPGM(" Count X:");
|
794
|
822
|
SERIAL_PROTOCOL(float(count_position[X_AXIS])/axis_steps_per_unit[X_AXIS]);
|
795
|
|
- SERIAL_PROTOCOL("Y:");
|
|
823
|
+ SERIAL_PROTOCOLPGM("Y:");
|
796
|
824
|
SERIAL_PROTOCOL(float(count_position[Y_AXIS])/axis_steps_per_unit[Y_AXIS]);
|
797
|
|
- SERIAL_PROTOCOL("Z:");
|
|
825
|
+ SERIAL_PROTOCOLPGM("Z:");
|
798
|
826
|
SERIAL_PROTOCOL(float(count_position[Z_AXIS])/axis_steps_per_unit[Z_AXIS]);
|
799
|
827
|
#endif
|
800
|
828
|
SERIAL_PROTOCOLLN("");
|
801
|
829
|
break;
|
802
|
830
|
case 119: // M119
|
803
|
831
|
#if (X_MIN_PIN > -1)
|
804
|
|
- SERIAL_PROTOCOL("x_min:");
|
|
832
|
+ SERIAL_PROTOCOLPGM("x_min:");
|
805
|
833
|
SERIAL_PROTOCOL(((READ(X_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
806
|
834
|
#endif
|
807
|
835
|
#if (X_MAX_PIN > -1)
|
808
|
|
- SERIAL_PROTOCOL("x_max:");
|
|
836
|
+ SERIAL_PROTOCOLPGM("x_max:");
|
809
|
837
|
SERIAL_PROTOCOL(((READ(X_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
810
|
838
|
#endif
|
811
|
839
|
#if (Y_MIN_PIN > -1)
|
812
|
|
- SERIAL_PROTOCOL("y_min:");
|
|
840
|
+ SERIAL_PROTOCOLPGM("y_min:");
|
813
|
841
|
SERIAL_PROTOCOL(((READ(Y_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
814
|
842
|
#endif
|
815
|
843
|
#if (Y_MAX_PIN > -1)
|
816
|
|
- SERIAL_PROTOCOL("y_max:");
|
|
844
|
+ SERIAL_PROTOCOLPGM("y_max:");
|
817
|
845
|
SERIAL_PROTOCOL(((READ(Y_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
818
|
846
|
#endif
|
819
|
847
|
#if (Z_MIN_PIN > -1)
|
820
|
|
- SERIAL_PROTOCOL("z_min:");
|
|
848
|
+ SERIAL_PROTOCOLPGM("z_min:");
|
821
|
849
|
SERIAL_PROTOCOL(((READ(Z_MIN_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
822
|
850
|
#endif
|
823
|
851
|
#if (Z_MAX_PIN > -1)
|
824
|
|
- SERIAL_PROTOCOL("z_max:");
|
|
852
|
+ SERIAL_PROTOCOLPGM("z_max:");
|
825
|
853
|
SERIAL_PROTOCOL(((READ(Z_MAX_PIN)^ENDSTOPS_INVERTING)?"H ":"L "));
|
826
|
854
|
#endif
|
827
|
855
|
SERIAL_PROTOCOLLN("");
|
|
@@ -897,7 +925,10 @@ inline void process_commands()
|
897
|
925
|
}
|
898
|
926
|
else
|
899
|
927
|
{
|
900
|
|
- SERIAL_ECHOLN("Unknown command:\""<<cmdbuffer[bufindr]<<"\"");
|
|
928
|
+ SERIAL_ECHO_START;
|
|
929
|
+ SERIAL_ECHOPGM("Unknown command:\"");
|
|
930
|
+ SERIAL_ECHO(cmdbuffer[bufindr]);
|
|
931
|
+ SERIAL_ECHOLNPGM("\"");
|
901
|
932
|
}
|
902
|
933
|
|
903
|
934
|
ClearToSend();
|
|
@@ -907,7 +938,8 @@ void FlushSerialRequestResend()
|
907
|
938
|
{
|
908
|
939
|
//char cmdbuffer[bufindr][100]="Resend:";
|
909
|
940
|
Serial.flush();
|
910
|
|
- SERIAL_PROTOCOLLN("Resend:"<<gcode_LastN + 1);
|
|
941
|
+ SERIAL_PROTOCOLPGM("Resend:");
|
|
942
|
+ SERIAL_PROTOCOLLN(gcode_LastN + 1);
|
911
|
943
|
ClearToSend();
|
912
|
944
|
}
|
913
|
945
|
|
|
@@ -918,7 +950,7 @@ void ClearToSend()
|
918
|
950
|
if(fromsd[bufindr])
|
919
|
951
|
return;
|
920
|
952
|
#endif //SDSUPPORT
|
921
|
|
- SERIAL_PROTOCOLLN("ok");
|
|
953
|
+ SERIAL_PROTOCOLLNPGM("ok");
|
922
|
954
|
}
|
923
|
955
|
|
924
|
956
|
inline void get_coordinates()
|
|
@@ -992,7 +1024,9 @@ void kill()
|
992
|
1024
|
disable_e();
|
993
|
1025
|
|
994
|
1026
|
if(PS_ON_PIN > -1) pinMode(PS_ON_PIN,INPUT);
|
995
|
|
- SERIAL_ERRORLN("Printer halted. kill() called !!");
|
|
1027
|
+ SERIAL_ERROR_START;
|
|
1028
|
+ SERIAL_ERRORLNPGM("Printer halted. kill() called !!");
|
|
1029
|
+ LCD_MESSAGEPGM("KILLED. ");
|
996
|
1030
|
while(1); // Wait for reset
|
997
|
1031
|
}
|
998
|
1032
|
|