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

Drop DISABLE_Z_MIN_PROBE_ENDSTOP, clean up probe config #4842

Conversation

thinkyhead
Copy link
Member

@thinkyhead thinkyhead commented Sep 19, 2016

Clean up probe configuration, reducing complexity somewhat.

  • Remove DISABLE_Z_MIN_PROBE_ENDSTOP entirely.
  • Undefine Z_MIN_PROBE_PIN unless using Z_MIN_PROBE_ENDSTOP.
  • Undefine Z_MIN_PROBE_ENDSTOP and Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN when no probe is selected.
  • Make Z_MIN_PROBE_PIN override option available in Configuration.h.
  • Remove obsolete sanity checks for servo probes.
  • Use counting method to test whether more than one probe is enabled.
  • Simplify conditionals in endstops.cpp - pre-filtered by sanity checking.
  • Move some probe conditionals to Conditionals_LCD.h (soon change to Conditionals_pre.h)

@thinkyhead thinkyhead force-pushed the rc_DISABLE_Z_MIN_PROBE_ENDSTOP_whassup branch from f6dd3ad to e05af60 Compare September 19, 2016 05:26
@Roxy-3D
Copy link
Member

Roxy-3D commented Sep 20, 2016

Did you stumble on the reason why this got added in the first place? I'm sure at the time, there was a good reason for it. But right now, I'm glad to see it gone!

I wish we could do it without #undef's however! But the #undef's were already in that area of the code. You didn't add any extra #undef's.

Quick Questions: Is it worth trying to remove all the #undef's in the code? My big problem with them is I don't have a good idea of the 'priority' (if any) that is followed. If there was some easy to understand hierarchy about when a #define was vulnerable to be #undef'ed that would help me.

2nd Quick Question: I think we could just be smarter on the #define's to not do them so we don't need to do an #undef later. Is that true? Is it a huge amount of work if that is true?

@thinkyhead
Copy link
Member Author

thinkyhead commented Sep 20, 2016

For the BLTOUCH certain settings need to be applied. You can only redefine a setting if it is not already defined, and so undef is needed for that. It makes more sense for something like BLTOUCH to enforce its 3 or 4 required settings, which are otherwise obscure to new users. And we cannot sanity check certain types of settings, such as the servo angles, except to tell users to define them. This is prettty much what the Conditionals files are about. To ease the burden on end-users when one setting requires several others to be just so.

@thinkyhead
Copy link
Member Author

thinkyhead commented Sep 20, 2016

In general, I have been moving towards getting better control over the specific order where things are defined, to ensure that things are set and/or overridden in the most controlled manner possible. It's the reason we have MarlinConfig.h now instead of the #include lines that used to be at the start end end of the Configuration.h file. This was especially vital to allow overriding pins earlier, in Configuration.h (where allowance has been made for custom overrides) without needing to use #undef later.

You'll notice that you can do something like #define MYTHIING OTHERTHING and the OTHERTHING symbol doesn't have to be defined first. It only has to be defined at some point before MYTHING is used in the code. The precompiler will wait to resolve the symbol until then, following a chain of defines if needed to arrive at the final substitution.

I think, generally, the use of #undef has been pared down to a decent minimum, and it's used well. For example, in the pins.h file it is used to hide pins that are not needed, because some code compiles just on the basis of the pin being defined. This allows the individual board pins files to be much simpler and more readable. Another benefit of enforcing the include order well, through the "hub" files MarlinConfig.h, language.h, and pins.h.

@thinkyhead
Copy link
Member Author

Note that the only reason I am able to add the "Make Z_MIN_PROBE_PIN override option available in Configuration.h" bullet item is because weeks ago I patched it to be overrideable in all the pins files. This isn't a general method that could apply for all pins, just those that get a similar treatment.

@thinkyhead
Copy link
Member Author

thinkyhead commented Sep 20, 2016

Before I merge this, I might want to add a sanity check for DISABLE_Z_MIN_PROBE_ENDSTOP and tell users to remove it. Maybe someone will perk up and tell us they need it for some reason. But we can provide a better solution if that's the case. Andreas was never able to articulate a real use case for it, and there's none that I can imagine with the current code.

My understanding is that it existed only because of the way the pin was being defined before, and it has become obsolete because we control that better now.

@thinkyhead thinkyhead merged commit 7ae351c into MarlinFirmware:RCBugFix Sep 20, 2016
@thinkyhead thinkyhead deleted the rc_DISABLE_Z_MIN_PROBE_ENDSTOP_whassup branch September 20, 2016 17:16
@thinkyhead thinkyhead mentioned this pull request Oct 24, 2016
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