Skip to content

Commit

Permalink
Fix INDEX_OF_AXIS
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Sep 23, 2021
1 parent b87ab9b commit ea051e1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
10 changes: 9 additions & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@
* HOTENDS - Number of hotends, whether connected or separate
* E_STEPPERS - Number of actual E stepper motors
* E_MANUAL - Number of E steppers for LCD move options
*
* These defines must be simple constants for use in REPEAT, etc.
*/
#if EXTRUDERS
#define HAS_EXTRUDERS 1
Expand Down Expand Up @@ -602,7 +604,13 @@

#elif ENABLED(SWITCHING_EXTRUDER) // One stepper for every two EXTRUDERS

#define E_STEPPERS ((EXTRUDERS + 1) / 2)
#if EXTRUDERS > 4
#define E_STEPPERS 3
#elif EXTRUDERS > 2
#define E_STEPPERS 2
#else
#define E_STEPPERS 1
#endif
#if DISABLED(SWITCHING_NOZZLE)
#define HOTENDS E_STEPPERS
#endif
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/module/stepper.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,10 +260,16 @@ constexpr pin_t ena_pins[] = {
};

// Index of the axis or extruder element in a combined array
constexpr int8_t index_of_axis(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
constexpr uint8_t index_of_axis(const AxisEnum axis E_OPTARG(const uint8_t eindex=0)) {
return uint8_t(axis) + (E_TERN0(axis < LINEAR_AXES ? 0 : eindex));
}
#define INDEX_OF_AXIS(A,V...) index_of_axis(A E_OPTARG(#V))
//#define __IAX_N(N,V...) _IAX_##N(V)
//#define _IAX_N(N,V...) __IAX_N(N,V)
//#define _IAX_1(A) index_of_axis(A)
//#define _IAX_2(A,B) index_of_axis(A E_OPTARG(B))
//#define INDEX_OF_AXIS(V...) _IAX_N(TWO_ARGS(V),V)

#define INDEX_OF_AXIS(A,V...) index_of_axis(A E_OPTARG(V+0))

// Bit mask for a matching enable pin, or 0
constexpr uint16_t ena_same(const uint8_t a, const uint8_t b) {
Expand Down

0 comments on commit ea051e1

Please sign in to comment.