Skip to content

Commit

Permalink
♻️ Patches for Zero Extruders (with TMC)
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jun 15, 2021
1 parent 4194cdd commit d3c56a7
Show file tree
Hide file tree
Showing 10 changed files with 324 additions and 273 deletions.
4 changes: 2 additions & 2 deletions Marlin/src/core/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ struct XYZval {
FI void set(const XYval<T> pxy, const T pz) { x = pxy.x; y = pxy.y; z = pz; }
FI void set(const T (&arr)[XY]) { x = arr[0]; y = arr[1]; }
FI void set(const T (&arr)[LINEAR_AXES]) { LINEAR_AXIS_CODE(x = arr[0], y = arr[1], z = arr[2]); }
#if LINEAR_AXES >= XYZ
#if HAS_Z_AXIS
FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz))
{ LINEAR_AXIS_CODE(x = px, y = py, z = pz); }
#endif
Expand Down Expand Up @@ -475,7 +475,7 @@ struct XYZEval {
FI void set(const T px, const T py) { x = px; y = py; }
FI void set(const XYval<T> pxy) { x = pxy.x; y = pxy.y; }
FI void set(const XYZval<T> pxyz) { set(LINEAR_AXIS_LIST(pxyz.x, pxyz.y, pxyz.z)); }
#if LINEAR_AXES >= XYZ
#if HAS_Z_AXIS
FI void set(LINEAR_AXIS_LIST(const T px, const T py, const T pz)) {
LINEAR_AXIS_CODE(x = px, y = py, z = pz);
}
Expand Down
88 changes: 48 additions & 40 deletions Marlin/src/feature/tmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -770,16 +770,18 @@
#endif
}

if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_status(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_status(stepperY2, i);
#endif
}
#if LINEAR_AXES >= XY
if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_status(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_status(stepperY2, i);
#endif
}
#endif

if (print_z) {
if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z)
tmc_status(stepperZ, i);
#endif
Expand All @@ -794,7 +796,7 @@
#endif
}

if (print_e) {
if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0)
tmc_status(stepperE0, i);
#endif
Expand Down Expand Up @@ -837,16 +839,18 @@
#endif
}

if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_parse_drv_status(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_parse_drv_status(stepperY2, i);
#endif
}
#if LINEAR_AXES >= XY
if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_parse_drv_status(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_parse_drv_status(stepperY2, i);
#endif
}
#endif

if (print_z) {
if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z)
tmc_parse_drv_status(stepperZ, i);
#endif
Expand All @@ -861,7 +865,7 @@
#endif
}

if (print_e) {
if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0)
tmc_parse_drv_status(stepperE0, i);
#endif
Expand Down Expand Up @@ -1037,16 +1041,18 @@
#endif
}

if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_get_registers(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_get_registers(stepperY2, i);
#endif
}
#if LINEAR_AXES >= XY
if (print_y) {
#if AXIS_IS_TMC(Y)
tmc_get_registers(stepperY, i);
#endif
#if AXIS_IS_TMC(Y2)
tmc_get_registers(stepperY2, i);
#endif
}
#endif

