Browse Source

Implement M0/M1 for EMERGENCY_PARSER

Scott Lahteine 8 years ago
parent
commit
c5fa70809b
3 changed files with 68 additions and 27 deletions
  1. 4
    0
      Marlin/Marlin.h
  2. 3
    0
      Marlin/MarlinSerial.cpp
  3. 61
    27
      Marlin/Marlin_main.cpp

+ 4
- 0
Marlin/Marlin.h View File

@@ -266,6 +266,10 @@ extern bool axis_known_position[XYZ]; // axis[n].is_known
266 266
 extern bool axis_homed[XYZ]; // axis[n].is_homed
267 267
 extern volatile bool wait_for_heatup;
268 268
 
269
+#if ENABLED(EMERGENCY_PARSER) && DISABLED(ULTIPANEL)
270
+  extern volatile bool wait_for_user;
271
+#endif
272
+
269 273
 extern float current_position[NUM_AXIS];
270 274
 extern float position_shift[XYZ];
271 275
 extern float home_offset[XYZ];

+ 3
- 0
Marlin/MarlinSerial.cpp View File

@@ -509,6 +509,9 @@ MarlinSerial customizedSerial;
509 509
           switch (state) {
510 510
             case state_M108:
511 511
               wait_for_heatup = false;
512
+              #if DISABLED(ULTIPANEL)
513
+                wait_for_user = false;
514
+              #endif
512 515
               break;
513 516
             case state_M112:
514 517
               kill(PSTR(MSG_KILLED));

+ 61
- 27
Marlin/Marlin_main.cpp View File

@@ -351,6 +351,10 @@ static bool relative_mode = false;
351 351
 
352 352
 volatile bool wait_for_heatup = true;
353 353
 
354
+#if ENABLED(EMERGENCY_PARSER) && DISABLED(ULTIPANEL)
355
+  wait_for_user = false;
356
+#endif
357
+
354 358
 const char errormagic[] PROGMEM = "Error:";
355 359
 const char echomagic[] PROGMEM = "echo:";
356 360
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
@@ -3815,7 +3819,7 @@ inline void gcode_G92() {
3815 3819
     sync_plan_position_e();
3816 3820
 }
3817 3821
 
3818
-#if ENABLED(ULTIPANEL)
3822
+#if ENABLED(ULTIPANEL) || ENABLED(EMERGENCY_PARSER)
3819 3823
 
3820 3824
   /**
3821 3825
    * M0: Unconditional stop - Wait for user button press on LCD
@@ -3835,38 +3839,68 @@ inline void gcode_G92() {
3835 3839
       hasS = codenum > 0;
3836 3840
     }
3837 3841
 
3838
-    if (!hasP && !hasS && *args != '\0')
3839
-      lcd_setstatus(args, true);
3840
-    else {
3841
-      LCD_MESSAGEPGM(MSG_USERWAIT);
3842
-      #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
3843
-        dontExpireStatus();
3844
-      #endif
3845
-    }
3842
+    #if ENABLED(ULTIPANEL)
3843
+
3844
+      if (!hasP && !hasS && *args != '\0')
3845
+        lcd_setstatus(args, true);
3846
+      else {
3847
+        LCD_MESSAGEPGM(MSG_USERWAIT);
3848
+        #if ENABLED(LCD_PROGRESS_BAR) && PROGRESS_MSG_EXPIRE > 0
3849
+          dontExpireStatus();
3850
+        #endif
3851
+      }
3852
+      lcd_ignore_click();
3853
+
3854
+    #else
3855
+
3856
+      if (!hasP && !hasS && *args != '\0') {
3857
+        SERIAL_ECHO_START;
3858
+        SERIAL_ECHOLN(args);
3859
+      }
3860
+
3861
+    #endif
3846 3862
 
3847
-    lcd_ignore_click();
3848 3863
     stepper.synchronize();
3849 3864
     refresh_cmd_timeout();
3850
-    if (codenum > 0) {
3851
-      codenum += previous_cmd_ms;  // wait until this time for a click
3852
-      KEEPALIVE_STATE(PAUSED_FOR_USER);
3853
-      while (PENDING(millis(), codenum) && !lcd_clicked()) idle();
3854
-      KEEPALIVE_STATE(IN_HANDLER);
3855
-      lcd_ignore_click(false);
3856
-    }
3857
-    else {
3858
-      if (!lcd_detected()) return;
3865
+
3866
+    #if ENABLED(ULTIPANEL)
3867
+
3868
+      if (codenum > 0) {
3869
+        codenum += previous_cmd_ms;  // wait until this time for a click
3870
+        KEEPALIVE_STATE(PAUSED_FOR_USER);
3871
+        while (PENDING(millis(), codenum) && !lcd_clicked()) idle();
3872
+        lcd_ignore_click(false);
3873
+      }
3874
+      else if (lcd_detected()) {
3875
+        KEEPALIVE_STATE(PAUSED_FOR_USER);
3876
+        while (!lcd_clicked()) idle();
3877
+      }
3878
+      else return;
3879
+
3880
+      if (IS_SD_PRINTING)
3881
+        LCD_MESSAGEPGM(MSG_RESUMING);
3882
+      else
3883
+        LCD_MESSAGEPGM(WELCOME_MSG);
3884
+
3885
+    #else
3886
+
3859 3887
       KEEPALIVE_STATE(PAUSED_FOR_USER);
3860
-      while (!lcd_clicked()) idle();
3861
-      KEEPALIVE_STATE(IN_HANDLER);
3862
-    }
3863
-    if (IS_SD_PRINTING)
3864
-      LCD_MESSAGEPGM(MSG_RESUMING);
3865
-    else
3866
-      LCD_MESSAGEPGM(WELCOME_MSG);
3888
+      wait_for_user = true;
3889
+
3890
+      if (codenum > 0) {
3891
+        codenum += previous_cmd_ms;  // wait until this time for an M108
3892
+        while (PENDING(millis(), codenum) && wait_for_user) idle();
3893
+      }
3894
+      else while (wait_for_user) idle();
3895
+
3896
+      wait_for_user = false;
3897
+
3898
+    #endif
3899
+
3900
+    KEEPALIVE_STATE(IN_HANDLER);
3867 3901
   }
3868 3902
 
3869
-#endif // ULTIPANEL
3903
+#endif // ULTIPANEL || EMERGENCY_PARSER
3870 3904
 
3871 3905
 /**
3872 3906
  * M17: Enable power on all stepper motors

Loading…
Cancel
Save