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
 extern bool axis_homed[XYZ]; // axis[n].is_homed
266
 extern bool axis_homed[XYZ]; // axis[n].is_homed
267
 extern volatile bool wait_for_heatup;
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
 extern float current_position[NUM_AXIS];
273
 extern float current_position[NUM_AXIS];
270
 extern float position_shift[XYZ];
274
 extern float position_shift[XYZ];
271
 extern float home_offset[XYZ];
275
 extern float home_offset[XYZ];

+ 3
- 0
Marlin/MarlinSerial.cpp View File

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

+ 61
- 27
Marlin/Marlin_main.cpp View File

351
 
351
 
352
 volatile bool wait_for_heatup = true;
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
 const char errormagic[] PROGMEM = "Error:";
358
 const char errormagic[] PROGMEM = "Error:";
355
 const char echomagic[] PROGMEM = "echo:";
359
 const char echomagic[] PROGMEM = "echo:";
356
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
360
 const char axis_codes[NUM_AXIS] = {'X', 'Y', 'Z', 'E'};
3815
     sync_plan_position_e();
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
    * M0: Unconditional stop - Wait for user button press on LCD
3825
    * M0: Unconditional stop - Wait for user button press on LCD
3835
       hasS = codenum > 0;
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
     stepper.synchronize();
3863
     stepper.synchronize();
3849
     refresh_cmd_timeout();
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
       KEEPALIVE_STATE(PAUSED_FOR_USER);
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
  * M17: Enable power on all stepper motors
3906
  * M17: Enable power on all stepper motors

Loading…
Cancel
Save