Browse Source

Update G-code injection, sub-commands (#14418)

InsanityAutomation 5 years ago
parent
commit
ce656e2a26
2 changed files with 9 additions and 12 deletions
  1. 8
    11
      Marlin/src/Marlin.cpp
  2. 1
    1
      Marlin/src/gcode/bedlevel/abl/G29.cpp

+ 8
- 11
Marlin/src/Marlin.cpp View File

@@ -502,19 +502,16 @@ void manage_inactivity(const bool ignore_stepper_queue/*=false*/) {
502 502
   #endif
503 503
 
504 504
   #if HAS_HOME
505
-    // Check to see if we have to home, use poor man's debouncer
506
-    // ---------------------------------------------------------
507
-    static int homeDebounceCount = 0;   // poor man's debouncing count
508
-    const int HOME_DEBOUNCE_DELAY = 2500;
509
-    if (!IS_SD_PRINTING() && !READ(HOME_PIN)) {
510
-      if (!homeDebounceCount) {
511
-        queue.inject_P(PSTR("G28"));
505
+    // Handle a standalone HOME button
506
+    constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
507
+    static millis_t next_home_key_ms; // = 0
508
+    if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed
509
+      const millis_t ms = millis();
510
+      if (ELAPSED(ms, next_home_key_ms)) {
511
+        next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
512 512
         LCD_MESSAGEPGM(MSG_AUTO_HOME);
513
+        queue.enqueue_now_P(PSTR("G28"));
513 514
       }
514
-      if (homeDebounceCount < HOME_DEBOUNCE_DELAY)
515
-        homeDebounceCount++;
516
-      else
517
-        homeDebounceCount = 0;
518 515
     }
519 516
   #endif
520 517
 

+ 1
- 1
Marlin/src/gcode/bedlevel/abl/G29.cpp View File

@@ -966,7 +966,7 @@ G29_TYPE GcodeSuite::G29() {
966 966
     #ifdef Z_PROBE_END_SCRIPT
967 967
       if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPAIR("Z Probe End Script: ", Z_PROBE_END_SCRIPT);
968 968
       planner.synchronize();
969
-      queue.inject_P(PSTR(Z_PROBE_END_SCRIPT));
969
+      process_subcommands_now_P(PSTR(Z_PROBE_END_SCRIPT));
970 970
     #endif
971 971
 
972 972
     // Auto Bed Leveling is complete! Enable if possible.

Loading…
Cancel
Save