|
@@ -110,6 +110,7 @@
|
110
|
110
|
// M502 - reverts to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
|
111
|
111
|
// M503 - print the current settings (from memory not from eeprom)
|
112
|
112
|
// M303 - PID relay autotune S<temperature> sets the target temperature. (default target temperature = 150C)
|
|
113
|
+// M999 - Restart after being stopped by error
|
113
|
114
|
|
114
|
115
|
//Stepper Movement Variables
|
115
|
116
|
|
|
@@ -135,6 +136,7 @@ float add_homeing[3]={0,0,0};
|
135
|
136
|
uint8_t active_extruder = 0;
|
136
|
137
|
unsigned char FanSpeed=0;
|
137
|
138
|
|
|
139
|
+
|
138
|
140
|
//===========================================================================
|
139
|
141
|
//=============================private variables=============================
|
140
|
142
|
//===========================================================================
|
|
@@ -143,7 +145,7 @@ static float destination[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0};
|
143
|
145
|
static float offset[3] = {0.0, 0.0, 0.0};
|
144
|
146
|
static bool home_all_axis = true;
|
145
|
147
|
static float feedrate = 1500.0, next_feedrate, saved_feedrate;
|
146
|
|
-static long gcode_N, gcode_LastN;
|
|
148
|
+static long gcode_N, gcode_LastN, Stopped_gcode_LastN = 0;
|
147
|
149
|
|
148
|
150
|
static bool relative_mode = false; //Determines Absolute or Relative Coordinates
|
149
|
151
|
static bool relative_mode_e = false; //Determines Absolute or Relative E Codes while in Absolute Coordinates mode. E is always relative in Relative Coordinates mode.
|
|
@@ -174,6 +176,7 @@ static unsigned long stoptime=0;
|
174
|
176
|
|
175
|
177
|
static uint8_t tmp_extruder;
|
176
|
178
|
|
|
179
|
+bool Stopped=false;
|
177
|
180
|
|
178
|
181
|
//===========================================================================
|
179
|
182
|
//=============================ROUTINES=============================
|
|
@@ -415,11 +418,17 @@ void get_command()
|
415
|
418
|
case 1:
|
416
|
419
|
case 2:
|
417
|
420
|
case 3:
|
418
|
|
- #ifdef SDSUPPORT
|
419
|
|
- if(card.saving)
|
420
|
|
- break;
|
421
|
|
- #endif //SDSUPPORT
|
422
|
|
- SERIAL_PROTOCOLLNPGM(MSG_OK);
|
|
421
|
+ if(Stopped == false) { // If printer is stopped by an error the G[0-3] codes are ignored.
|
|
422
|
+ #ifdef SDSUPPORT
|
|
423
|
+ if(card.saving)
|
|
424
|
+ break;
|
|
425
|
+ #endif //SDSUPPORT
|
|
426
|
+ SERIAL_PROTOCOLLNPGM(MSG_OK);
|
|
427
|
+ }
|
|
428
|
+ else {
|
|
429
|
+ SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
|
|
430
|
+ LCD_MESSAGEPGM(MSG_STOPPED);
|
|
431
|
+ }
|
423
|
432
|
break;
|
424
|
433
|
default:
|
425
|
434
|
break;
|
|
@@ -547,19 +556,25 @@ void process_commands()
|
547
|
556
|
{
|
548
|
557
|
case 0: // G0 -> G1
|
549
|
558
|
case 1: // G1
|
550
|
|
- get_coordinates(); // For X Y Z E F
|
551
|
|
- prepare_move();
|
552
|
|
- //ClearToSend();
|
553
|
|
- return;
|
|
559
|
+ if(Stopped == false) {
|
|
560
|
+ get_coordinates(); // For X Y Z E F
|
|
561
|
+ prepare_move();
|
|
562
|
+ //ClearToSend();
|
|
563
|
+ return;
|
|
564
|
+ }
|
554
|
565
|
//break;
|
555
|
566
|
case 2: // G2 - CW ARC
|
556
|
|
- get_arc_coordinates();
|
557
|
|
- prepare_arc_move(true);
|
558
|
|
- return;
|
|
567
|
+ if(Stopped == false) {
|
|
568
|
+ get_arc_coordinates();
|
|
569
|
+ prepare_arc_move(true);
|
|
570
|
+ return;
|
|
571
|
+ }
|
559
|
572
|
case 3: // G3 - CCW ARC
|
560
|
|
- get_arc_coordinates();
|
561
|
|
- prepare_arc_move(false);
|
562
|
|
- return;
|
|
573
|
+ if(Stopped == false) {
|
|
574
|
+ get_arc_coordinates();
|
|
575
|
+ prepare_arc_move(false);
|
|
576
|
+ return;
|
|
577
|
+ }
|
563
|
578
|
case 4: // G4 dwell
|
564
|
579
|
LCD_MESSAGEPGM(MSG_DWELL);
|
565
|
580
|
codenum = 0;
|
|
@@ -972,6 +987,7 @@ void process_commands()
|
972
|
987
|
#if (PS_ON_PIN > -1)
|
973
|
988
|
case 80: // M80 - ATX Power On
|
974
|
989
|
SET_OUTPUT(PS_ON_PIN); //GND
|
|
990
|
+ WRITE(PS_ON_PIN, LOW);
|
975
|
991
|
break;
|
976
|
992
|
#endif
|
977
|
993
|
|
|
@@ -1236,7 +1252,11 @@ void process_commands()
|
1236
|
1252
|
EEPROM_printSettings();
|
1237
|
1253
|
}
|
1238
|
1254
|
break;
|
1239
|
|
-
|
|
1255
|
+ case 999: // Restart after being stopped
|
|
1256
|
+ Stopped = false;
|
|
1257
|
+ gcode_LastN = Stopped_gcode_LastN;
|
|
1258
|
+ FlushSerialRequestResend();
|
|
1259
|
+ break;
|
1240
|
1260
|
}
|
1241
|
1261
|
}
|
1242
|
1262
|
|
|
@@ -1438,4 +1458,18 @@ void kill()
|
1438
|
1458
|
while(1); // Wait for reset
|
1439
|
1459
|
}
|
1440
|
1460
|
|
|
1461
|
+void Stop()
|
|
1462
|
+{
|
|
1463
|
+ disable_heater();
|
|
1464
|
+ if(Stopped == false) {
|
|
1465
|
+ Stopped = true;
|
|
1466
|
+ Stopped_gcode_LastN = gcode_LastN; // Save last g_code for restart
|
|
1467
|
+ SERIAL_ERROR_START;
|
|
1468
|
+ SERIAL_ERRORLNPGM(MSG_ERR_STOPPED);
|
|
1469
|
+ LCD_MESSAGEPGM(MSG_STOPPED);
|
|
1470
|
+ }
|
|
1471
|
+}
|
|
1472
|
+
|
|
1473
|
+bool IsStopped() { return Stopped; };
|
|
1474
|
+
|
1441
|
1475
|
|