Welcome! Log In Create A New Profile

Advanced

Endstop pullup code

Posted by normw 
Endstop pullup code
November 21, 2014 01:47PM
Can someone explain the endstoppullups #define?

// coarse Endstop Settings
#define ENDSTOPPULLUPS // Comment this out (using // at the start of the line) to disable the endstop pullup resistors

#ifndef ENDSTOPPULLUPS
// fine endstop settings: Individual pullups. will be ignored if ENDSTOPPULLUPS is defined
// #define ENDSTOPPULLUP_XMAX
// #define ENDSTOPPULLUP_YMAX
// #define ENDSTOPPULLUP_ZMAX
// #define ENDSTOPPULLUP_XMIN
// #define ENDSTOPPULLUP_YMIN
// #define ENDSTOPPULLUP_ZMIN
#endif

#ifdef ENDSTOPPULLUPS
#define ENDSTOPPULLUP_XMAX
#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
#endif
The endstop pullup code looks redundant. I think the coarse endstop define turns the endstop pullups off completely and the following endstoppullups blocks are ignored.

The next two blocks of endstop defines appear to be redundant.

Thanks
Re: Endstop pullup code
November 24, 2014 04:38AM
The "#define ENDSTOPPULLUPS" just creates the define ENDSTOPPULLUPS, does nothing else


you then have two blocks of code

#ifndef ENDSTOPPULLUPS (note the n in there, if not defined)
...
#endif

and

#ifdef ENDSTOPPULLUPS
...
#endif

First block is run if ENDSTOPPULLUPS is not defined second block is run if it is defined.

the various "#define ENDSTOPPULLUP_XMAX" define the actual endstops to pull up.

so ENDSTOPPULLUPS is being used to activate all defines in the second block, which by default should be all of them.


is it code duplication, a little, but code is like that quite often.
Re: Endstop pullup code
November 24, 2014 10:15AM
Thanks Dust, the duplication does not seem necessary, but as long as the computer is not confused I guess we're OK.
Sorry, only registered users may post in this forum.

Click here to login