Skip to content

Commit

Permalink
🎨 Various multi-axis patches (MarlinFirmware#22823)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead authored and pull[bot] committed Oct 4, 2021
1 parent da070c1 commit a0e790e
Show file tree
Hide file tree
Showing 20 changed files with 174 additions and 127 deletions.
24 changes: 12 additions & 12 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,37 +794,37 @@
#define ENDSTOPPULLUPS
#if DISABLED(ENDSTOPPULLUPS)
// Disable ENDSTOPPULLUPS to set pullups individually
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_IMAX
//#define ENDSTOPPULLUP_JMAX
//#define ENDSTOPPULLUP_KMAX
//#define ENDSTOPPULLUP_XMIN
//#define ENDSTOPPULLUP_YMIN
//#define ENDSTOPPULLUP_ZMIN
//#define ENDSTOPPULLUP_IMIN
//#define ENDSTOPPULLUP_JMIN
//#define ENDSTOPPULLUP_KMIN
//#define ENDSTOPPULLUP_XMAX
//#define ENDSTOPPULLUP_YMAX
//#define ENDSTOPPULLUP_ZMAX
//#define ENDSTOPPULLUP_IMAX
//#define ENDSTOPPULLUP_JMAX
//#define ENDSTOPPULLUP_KMAX
//#define ENDSTOPPULLUP_ZMIN_PROBE
#endif

// Enable pulldown for all endstops to prevent a floating state
//#define ENDSTOPPULLDOWNS
#if DISABLED(ENDSTOPPULLDOWNS)
// Disable ENDSTOPPULLDOWNS to set pulldowns individually
//#define ENDSTOPPULLDOWN_XMAX
//#define ENDSTOPPULLDOWN_YMAX
//#define ENDSTOPPULLDOWN_ZMAX
//#define ENDSTOPPULLDOWN_IMAX
//#define ENDSTOPPULLDOWN_JMAX
//#define ENDSTOPPULLDOWN_KMAX
//#define ENDSTOPPULLDOWN_XMIN
//#define ENDSTOPPULLDOWN_YMIN
//#define ENDSTOPPULLDOWN_ZMIN
//#define ENDSTOPPULLDOWN_IMIN
//#define ENDSTOPPULLDOWN_JMIN
//#define ENDSTOPPULLDOWN_KMIN
//#define ENDSTOPPULLDOWN_XMAX
//#define ENDSTOPPULLDOWN_YMAX
//#define ENDSTOPPULLDOWN_ZMAX
//#define ENDSTOPPULLDOWN_IMAX
//#define ENDSTOPPULLDOWN_JMAX
//#define ENDSTOPPULLDOWN_KMAX
//#define ENDSTOPPULLDOWN_ZMIN_PROBE
#endif

Expand Down
12 changes: 8 additions & 4 deletions Marlin/src/HAL/SAMD51/endstop_interrupts.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,14 @@ void setup_endstop_interrupts() {
#error "Z_MIN_PROBE_PIN has no EXTINT line available."
#endif
_ATTACH(Z_MIN_PROBE_PIN);
#elif HAS_I_MAX
#endif
#if HAS_I_MAX
#if !AVAILABLE_EILINE(I_MAX_PIN)
#error "I_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(I_MAX_PIN, endstop_ISR, CHANGE);
#elif HAS_I_MIN
#endif
#if HAS_I_MIN
#if !AVAILABLE_EILINE(I_MIN_PIN)
#error "I_MIN_PIN has no EXTINT line available."
#endif
Expand All @@ -178,7 +180,8 @@ void setup_endstop_interrupts() {
#error "J_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(J_MAX_PIN, endstop_ISR, CHANGE);
#elif HAS_J_MIN
#endif
#if HAS_J_MIN
#if !AVAILABLE_EILINE(J_MIN_PIN)
#error "J_MIN_PIN has no EXTINT line available."
#endif
Expand All @@ -189,7 +192,8 @@ void setup_endstop_interrupts() {
#error "K_MAX_PIN has no EXTINT line available."
#endif
attachInterrupt(K_MAX_PIN, endstop_ISR, CHANGE);
#elif HAS_K_MIN
#endif
#if HAS_K_MIN
#if !AVAILABLE_EILINE(K_MIN_PIN)
#error "K_MIN_PIN has no EXTINT line available."
#endif
Expand Down
63 changes: 37 additions & 26 deletions Marlin/src/core/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,32 +33,32 @@

#define _AXIS(A) (A##_AXIS)

#define _XMIN_ 100
#define _YMIN_ 200
#define _ZMIN_ 300
#define _IMIN_ 500
#define _JMIN_ 600
#define _KMIN_ 700
#define _XMAX_ 101
#define _YMAX_ 201
#define _ZMAX_ 301
#define _IMAX_ 501
#define _JMAX_ 601
#define _KMAX_ 701
#define _XDIAG_ 102
#define _YDIAG_ 202
#define _ZDIAG_ 302
#define _IDIAG_ 502
#define _JDIAG_ 602
#define _KDIAG_ 702
#define _E0DIAG_ 400
#define _E1DIAG_ 401
#define _E2DIAG_ 402
#define _E3DIAG_ 403
#define _E4DIAG_ 404
#define _E5DIAG_ 405
#define _E6DIAG_ 406
#define _E7DIAG_ 407
#define _XMIN_ 0x11
#define _YMIN_ 0x12
#define _ZMIN_ 0x13
#define _IMIN_ 0x14
#define _JMIN_ 0x15
#define _KMIN_ 0x16
#define _XMAX_ 0x21
#define _YMAX_ 0x22
#define _ZMAX_ 0x23
#define _IMAX_ 0x24
#define _JMAX_ 0x25
#define _KMAX_ 0x26
#define _XDIAG_ 0x31
#define _YDIAG_ 0x32
#define _ZDIAG_ 0x33
#define _IDIAG_ 0x34
#define _JDIAG_ 0x35
#define _KDIAG_ 0x36
#define _E0DIAG_ 0xE0
#define _E1DIAG_ 0xE1
#define _E2DIAG_ 0xE2
#define _E3DIAG_ 0xE3
#define _E4DIAG_ 0xE4
#define _E5DIAG_ 0xE5
#define _E6DIAG_ 0xE6
#define _E7DIAG_ 0xE7

#define _FORCE_INLINE_ __attribute__((__always_inline__)) __inline__
#define FORCE_INLINE __attribute__((always_inline)) inline
Expand Down Expand Up @@ -251,6 +251,8 @@
memcpy(&a[0],&b[0],_MIN(sizeof(a),sizeof(b))); \
}while(0)

#define CODE_11( A,B,C,D,E,F,G,H,I,J,K,...) A; B; C; D; E; F; G; H; I; J; K
#define CODE_10( A,B,C,D,E,F,G,H,I,J,...) A; B; C; D; E; F; G; H; I; J
#define CODE_9( A,B,C,D,E,F,G,H,I,...) A; B; C; D; E; F; G; H; I
#define CODE_8( A,B,C,D,E,F,G,H,...) A; B; C; D; E; F; G; H
#define CODE_7( A,B,C,D,E,F,G,...) A; B; C; D; E; F; G
Expand Down Expand Up @@ -286,6 +288,10 @@
#define GANG_N_1(N,K) _GANG_N(N,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K,K)

// Macros for initializing arrays
#define LIST_20(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T
#define LIST_19(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S
#define LIST_18(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R
#define LIST_17(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q
#define LIST_16(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P
#define LIST_15(A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N,O
#define LIST_14(A,B,C,D,E,F,G,H,I,J,K,L,M,N,...) A,B,C,D,E,F,G,H,I,J,K,L,M,N
Expand Down Expand Up @@ -502,6 +508,11 @@
#define INC_13 14
#define INC_14 15
#define INC_15 16
#define INC_16 17
#define INC_17 18
#define INC_18 19
#define INC_19 20
#define INC_20 21
#define INCREMENT_(n) INC_##n
#define INCREMENT(n) INCREMENT_(n)

Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/feature/backlash.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ Backlash backlash;
* spread over multiple segments, smoothing out artifacts even more.
*/

void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block) {
static uint8_t last_direction_bits;
uint8_t changed_dir = last_direction_bits ^ dm;
void Backlash::add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block) {
static axis_bits_t last_direction_bits;
axis_bits_t changed_dir = last_direction_bits ^ dm;
// Ignore direction change unless steps are taken in that direction
#if DISABLED(CORE_BACKLASH) || ENABLED(MARKFORGED_XY)
if (!da) CBI(changed_dir, X_AXIS);
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/backlash.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Backlash {
return has_measurement(X_AXIS) || has_measurement(Y_AXIS) || has_measurement(Z_AXIS);
}

void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const uint8_t dm, block_t * const block);
void add_correction_steps(const int32_t &da, const int32_t &db, const int32_t &dc, const axis_bits_t dm, block_t * const block);
};

extern Backlash backlash;
6 changes: 3 additions & 3 deletions Marlin/src/gcode/config/M217.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ void GcodeSuite::M217_report(const bool forReplay/*=true*/) {
SP_E_STR, LINEAR_UNIT(toolchange_settings.extra_prime),
SP_P_STR, LINEAR_UNIT(toolchange_settings.prime_speed));
SERIAL_ECHOPGM(" R", LINEAR_UNIT(toolchange_settings.retract_speed),
" U", LINEAR_UNIT(toolchange_settings.unretract_speed),
" F", toolchange_settings.fan_speed,
" G", toolchange_settings.fan_time);
" U", LINEAR_UNIT(toolchange_settings.unretract_speed),
" F", toolchange_settings.fan_speed,
" G", toolchange_settings.fan_time);

