Browse Source

✨ Configurable FREEZE pin state (#23944)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
ellensp 2 years ago
parent
commit
20b5615305
No account linked to committer's email address

+ 1
- 0
Marlin/Configuration_adv.h View File

4116
 //#define FREEZE_FEATURE
4116
 //#define FREEZE_FEATURE
4117
 #if ENABLED(FREEZE_FEATURE)
4117
 #if ENABLED(FREEZE_FEATURE)
4118
   //#define FREEZE_PIN 41   // Override the default (KILL) pin here
4118
   //#define FREEZE_PIN 41   // Override the default (KILL) pin here
4119
+  #define FREEZE_STATE LOW  // State of pin indicating freeze
4119
 #endif
4120
 #endif
4120
 
4121
 
4121
 /**
4122
 /**

+ 7
- 3
Marlin/src/MarlinCore.cpp View File

476
   #endif
476
   #endif
477
 
477
 
478
   #if HAS_FREEZE_PIN
478
   #if HAS_FREEZE_PIN
479
-    Stepper::frozen = !READ(FREEZE_PIN);
479
+    Stepper::frozen = READ(FREEZE_PIN) ^ DISABLED(INVERT_FREEZE_PIN);
480
   #endif
480
   #endif
481
 
481
 
482
   #if HAS_HOME
482
   #if HAS_HOME
1166
     #endif
1166
     #endif
1167
   #endif
1167
   #endif
1168
 
1168
 
1169
-  #if HAS_FREEZE_PIN
1169
+  #if ENABLED(FREEZE_FEATURE)
1170
     SETUP_LOG("FREEZE_PIN");
1170
     SETUP_LOG("FREEZE_PIN");
1171
-    SET_INPUT_PULLUP(FREEZE_PIN);
1171
+    #if FREEZE_STATE
1172
+      SET_INPUT_PULLDOWN(FREEZE_PIN);
1173
+    #else
1174
+      SET_INPUT_PULLUP(FREEZE_PIN);
1175
+    #endif
1172
   #endif
1176
   #endif
1173
 
1177
 
1174
   #if HAS_SUICIDE
1178
   #if HAS_SUICIDE

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

2824
 #endif
2824
 #endif
2825
 
2825
 
2826
 // User Interface
2826
 // User Interface
2827
-#if ENABLED(FREEZE_FEATURE)
2828
-  #if !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
2829
-    #define FREEZE_PIN KILL_PIN
2830
-  #endif
2831
-  #if PIN_EXISTS(FREEZE)
2832
-    #define HAS_FREEZE_PIN 1
2833
-  #endif
2834
-#else
2835
-  #undef FREEZE_PIN
2836
-#endif
2837
-#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
2827
+#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
2828
+  #define FREEZE_PIN KILL_PIN
2829
+#elif PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
2838
   #define HAS_KILL 1
2830
   #define HAS_KILL 1
2839
 #endif
2831
 #endif
2840
 #if PIN_EXISTS(HOME)
2832
 #if PIN_EXISTS(HOME)

+ 2
- 2
Marlin/src/inc/SanityCheck.h View File

1035
 /**
1035
 /**
1036
  * Instant Freeze
1036
  * Instant Freeze
1037
  */
1037
  */
1038
-#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE)
1039
-  #error "FREEZE_FEATURE requires a FREEZE_PIN to be defined."
1038
+#if ENABLED(FREEZE_FEATURE) && !(PIN_EXISTS(FREEZE) && defined(FREEZE_STATE))
1039
+  #error "FREEZE_FEATURE requires both FREEZE_PIN and FREEZE_STATE."
1040
 #endif
1040
 #endif
1041
 
1041
 
1042
 /**
1042
 /**

+ 2
- 2
Marlin/src/module/stepper.cpp View File

189
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
189
 uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
190
 uint8_t Stepper::steps_per_isr;
190
 uint8_t Stepper::steps_per_isr;
191
 
191
 
192
-#if HAS_FREEZE_PIN
192
+#if ENABLED(FREEZE_FEATURE)
193
   bool Stepper::frozen; // = false
193
   bool Stepper::frozen; // = false
194
 #endif
194
 #endif
195
 
195
 
1643
   if (!current_block) return;
1643
   if (!current_block) return;
1644
 
1644
 
1645
   // Skipping step processing causes motion to freeze
1645
   // Skipping step processing causes motion to freeze
1646
-  if (TERN0(HAS_FREEZE_PIN, frozen)) return;
1646
+  if (TERN0(FREEZE_FEATURE, frozen)) return;
1647
 
1647
 
1648
   // Count of pending loops and events for this iteration
1648
   // Count of pending loops and events for this iteration
1649
   const uint32_t pending_events = step_event_count - step_events_completed;
1649
   const uint32_t pending_events = step_event_count - step_events_completed;

+ 1
- 1
Marlin/src/module/stepper.h View File

336
       static constexpr uint8_t last_moved_extruder = 0;
336
       static constexpr uint8_t last_moved_extruder = 0;
337
     #endif
337
     #endif
338
 
338
 
339
-    #if HAS_FREEZE_PIN
339
+    #if ENABLED(FREEZE_FEATURE)
340
       static bool frozen;                   // Set this flag to instantly freeze motion
340
       static bool frozen;                   // Set this flag to instantly freeze motion
341
     #endif
341
     #endif
342
 
342
 

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

823
 #if HAS_KILL
823
 #if HAS_KILL
824
   REPORT_NAME_DIGITAL(__LINE__, KILL_PIN)
824
   REPORT_NAME_DIGITAL(__LINE__, KILL_PIN)
825
 #endif
825
 #endif
826
-#if HAS_FREEZE_PIN
826
+#if PIN_EXISTS(FREEZE)
827
   REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN)
827
   REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN)
828
 #endif
828
 #endif
829
 #if PIN_EXISTS(LCD_BACKLIGHT)
829
 #if PIN_EXISTS(LCD_BACKLIGHT)

Loading…
Cancel
Save