Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable FREEZE pin state #23944

Merged
merged 3 commits into from
Mar 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -4113,6 +4113,7 @@
//#define FREEZE_FEATURE
#if ENABLED(FREEZE_FEATURE)
//#define FREEZE_PIN 41 // Override the default (KILL) pin here
#define FREEZE_STATE LOW // State of pin indicating freeze
#endif

/**
Expand Down
10 changes: 7 additions & 3 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
#endif

#if HAS_FREEZE_PIN
Stepper::frozen = !READ(FREEZE_PIN);
Stepper::frozen = READ(FREEZE_PIN) ^ DISABLED(INVERT_FREEZE_PIN);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is INVERT_FREEZE_PIN still present?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope. This will need another patch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR is all messed up now.
FREEZE_STATE only enables pullup or pull down and does not invert the logic level.
The entire original purpose of PR has been lost.

To many busy bodies and a rouge main programmer.
It enough to drive me around the bend.

#endif

#if HAS_HOME
Expand Down Expand Up @@ -1166,9 +1166,13 @@ void setup() {
#endif
#endif

#if HAS_FREEZE_PIN
#if ENABLED(FREEZE_FEATURE)
SETUP_LOG("FREEZE_PIN");
SET_INPUT_PULLUP(FREEZE_PIN);
#if FREEZE_STATE
SET_INPUT_PULLDOWN(FREEZE_PIN);
#else
SET_INPUT_PULLUP(FREEZE_PIN);
#endif
#endif

#if HAS_SUICIDE
Expand Down
14 changes: 3 additions & 11 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2824,17 +2824,9 @@
#endif

// User Interface
#if ENABLED(FREEZE_FEATURE)
#if !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
#define FREEZE_PIN KILL_PIN
#endif
#if PIN_EXISTS(FREEZE)
#define HAS_FREEZE_PIN 1
#endif
#else
#undef FREEZE_PIN
#endif
#if PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE) && PIN_EXISTS(KILL)
#define FREEZE_PIN KILL_PIN
#elif PIN_EXISTS(KILL) && TERN1(FREEZE_FEATURE, KILL_PIN != FREEZE_PIN)
#define HAS_KILL 1
#endif
#if PIN_EXISTS(HOME)
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1044,8 +1044,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
/**
* Instant Freeze
*/
#if ENABLED(FREEZE_FEATURE) && !PIN_EXISTS(FREEZE)
#error "FREEZE_FEATURE requires a FREEZE_PIN to be defined."
#if ENABLED(FREEZE_FEATURE) && !(PIN_EXISTS(FREEZE) && defined(FREEZE_STATE))
#error "FREEZE_FEATURE requires both FREEZE_PIN and FREEZE_STATE."
#endif

/**
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/module/stepper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ bool Stepper::abort_current_block;
uint32_t Stepper::acceleration_time, Stepper::deceleration_time;
uint8_t Stepper::steps_per_isr;

#if HAS_FREEZE_PIN
#if ENABLED(FREEZE_FEATURE)
bool Stepper::frozen; // = false
#endif

Expand Down Expand Up @@ -1643,7 +1643,7 @@ void Stepper::pulse_phase_isr() {
if (!current_block) return;

// Skipping step processing causes motion to freeze
if (TERN0(HAS_FREEZE_PIN, frozen)) return;
if (TERN0(FREEZE_FEATURE, frozen)) return;

// Count of pending loops and events for this iteration
const uint32_t pending_events = step_event_count - step_events_completed;
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ class Stepper {
static constexpr uint8_t last_moved_extruder = 0;
#endif

#if HAS_FREEZE_PIN
#if ENABLED(FREEZE_FEATURE)
static bool frozen; // Set this flag to instantly freeze motion
#endif

Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/pins/pinsDebug_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,7 @@
#if HAS_KILL
REPORT_NAME_DIGITAL(__LINE__, KILL_PIN)
#endif
#if HAS_FREEZE_PIN
#if PIN_EXISTS(FREEZE)
REPORT_NAME_DIGITAL(__LINE__, FREEZE_PIN)
#endif
#if PIN_EXISTS(LCD_BACKLIGHT)
Expand Down