#if ENABLED(TOOLCHANGE_MIGRATION_FEATURE)
SERIAL_ECHOPGM(" A", migration.automode);
Expand Down
26 changes: 11 additions & 15 deletions Marlin/src/gcode/feature/trinamic/M906.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,8 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) {
SERIAL_ECHOPGM(" M906");
};

#if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z)
#if AXIS_IS_TMC(X) || AXIS_IS_TMC(Y) || AXIS_IS_TMC(Z) \
|| AXIS_IS_TMC(I) || AXIS_IS_TMC(J) || AXIS_IS_TMC(K)
say_M906(forReplay);
#if AXIS_IS_TMC(X)
SERIAL_ECHOPGM_P(SP_X_STR, stepperX.getMilliamps());
Expand All @@ -217,6 +218,15 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) {
#if AXIS_IS_TMC(Z)
SERIAL_ECHOPGM_P(SP_Z_STR, stepperZ.getMilliamps());
#endif
#if AXIS_IS_TMC(I)
SERIAL_ECHOPGM_P(SP_I_STR, stepperI.getMilliamps());
#endif
#if AXIS_IS_TMC(J)
SERIAL_ECHOPGM_P(SP_J_STR, stepperJ.getMilliamps());
#endif
#if AXIS_IS_TMC(K)
SERIAL_ECHOPGM_P(SP_K_STR, stepperK.getMilliamps());
#endif
SERIAL_EOL();
#endif

Expand All @@ -239,25 +249,11 @@ void GcodeSuite::M906_report(const bool forReplay/*=true*/) {
say_M906(forReplay);
SERIAL_ECHOLNPGM(" I2 Z", stepperZ3.getMilliamps());
#endif

#if AXIS_IS_TMC(Z4)
say_M906(forReplay);
SERIAL_ECHOLNPGM(" I3 Z", stepperZ4.getMilliamps());
#endif

#if AXIS_IS_TMC(I)
say_M906(forReplay);
SERIAL_ECHOLNPGM_P(SP_I_STR, stepperI.getMilliamps());
#endif
#if AXIS_IS_TMC(J)
say_M906(forReplay);
SERIAL_ECHOLNPGM_P(SP_J_STR, stepperJ.getMilliamps());
#endif
#if AXIS_IS_TMC(K)
say_M906(forReplay);
SERIAL_ECHOLNPGM_P(SP_K_STR, stepperK.getMilliamps());
#endif

#if AXIS_IS_TMC(E0)
say_M906(forReplay);
SERIAL_ECHOLNPGM(" T0 E", stepperE0.getMilliamps());
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ millis_t GcodeSuite::previous_move_ms = 0,

// Relative motion mode for each logical axis
static constexpr xyze_bool_t ar_init = AXIS_RELATIVE_MODES;
uint8_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG(
axis_bits_t GcodeSuite::axis_relative = 0 LOGICAL_AXIS_GANG(
| (ar_init.e << REL_E),
| (ar_init.x << REL_X),
| (ar_init.y << REL_Y),
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ extern const char G28_STR[];
class GcodeSuite {
public:

static uint8_t axis_relative;
static axis_bits_t axis_relative;

static inline bool axis_is_relative(const AxisEnum a) {
#if HAS_EXTRUDERS
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/gcode/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ void GCodeQueue::RingBuffer::ok_to_send() {
while (NUMERIC_SIGNED(*p))
SERIAL_CHAR(*p++);
}
SERIAL_ECHOPGM_P(SP_P_STR, planner.moves_free(),
SP_B_STR, BUFSIZE - length);
SERIAL_ECHOPGM_P(SP_P_STR, planner.moves_free(), SP_B_STR, BUFSIZE - length);
#endif
SERIAL_EOL();
}
Expand Down
26 changes: 10 additions & 16 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -1922,20 +1922,14 @@
#ifndef Z4_INTERPOLATE
#define Z4_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 4
#ifndef I_INTERPOLATE
#define I_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 4 && !defined(I_INTERPOLATE)
#define I_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 5
#ifndef J_INTERPOLATE
#define J_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 5 && !defined(J_INTERPOLATE)
#define J_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 6
#ifndef K_INTERPOLATE
#define K_INTERPOLATE INTERPOLATE
#endif
#if LINEAR_AXES >= 6 && !defined(K_INTERPOLATE)
#define K_INTERPOLATE INTERPOLATE
#endif
#ifndef E0_INTERPOLATE
#define E0_INTERPOLATE INTERPOLATE
Expand All @@ -1962,13 +1956,13 @@
#define E7_INTERPOLATE INTERPOLATE
#endif
#ifndef X_SLAVE_ADDRESS
#define X_SLAVE_ADDRESS 0
#define X_SLAVE_ADDRESS 0
#endif
#ifndef Y_SLAVE_ADDRESS
#define Y_SLAVE_ADDRESS 0
#define Y_SLAVE_ADDRESS 0
#endif
#ifndef Z_SLAVE_ADDRESS
#define Z_SLAVE_ADDRESS 0
#define Z_SLAVE_ADDRESS 0
#endif
#ifndef I_SLAVE_ADDRESS
#define I_SLAVE_ADDRESS 0
Expand Down Expand Up @@ -2660,7 +2654,7 @@
#if HAS_EXTRUDERS && PIN_EXISTS(MOTOR_CURRENT_PWM_E)
#define HAS_MOTOR_CURRENT_PWM_E 1
#endif
#if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z)
#if HAS_MOTOR_CURRENT_PWM_E || ANY_PIN(MOTOR_CURRENT_PWM_X, MOTOR_CURRENT_PWM_Y, MOTOR_CURRENT_PWM_XY, MOTOR_CURRENT_PWM_Z, MOTOR_CURRENT_PWM_I, MOTOR_CURRENT_PWM_J, MOTOR_CURRENT_PWM_K)
#define HAS_MOTOR_CURRENT_PWM 1
#endif

Expand Down
12 changes: 9 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1404,8 +1404,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif
#if LINEAR_AXES >= 5
#if AXIS5_NAME == AXIS4_NAME || AXIS5_NAME == AXIS6_NAME
#error "AXIS5_NAME must be different from AXIS4_NAME and AXIS6_NAME"
#if AXIS5_NAME == AXIS4_NAME
#error "AXIS5_NAME must be unique."
#elif AXIS5_NAME != 'A' && AXIS5_NAME != 'B' && AXIS5_NAME != 'C' && AXIS5_NAME != 'U' && AXIS5_NAME != 'V' && AXIS5_NAME != 'W'
#error "AXIS5_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'."
#elif !defined(J_MIN_POS) || !defined(J_MAX_POS)
Expand All @@ -1418,7 +1418,7 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#if LINEAR_AXES >= 6
#if AXIS6_NAME == AXIS5_NAME || AXIS6_NAME == AXIS4_NAME
#error "AXIS6_NAME must be different from AXIS5_NAME and AXIS4_NAME."
#error "AXIS6_NAME must be unique."
#elif AXIS6_NAME != 'A' && AXIS6_NAME != 'B' && AXIS6_NAME != 'C' && AXIS6_NAME != 'U' && AXIS6_NAME != 'V' && AXIS6_NAME != 'W'
#error "AXIS6_NAME can only be one of 'A', 'B', 'C', 'U', 'V', or 'W'."
#elif !defined(K_MIN_POS) || !defined(K_MAX_POS)
Expand Down Expand Up @@ -3040,10 +3040,16 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMIN (or ENDSTOPPULLUPS) when homing to Z_MIN."
#elif Z_SENSORLESS && Z_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_ZMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_ZMAX (or ENDSTOPPULLUPS) when homing to Z_MAX."
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_IMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMIN (or ENDSTOPPULLUPS) when homing to I_MIN."
#elif LINEAR_AXES >= 4 && I_SENSORLESS && I_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_IMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_IMAX (or ENDSTOPPULLUPS) when homing to I_MAX."
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_JMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMIN (or ENDSTOPPULLUPS) when homing to J_MIN."
#elif LINEAR_AXES >= 5 && J_SENSORLESS && J_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_JMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_JMAX (or ENDSTOPPULLUPS) when homing to J_MAX."
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MIN && DISABLED(ENDSTOPPULLUP_KMIN)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMIN (or ENDSTOPPULLUPS) when homing to K_MIN."
#elif LINEAR_AXES >= 6 && K_SENSORLESS && K_HOME_TO_MAX && DISABLED(ENDSTOPPULLUP_KMAX)
#error "SENSORLESS_HOMING requires ENDSTOPPULLUP_KMAX (or ENDSTOPPULLUPS) when homing to K_MAX."
#endif
Expand Down
Loading

0 comments on commit a0e790e

Please sign in to comment.