Bläddra i källkod

✨ Instant Freeze/Resume Function (#17462)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Jamie 3 år sedan
förälder
incheckning
d97c1f1c62

+ 10
- 0
Marlin/Configuration_adv.h Visa fil

@@ -3782,6 +3782,16 @@
3782 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 3795
  * MAX7219 Debug Matrix
3786 3796
  *
3787 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 Visa fil

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

+ 13
- 3
Marlin/src/inc/Conditionals_post.h Visa fil

@@ -2318,12 +2318,22 @@
2318 2318
 #endif
2319 2319
 
2320 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 2330
 #endif
2324
-#if PIN_EXISTS(KILL)
2331
+#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
2325 2332
   #define HAS_KILL 1
2326 2333
 #endif
2334
+#if PIN_EXISTS(HOME)
2335
+  #define HAS_HOME 1
2336
+#endif
2327 2337
 #if PIN_EXISTS(SUICIDE)
2328 2338
   #define HAS_SUICIDE 1
2329 2339
 #endif

+ 4
- 0
Marlin/src/inc/SanityCheck.h Visa fil

@@ -3307,3 +3307,7 @@ static_assert(   _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
3307 3307
 
3308 3308
 // Misc. Cleanup
3309 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 Visa fil

@@ -179,6 +179,10 @@ bool Stepper::abort_current_block;
179 179
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
180 180
 uint8_t Stepper::steps_per_isr;
181 181
 
182
+#if HAS_FREEZE_PIN
183
+  bool Stepper::frozen; // = false
184
+#endif
185
+
182 186
 IF_DISABLED(ADAPTIVE_STEP_SMOOTHING, constexpr) uint8_t Stepper::oversampling_factor;
183 187
 
184 188
 xyze_long_t Stepper::delta_error{0};
@@ -1531,6 +1535,9 @@ void Stepper::pulse_phase_isr() {
1531 1535
   // If there is no current block, do nothing
1532 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 1541
   // Count of pending loops and events for this iteration
1535 1542
   const uint32_t pending_events = step_event_count - step_events_completed;
1536 1543
   uint8_t events_to_do = _MIN(pending_events, steps_per_isr);

+ 4
- 0
Marlin/src/module/stepper.h Visa fil

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

+ 4
- 1
Marlin/src/pins/pinsDebug_list.h Visa fil

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

+ 1
- 1
buildroot/tests/mega2560 Visa fil

@@ -21,7 +21,7 @@ opt_set MOTHERBOARD BOARD_AZTEEG_X3_PRO LCD_LANGUAGE fr \
21 21
 opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_VALIDATION ENABLE_LEVELING_FADE_HEIGHT SKEW_CORRECTION \
22 22
            REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER LIGHTWEIGHT_UI STATUS_MESSAGE_SCROLLING SHOW_CUSTOM_BOOTSCREEN BOOT_MARLIN_LOGO_SMALL \
23 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 25
            MULTI_NOZZLE_DUPLICATION CLASSIC_JERK LIN_ADVANCE EXTRA_LIN_ADVANCE_K QUICK_HOME \
26 26
            LCD_SET_PROGRESS_MANUALLY PRINT_PROGRESS_SHOW_DECIMALS SHOW_REMAINING_TIME \
27 27
            BABYSTEPPING BABYSTEP_XY NANODLP_Z_SYNC I2C_POSITION_ENCODERS M114_DETAIL

Laddar…
Avbryt
Spara