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

NUM_ENDSTOP_STATES incorrect when Z_MIN_PROBE = Z_MIN #27190

Merged
merged 3 commits into from
Jul 13, 2024

Conversation

tombrazier
Copy link
Contributor

Description

When Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN is defined, NUM_ENDSTOP_STATES can end up being incorrect. This is because NUM_ENDSTOP_STATES is assigned the value Z_MIN_PROBE + 1 by the compiler and, in this particular case, Z_MIN_PROBE is an alias for Z_MIN.

An example case is when Z_HOME_DIR == 1, in which case the following asserts should work:

static_assert(X_MIN == 0);
static_assert(Y_MIN == 1);
static_assert(Z_MIN == 2);
static_assert(Z_MAX == 3);
static_assert(NUM_ENDSTOP_STATES == 4);
static_assert(X_ENDSTOP == X_MIN);
static_assert(Y_ENDSTOP == Y_MIN);
static_assert(Z_ENDSTOP == Z_MAX);
static_assert(Z_MIN_PROBE == Z_MIN);

However in this case NUM_ENDSTOP_STATES ends up being Z_MIN_PROBE + 1 == Z_MIN + 1 == 3.

Requirements

N/A

Benefits

This fixes an edge case where endstop_mask_t has an underlying type which is too narrow.

Configurations

configs.zip

Related Issues

@thinkyhead thinkyhead force-pushed the endstop_count_bug branch from dbe9f13 to 7258958 Compare July 5, 2024 03:09
@thinkyhead thinkyhead merged commit 57bda2f into MarlinFirmware:bugfix-2.1.x Jul 13, 2024
62 checks passed
thinkyhead added a commit to thinkyhead/Marlin that referenced this pull request Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants