Browse Source

✨ Instant Freeze/Resume Function (#17462)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Jamie 4 years ago
parent
commit
d97c1f1c62

+ 10
- 0
Marlin/Configuration_adv.h View File

3782
 #endif
3782
 #endif
3783
 
3783
 
3784
 /**
3784
 /**
3785
+ * Instant freeze / unfreeze functionality
3786
+ * Specified pin has pullup and connecting to ground will instantly pause motion.
3787
+ * Potentially useful for emergency stop that allows being resumed.
3788
+ */
3789
+//#define FREEZE_FEATURE
3790
+#if ENABLED(FREEZE_FEATURE)
3791
+  //#define FREEZE_PIN 41   // Override the default (KILL) pin here
3792
+#endif
3793
+
3794
+/**
3785
  * MAX7219 Debug Matrix
3795
  * MAX7219 Debug Matrix
3786
  *
3796
  *
3787
  * Add support for a low-cost 8x8 LED Matrix based on the Max7219 chip as a realtime status display.
3797
  * Add support for a low-cost 8x8 LED Matrix based on the Max7219 chip as a realtime status display.

+ 8
- 0
Marlin/src/MarlinCore.cpp View File

483
     }
483
     }
484
   #endif
484
   #endif
485
 
485
 
486
+  #if HAS_FREEZE_PIN
487
+    Stepper::frozen = !READ(FREEZE_PIN);
488
+  #endif
489
+
486
   #if HAS_HOME
490
   #if HAS_HOME
487
     // Handle a standalone HOME button
491
     // Handle a standalone HOME button
488
     constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
492
     constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
1089
     #endif
1093
     #endif
1090
   #endif
1094
   #endif
1091
 
1095
 
1096
+  #if HAS_FREEZE_PIN
1097
+    SET_INPUT_PULLUP(FREEZE_PIN);
1098
+  #endif
1099
+
1092
   #if HAS_SUICIDE
1100
   #if HAS_SUICIDE
1093
     SETUP_LOG("SUICIDE_PIN");
1101
     SETUP_LOG("SUICIDE_PIN");
1094
     OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
1102
     OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);

+ 13
- 3
Marlin/src/inc/Conditionals_post.h View File

2318
 #endif
2318
 #endif
2319
 
2319
 
2320
 // User Interface
2320
 // User Interface
2321
-#if PIN_EXISTS(HOME)
2322
-  #define HAS_HOME 1
2321
+#if ENABLED(FREEZE_FEATURE)
2322
+  #if !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
2323
+    #define FREEZE_PIN KILL_PIN
2324
+  #endif
2325
+  #if PIN_EXISTS(FREEZE)
2326
+    #define HAS_FREEZE_PIN 1
2327
+  #endif
2328
+#else
2329
+  #undef FREEZE_PIN
2323
 #endif
2330
 #endif
2324
-#if PIN_EXISTS(KILL)
2331
+#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
2325
   #define HAS_KILL 1
2332
   #define HAS_KILL 1
2326
 #endif
2333
 #endif
2334
+#if PIN_EXISTS(HOME)
2335
+  #define HAS_HOME 1
2336
+#endif
2327
 #if PIN_EXISTS(SUICIDE)
2337
 #if PIN_EXISTS(SUICIDE)
2328
   #define HAS_SUICIDE 1
2338
   #define HAS_SUICIDE 1
2329
 #endif
2339
 #endif

+ 4
- 0
Marlin/src/inc/SanityCheck.h View File

3307
 
3307
 
3308
 // Misc. Cleanup
3308
 // Misc. Cleanup
3309
 #undef _TEST_PWM
3309
 #undef _TEST_PWM
3310
+
3311
+#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE)
3312
+  #error "FREEZE_FEATURE requires a FREEZE_PIN to be defined."
3313
+#endif

+ 7
- 0
Marlin/src/module/stepper.cpp View File

179
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
179
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
180
 uint8_t Stepper::steps_per_isr;
180
 uint8_t Stepper::steps_per_isr;
181
 
181
 
182
+#if HAS_FREEZE_PIN
183
+  bool Stepper::frozen; // = false
184
+#endif
185
+
182
 IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor;
186
 IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor;
183
 
187
 
184
 xyze_long_t Stepper::delta_error{0};
188
 xyze_long_t Stepper::delta_error{0};
1531
   // If there is no current block, do nothing
1535
   // If there is no current block, do nothing
1532
   if (!current_block) return;
1536
   if (!current_block) return;
1533
 
1537
 
1538
+  // Skipping step processing causes motion to freeze
1539
+  if (TERN0(HAS_FREEZE_PIN, frozen)) return;
1540
+
1534
   // Count of pending loops and events for this iteration
1541
   // Count of pending loops and events for this iteration
1535
   const uint32_t pending_events = step_event_count - step_events_completed;
1542
   const uint32_t pending_events = step_event_count - step_events_completed;
1536
   uint8_t events_to_do = _MIN(pending_events, steps_per_isr);
1543
   uint8_t events_to_do = _MIN(pending_events, steps_per_isr);

+ 4
- 0
Marlin/src/module/stepper.h View File

266
       static constexpr uint8_t last_moved_extruder = 0;
266
       static constexpr uint8_t last_moved_extruder = 0;
267
     #endif
267
     #endif
268
 
268
 
269
+    #if HAS_FREEZE_PIN
270
+      static bool frozen;                   // Set this flag to instantly freeze motion
271
+    #endif
272
+
269
   private:
273
   private:
270
 
274
 
271
     static block_t* current_block;          // A pointer to the block currently being traced
275
     static block_t* current_block;          // A pointer to the block currently being traced

+ 4
- 1
Marlin/src/pins/pinsDebug_list.h View File

721
 #if PIN_EXISTS(I2C_SDA)
721
 #if PIN_EXISTS(I2C_SDA)
722
   REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN)
722
   REPORT_NAME_DIGITAL(__LINE__, I2C_SDA_PIN)
723
 #endif
723
 #endif
724
-#if PIN_EXISTS(KILL)
724
+#if HAS_KILL
725
   REPORT_NAME_DIGITAL(__LINE__, KILL_PIN)
725
   REPORT_NAME_DIGITAL(__LINE__, KILL_PIN)
726
 #endif
726
 #endif
727
+#if HAS_FREEZE_PIN
728
+  REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN)
729
+#endif
727
 #if PIN_EXISTS(LCD_BACKLIGHT)
730
 #if PIN_EXISTS(LCD_BACKLIGHT)
728
   REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN)
731
   REPORT_NAME_DIGITAL(__LINE__, LCD_BACKLIGHT_PIN)
729
 #endif
732
 #endif

+ 1
- 1
buildroot/tests/mega2560 View File

21
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
21
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
22
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
22
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
23
            SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \
23
            SDSUPPORT SDCARD_SORT_ALPHA USB_FLASH_DRIVE_SUPPORT AUTO_REPORT_SD_STATUS SCROLL_LONG_FILENAMES CANCEL_OBJECTS SOUND_MENU_ITEM \
24
-           EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN \
24
+           EEPROM_SETTINGS EEPROM_CHITCHAT GCODE_MACROS CUSTOM_MENU_MAIN FREEZE_FEATURE \
25
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
25
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
26
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
26
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
27
            BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL
27
            BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL

Loading…
Cancel
Save