if (print_z) {
if (TERN0(HAS_Z_AXIS, print_z)) {
#if AXIS_IS_TMC(Z)
tmc_get_registers(stepperZ, i);
#endif
Expand All @@ -1061,7 +1067,7 @@
#endif
}

if (print_e) {
if (TERN0(HAS_EXTRUDERS, print_e)) {
#if AXIS_IS_TMC(E0)
tmc_get_registers(stepperE0, i);
#endif
Expand Down Expand Up @@ -1242,16 +1248,18 @@ void test_tmc_connection(
#endif
}

if (test_y) {
#if AXIS_IS_TMC(Y)
axis_connection += test_connection(stepperY);
#endif
#if AXIS_IS_TMC(Y2)
axis_connection += test_connection(stepperY2);
#endif
}
#if LINEAR_AXES >= XY
if (test_y) {
#if AXIS_IS_TMC(Y)
axis_connection += test_connection(stepperY);
#endif
#if AXIS_IS_TMC(Y2)
axis_connection += test_connection(stepperY2);
#endif
}
#endif

if (test_z) {
if (TERN0(HAS_Z_AXIS, test_z)) {
#if AXIS_IS_TMC(Z)
axis_connection += test_connection(stepperZ);
#endif
Expand All @@ -1266,7 +1274,7 @@ void test_tmc_connection(
#endif
}

if (test_e) {
if (TERN0(HAS_EXTRUDERS, test_e)) {
#if AXIS_IS_TMC(E0)
axis_connection += test_connection(stepperE0);
#endif
Expand Down
101 changes: 55 additions & 46 deletions Marlin/src/gcode/feature/L6470/M906.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,58 +252,67 @@ void GcodeSuite::M906() {
if (index == 1) L6470_SET_KVAL_HOLD(X2);
#endif
break;
case Y_AXIS:
#if AXIS_IS_L64XX(Y)
if (index == 0) L6470_SET_KVAL_HOLD(Y);
#endif
#if AXIS_IS_L64XX(Y2)
if (index == 1) L6470_SET_KVAL_HOLD(Y2);
#endif
break;
case Z_AXIS:
#if AXIS_IS_L64XX(Z)
if (index == 0) L6470_SET_KVAL_HOLD(Z);
#endif
#if AXIS_IS_L64XX(Z2)
if (index == 1) L6470_SET_KVAL_HOLD(Z2);
#endif
#if AXIS_IS_L64XX(Z3)
if (index == 2) L6470_SET_KVAL_HOLD(Z3);
#endif
#if AXIS_DRIVER_TYPE_Z4(L6470)
if (index == 3) L6470_SET_KVAL_HOLD(Z4);
#endif
break;
case E_AXIS: {
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
switch (target_extruder) {
#if AXIS_IS_L64XX(E0)
case 0: L6470_SET_KVAL_HOLD(E0); break;
#endif
#if AXIS_IS_L64XX(E1)
case 1: L6470_SET_KVAL_HOLD(E1); break;
#endif
#if AXIS_IS_L64XX(E2)
case 2: L6470_SET_KVAL_HOLD(E2); break;

#if LINEAR_AXES >= XY
case Y_AXIS:
#if AXIS_IS_L64XX(Y)
if (index == 0) L6470_SET_KVAL_HOLD(Y);
#endif
#if AXIS_IS_L64XX(E3)
case 3: L6470_SET_KVAL_HOLD(E3); break;
#if AXIS_IS_L64XX(Y2)
if (index == 1) L6470_SET_KVAL_HOLD(Y2);
#endif
#if AXIS_IS_L64XX(E4)
case 4: L6470_SET_KVAL_HOLD(E4); break;
break;
#endif

#if HAS_Z_AXIS
case Z_AXIS:
#if AXIS_IS_L64XX(Z)
if (index == 0) L6470_SET_KVAL_HOLD(Z);
#endif
#if AXIS_IS_L64XX(E5)
case 5: L6470_SET_KVAL_HOLD(E5); break;
#if AXIS_IS_L64XX(Z2)
if (index == 1) L6470_SET_KVAL_HOLD(Z2);
#endif
#if AXIS_IS_L64XX(E6)
case 6: L6470_SET_KVAL_HOLD(E6); break;
#if AXIS_IS_L64XX(Z3)
if (index == 2) L6470_SET_KVAL_HOLD(Z3);
#endif
#if AXIS_IS_L64XX(E7)
case 7: L6470_SET_KVAL_HOLD(E7); break;
#if AXIS_DRIVER_TYPE_Z4(L6470)
if (index == 3) L6470_SET_KVAL_HOLD(Z4);
#endif
}
} break;
break;
#endif

#if HAS_EXTRUDERS
case E_AXIS: {
const int8_t target_extruder = get_target_extruder_from_command();
if (target_extruder < 0) return;
switch (target_extruder) {
#if AXIS_IS_L64XX(E0)
case 0: L6470_SET_KVAL_HOLD(E0); break;
#endif
#if AXIS_IS_L64XX(E1)
case 1: L6470_SET_KVAL_HOLD(E1); break;
#endif
#if AXIS_IS_L64XX(E2)
case 2: L6470_SET_KVAL_HOLD(E2); break;
#endif
#if AXIS_IS_L64XX(E3)
case 3: L6470_SET_KVAL_HOLD(E3); break;
#endif
#if AXIS_IS_L64XX(E4)
case 4: L6470_SET_KVAL_HOLD(E4); break;
#endif
#if AXIS_IS_L64XX(E5)
case 5: L6470_SET_KVAL_HOLD(E5); break;
#endif
#if AXIS_IS_L64XX(E6)
case 6: L6470_SET_KVAL_HOLD(E6); break;
#endif
#if AXIS_IS_L64XX(E7)
case 7: L6470_SET_KVAL_HOLD(E7); break;
#endif
}
} break;
#endif
}
}

Expand Down
99 changes: 54 additions & 45 deletions Marlin/src/gcode/feature/trinamic/M569.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,57 +60,66 @@ static void set_stealth_status(const bool enable, const int8_t target_extruder)
if (index == 1) TMC_SET_STEALTH(X2);
#endif
break;
case Y_AXIS:
#if AXIS_HAS_STEALTHCHOP(Y)
if (index == 0) TMC_SET_STEALTH(Y);
#endif
#if AXIS_HAS_STEALTHCHOP(Y2)
if (index == 1) TMC_SET_STEALTH(Y2);
#endif
break;
case Z_AXIS:
#if AXIS_HAS_STEALTHCHOP(Z)
if (index == 0) TMC_SET_STEALTH(Z);
#endif
#if AXIS_HAS_STEALTHCHOP(Z2)
if (index == 1) TMC_SET_STEALTH(Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(Z3)
if (index == 2) TMC_SET_STEALTH(Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(Z4)
if (index == 3) TMC_SET_STEALTH(Z4);
#endif
break;
case E_AXIS: {
if (target_extruder < 0) return;
switch (target_extruder) {
#if AXIS_HAS_STEALTHCHOP(E0)
case 0: TMC_SET_STEALTH(E0); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
case 1: TMC_SET_STEALTH(E1); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
case 2: TMC_SET_STEALTH(E2); break;

#if LINEAR_AXES >= XY
case Y_AXIS:
#if AXIS_HAS_STEALTHCHOP(Y)
if (index == 0) TMC_SET_STEALTH(Y);
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
case 3: TMC_SET_STEALTH(E3); break;
#if AXIS_HAS_STEALTHCHOP(Y2)
if (index == 1) TMC_SET_STEALTH(Y2);
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
case 4: TMC_SET_STEALTH(E4); break;
break;
#endif

#if HAS_Z_AXIS
case Z_AXIS:
#if AXIS_HAS_STEALTHCHOP(Z)
if (index == 0) TMC_SET_STEALTH(Z);
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
case 5: TMC_SET_STEALTH(E5); break;
#if AXIS_HAS_STEALTHCHOP(Z2)
if (index == 1) TMC_SET_STEALTH(Z2);
#endif
#if AXIS_HAS_STEALTHCHOP(E6)
case 6: TMC_SET_STEALTH(E6); break;
#if AXIS_HAS_STEALTHCHOP(Z3)
if (index == 2) TMC_SET_STEALTH(Z3);
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
case 7: TMC_SET_STEALTH(E7); break;
#if AXIS_HAS_STEALTHCHOP(Z4)
if (index == 3) TMC_SET_STEALTH(Z4);
#endif
}
} break;
break;
#endif

#if HAS_EXTRUDERS
case E_AXIS: {
if (target_extruder < 0) return;
switch (target_extruder) {
#if AXIS_HAS_STEALTHCHOP(E0)
case 0: TMC_SET_STEALTH(E0); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E1)
case 1: TMC_SET_STEALTH(E1); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E2)
case 2: TMC_SET_STEALTH(E2); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E3)
case 3: TMC_SET_STEALTH(E3); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E4)
case 4: TMC_SET_STEALTH(E4); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E5)
case 5: TMC_SET_STEALTH(E5); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E6)
case 6: TMC_SET_STEALTH(E6); break;
#endif
#if AXIS_HAS_STEALTHCHOP(E7)
case 7: TMC_SET_STEALTH(E7); break;
#endif
}
} break;
#endif
}
}
}
Expand Down
Loading

0 comments on commit d3c56a7

Please sign in to comment.