From fee1de539aa2651cb4c5d6321e5471cd80a80999 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Sat, 12 Aug 2023 22:52:05 +0200 Subject: [PATCH 01/13] 92.9 sets position of rotational axes directly --- Marlin/src/gcode/geometry/G92.cpp | 4 ++-- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/pins/pins_postprocess.h | 36 +++++++++++++++--------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index 626441f4e25c..da19e0d1497d 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -42,7 +42,7 @@ * G92 : Modify Workspace Offsets so the reported position shows the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E]. * G92.1 : Zero XYZ Workspace Offsets (so the reported position = the native position). * - * With POWER_LOSS_RECOVERY: + * With POWER_LOSS_RECOVERY or with AXISn_ROTATES: * G92.9 : Set NATIVE Current Position to the given X [Y [Z [A [B [C [U [V [W ]]]]]]]] [E]. */ void GcodeSuite::G92() { @@ -67,7 +67,7 @@ void GcodeSuite::G92() { break; #endif - #if ENABLED(POWER_LOSS_RECOVERY) + #if ENABLED(POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES case 9: // G92.9 - Set Current Position directly (like Marlin 1.0) LOOP_LOGICAL_AXES(i) { if (parser.seenval(AXIS_CHAR(i))) { diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 33b42e851195..b3286f918758 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3273,7 +3273,7 @@ #endif // Add commands that need sub-codes to this list -#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY) +#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES #define USE_GCODE_SUBCODES 1 #endif diff --git a/Marlin/src/pins/pins_postprocess.h b/Marlin/src/pins/pins_postprocess.h index e5467833e56b..ac0421ea3d7a 100644 --- a/Marlin/src/pins/pins_postprocess.h +++ b/Marlin/src/pins/pins_postprocess.h @@ -503,12 +503,12 @@ #ifdef X_STOP_PIN #if X_HOME_TO_MIN #define X_MIN_PIN X_STOP_PIN - #else + #elif X_HOME_TO_MAX #define X_MAX_PIN X_STOP_PIN #endif #elif X_HOME_TO_MIN #define X_STOP_PIN X_MIN_PIN - #else + #elif X_HOME_TO_MAX #define X_STOP_PIN X_MAX_PIN #endif #if !defined(X2_STOP_PIN) && ENABLED(X_DUAL_ENDSTOPS) && PIN_EXISTS(X_STOP) @@ -520,12 +520,12 @@ #ifdef Y_STOP_PIN #if Y_HOME_TO_MIN #define Y_MIN_PIN Y_STOP_PIN - #else + #elif Y_HOME_TO_MAX #define Y_MAX_PIN Y_STOP_PIN #endif #elif Y_HOME_TO_MIN #define Y_STOP_PIN Y_MIN_PIN - #else + #elif X_HOME_TO_MAX #define Y_STOP_PIN Y_MAX_PIN #endif #if !defined(Y2_STOP_PIN) && ENABLED(Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y_STOP) @@ -537,12 +537,12 @@ #ifdef Z_STOP_PIN #if Z_HOME_TO_MIN #define Z_MIN_PIN Z_STOP_PIN - #else + #elif Z_HOME_TO_MAX #define Z_MAX_PIN Z_STOP_PIN #endif #elif Z_HOME_TO_MIN #define Z_STOP_PIN Z_MIN_PIN - #else + #elif Z_HOME_TO_MAX #define Z_STOP_PIN Z_MAX_PIN #endif #if ENABLED(Z_MULTI_ENDSTOPS) && PIN_EXISTS(Z_STOP) @@ -562,12 +562,12 @@ #ifdef I_STOP_PIN #if I_HOME_TO_MIN #define I_MIN_PIN I_STOP_PIN - #else + #elif I_HOME_TO_MAX #define I_MAX_PIN I_STOP_PIN #endif #elif I_HOME_TO_MIN #define I_STOP_PIN I_MIN_PIN - #else + #elif I_HOME_TO_MAX #define I_STOP_PIN I_MAX_PIN #endif #endif @@ -576,12 +576,12 @@ #ifdef J_STOP_PIN #if J_HOME_TO_MIN #define J_MIN_PIN J_STOP_PIN - #else + #elif J_HOME_TO_MAX #define J_MAX_PIN J_STOP_PIN #endif #elif J_HOME_TO_MIN #define J_STOP_PIN J_MIN_PIN - #else + #elif J_HOME_TO_MAX #define J_STOP_PIN J_MAX_PIN #endif #endif @@ -590,12 +590,12 @@ #ifdef K_STOP_PIN #if K_HOME_TO_MIN #define K_MIN_PIN K_STOP_PIN - #else + #elif K_HOME_TO_MAX #define K_MAX_PIN K_STOP_PIN #endif #elif K_HOME_TO_MIN #define K_STOP_PIN K_MIN_PIN - #else + #elif K_HOME_TO_MAX #define K_STOP_PIN K_MAX_PIN #endif #endif @@ -604,12 +604,12 @@ #ifdef U_STOP_PIN #if U_HOME_TO_MIN #define U_MIN_PIN U_STOP_PIN - #else + #elif U_HOME_TO_MAX #define U_MAX_PIN U_STOP_PIN #endif #elif U_HOME_TO_MIN #define U_STOP_PIN U_MIN_PIN - #else + #elif U_HOME_TO_MAX #define U_STOP_PIN U_MAX_PIN #endif #endif @@ -618,12 +618,12 @@ #ifdef V_STOP_PIN #if V_HOME_TO_MIN #define V_MIN_PIN V_STOP_PIN - #else + #elif V_HOME_TO_MAX #define V_MAX_PIN V_STOP_PIN #endif #elif V_HOME_TO_MIN #define V_STOP_PIN V_MIN_PIN - #else + #elif V_HOME_TO_MAX #define V_STOP_PIN V_MAX_PIN #endif #endif @@ -632,12 +632,12 @@ #ifdef W_STOP_PIN #if W_HOME_TO_MIN #define W_MIN_PIN W_STOP_PIN - #else + #elif W_HOME_TO_MAX #define W_MAX_PIN W_STOP_PIN #endif #elif W_HOME_TO_MIN #define W_STOP_PIN W_MIN_PIN - #else + #elif W_HOME_TO_MAX #define W_STOP_PIN W_MAX_PIN #endif #endif From 5ee1312135e3d64b2ed88b87c6497495905e3922 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Wed, 21 Jun 2023 05:03:18 +0200 Subject: [PATCH 02/13] fix compilation with rotational axes --- Marlin/src/inc/Conditionals_LCD.h | 4 ++++ Marlin/src/inc/Conditionals_post.h | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b069e2d2b173..663a1a0e32db 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1060,6 +1060,10 @@ #define ROTATIONAL_AXES 0 #endif +#if ROTATIONAL_AXES >= 1 + #define HAS_ROTATIONAL_AXES 1 +#endif + /** * Number of Secondary Linear Axes (e.g., UVW) * All secondary axes for which AXIS*_ROTATES is not defined. diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index b3286f918758..5dc5ac894d4b 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -101,10 +101,6 @@ #define AXIS9_NAME 'W' #endif -#if ANY(AXIS4_ROTATES, AXIS5_ROTATES, AXIS6_ROTATES, AXIS7_ROTATES, AXIS8_ROTATES, AXIS9_ROTATES) - #define HAS_ROTATIONAL_AXES 1 -#endif - #if HAS_X_AXIS #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS)) #endif From 7f4fc9a541d11088a3f27c01813110de313fe86c Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Wed, 21 Jun 2023 06:49:29 +0200 Subject: [PATCH 03/13] LCD move rotational axes in degrees --- Marlin/src/gcode/parser.h | 23 +++++++++++++++-------- Marlin/src/lcd/language/language_de.h | 4 ++++ Marlin/src/lcd/language/language_en.h | 4 ++++ Marlin/src/lcd/marlinui.cpp | 15 +++++++++++++-- Marlin/src/lcd/menu/menu_motion.cpp | 12 +++++++++--- 5 files changed, 45 insertions(+), 13 deletions(-) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index c05d6f32c521..7392d36df6a9 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -288,6 +288,18 @@ class GCodeParser { // Bool is true with no value or non-zero static bool value_bool() { return !has_value() || !!value_byte(); } + #if HAS_ROTATIONAL_AXES + static constexpr bool axis_is_rotational(const AxisEnum axis) { + return (false + || TERN0(AXIS4_ROTATES, axis == I_AXIS) + || TERN0(AXIS5_ROTATES, axis == J_AXIS) + || TERN0(AXIS6_ROTATES, axis == K_AXIS) + || TERN0(AXIS7_ROTATES, axis == U_AXIS) + || TERN0(AXIS8_ROTATES, axis == V_AXIS) + || TERN0(AXIS9_ROTATES, axis == W_AXIS) + ); + } + #endif // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) @@ -307,14 +319,9 @@ class GCodeParser { } static float axis_unit_factor(const AxisEnum axis) { - if (false - || TERN0(AXIS4_ROTATES, axis == I_AXIS) - || TERN0(AXIS5_ROTATES, axis == J_AXIS) - || TERN0(AXIS6_ROTATES, axis == K_AXIS) - || TERN0(AXIS7_ROTATES, axis == U_AXIS) - || TERN0(AXIS8_ROTATES, axis == V_AXIS) - || TERN0(AXIS9_ROTATES, axis == W_AXIS) - ) return 1.0f; + #if HAS_ROTATIONAL_AXES + if (axis_is_rotational(axis)) return 1.0f; + #endif #if HAS_EXTRUDERS if (axis >= E_AXIS && volumetric_enabled) return volumetric_unit_factor; #endif diff --git a/Marlin/src/lcd/language/language_de.h b/Marlin/src/lcd/language/language_de.h index 30e2521d2302..80ea8521eac4 100644 --- a/Marlin/src/lcd/language/language_de.h +++ b/Marlin/src/lcd/language/language_de.h @@ -298,6 +298,10 @@ namespace LanguageNarrow_de { LSTR MSG_MOVE_001IN = _UxGT("0.010 in"); LSTR MSG_MOVE_01IN = _UxGT("0.100 in"); LSTR MSG_MOVE_1IN = _UxGT("1.000 in"); + LSTR MSG_MOVE_001DEG = _UxGT(" 0,01 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_01DEG = _UxGT(" 0,10 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_1DEG = _UxGT(" 1,00 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_10DEG = _UxGT("10,00 ") LCD_STR_DEGREE; LSTR MSG_SPEED = _UxGT("Geschw."); LSTR MSG_MESH_Z_OFFSET = _UxGT("Bett Z"); LSTR MSG_NOZZLE = _UxGT("Düse"); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 9fdc33e5f202..4b5c3d837773 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -327,6 +327,10 @@ namespace LanguageNarrow_en { LSTR MSG_MOVE_01IN = _UxGT("Move 0.1in"); LSTR MSG_MOVE_05IN = _UxGT("Move 0.5in"); LSTR MSG_MOVE_1IN = _UxGT("Move 1.0in"); + LSTR MSG_MOVE_001DEG = _UxGT("Move 0.01 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_01DEG = _UxGT("Move 0.1 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_1DEG = _UxGT("Move 1 ") LCD_STR_DEGREE; + LSTR MSG_MOVE_10DEG = _UxGT("Move 10 ") LCD_STR_DEGREE; LSTR MSG_LIVE_MOVE = _UxGT("Live Move"); LSTR MSG_SPEED = _UxGT("Speed"); LSTR MSG_MESH_Z_OFFSET = _UxGT("Bed Z"); diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 69a8e2336365..df32ec2d7986 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -61,6 +61,10 @@ MarlinUI ui; #include "../module/printcounter.h" #endif +#if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES + #include "../gcode/parser.h" +#endif + #if LCD_HAS_WAIT_FOR_MOVE bool MarlinUI::wait_for_move; // = false #endif @@ -816,6 +820,13 @@ void MarlinUI::init() { if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; + + // For a rotational axis convert the "inch" feedrate to "mm" before applying it + // TODO: Assert that all units on a rotational axis are expressed in degrees, not by distance + feedRate_t fr = fr_mm_s; + #if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES + if (parser.axis_is_rotational(axis) && parser.using_inch_units()) fr = IN_TO_MM(fr); + #endif #if IS_KINEMATIC @@ -843,13 +854,13 @@ void MarlinUI::init() { // previous invocation is being blocked. Modifications to offset shouldn't be made while // processing is true or the planner will get out of sync. processing = true; - prepare_internal_move_to_destination(fr_mm_s); // will set current_position from destination + prepare_internal_move_to_destination(fr); // will set current_position from destination processing = false; #else // For Cartesian / Core motion simply move to the current_position - planner.buffer_line(current_position, fr_mm_s, + planner.buffer_line(current_position, fr, TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder ); diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index ae6e87af6585..787b3145d643 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -83,8 +83,8 @@ void lcd_move_axis(const AxisEnum axis) { if (ui.should_draw()) { MenuEditItemBase::itemIndex = axis; const float pos = ui.manual_move.axis_value(axis); - if (parser.using_inch_units()) { - const float imp_pos = LINEAR_UNIT(pos); + if (parser.using_inch_units && TERN1(HAS_ROTATIONAL_AXES, !parser.axis_is_rotational(axis))) { + const float imp_pos = parser.per_axis_value(axis, pos); MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ftostr63(imp_pos)); } else @@ -156,7 +156,13 @@ void _menu_move_distance(const AxisEnum axis, const screenFunc_t func, const int } BACK_ITEM(MSG_MOVE_AXIS); - if (parser.using_inch_units()) { + if (TERN0(HAS_ROTATIONAL_AXES, parser.axis_is_rotational(axis))) { + SUBMENU(MSG_MOVE_10DEG, []{ _goto_manual_move(10); }); + SUBMENU(MSG_MOVE_1DEG, []{ _goto_manual_move(1.000f); }); + SUBMENU(MSG_MOVE_01DEG, []{ _goto_manual_move(0.100f); }); + SUBMENU(MSG_MOVE_001DEG, []{ _goto_manual_move(0.010f); }); + } + else if (parser.using_inch_units()) { if (HAS_LARGE_MOVES) { SUBMENU(MSG_MOVE_1IN, []{ _goto_manual_move(IN_TO_MM(1.000f)); }); SUBMENU(MSG_MOVE_05IN, []{ _goto_manual_move(IN_TO_MM(0.500f)); }); From 810187a6185c49210b6f59e523a1ea01e30e6dc3 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Thu, 17 Aug 2023 01:02:46 +0200 Subject: [PATCH 04/13] handle e-only moves like moves with linear axes --- Marlin/src/lcd/marlinui.cpp | 7 +++++-- Marlin/src/module/motion.cpp | 7 +++++-- Marlin/src/module/planner.cpp | 4 ++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index df32ec2d7986..22fdd9c53c75 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -821,8 +821,11 @@ void MarlinUI::init() { const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; - // For a rotational axis convert the "inch" feedrate to "mm" before applying it - // TODO: Assert that all units on a rotational axis are expressed in degrees, not by distance + /** + * For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G1 G-code + * implementation. For moves involving only rotational axes, the planner will convert back to the feedrate# + * in degrees per time unit. + */ feedRate_t fr = fr_mm_s; #if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES if (parser.axis_is_rotational(axis) && parser.using_inch_units()) fr = IN_TO_MM(fr); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 272b16c9ac0f..35f5de8b6e97 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1159,10 +1159,13 @@ float get_move_distance(const xyze_pos_t &diff OPTARG(HAS_ROTATIONAL_AXES, bool #if HAS_ROTATIONAL_AXES if (UNEAR_ZERO(distance_sqr)) { - // Move involves only rotational axes. Calculate angular distance in accordance with LinuxCNC - is_cartesian_move = false; + // Move involves no linear axes. Calculate angular distance in accordance with LinuxCNC distance_sqr = ROTATIONAL_AXIS_GANG(sq(diff.i), + sq(diff.j), + sq(diff.k), + sq(diff.u), + sq(diff.v), + sq(diff.w)); } + if (!UNEAR_ZERO(distance_sqr)) { + //Move involves rotational axes, not just the extruder + is_cartesian_move = false; + } #endif #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 6b645fa1337e..bb2a4ef10c84 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2300,6 +2300,10 @@ bool Planner::_populate_block( // Example 2: At 120°/s a 60° move involving only rotational axes takes 0.5s. So this will give 2.0. float inverse_secs = inverse_millimeters * ( #if ALL(HAS_ROTATIONAL_AXES, INCH_MODE_SUPPORT) + /** + * Work around for the premature feedrate conversion from + * inches/s to mm/s by the get_distance_from_command function. + */ cartesian_move ? fr_mm_s : LINEAR_UNIT(fr_mm_s) #else fr_mm_s From f4dc67ddb2d2362e98d7c4baf4449f46c124e634 Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Mon, 16 Oct 2023 02:25:13 +0200 Subject: [PATCH 05/13] remove conflicting _U --- Marlin/src/core/types.h | 12 ++++++------ Marlin/src/lcd/marlinui.cpp | 6 +++--- Marlin/src/module/motion.cpp | 3 ++- Marlin/src/module/planner.cpp | 30 +++++++++++++++--------------- Marlin/src/module/stepper.cpp | 18 +++++++++--------- 5 files changed, 35 insertions(+), 34 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 679cb2ce13e7..919690064b19 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -937,7 +937,7 @@ class AxisBits { typedef bits_t(NUM_AXIS_ENUMS) el; union { el bits; - // x, y, z ... e0, e1, e2 ... hx, hy, hz + // Axes x, y, z ... e0, e1, e2 ... hx, hy, hz struct { #if NUM_AXES bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); @@ -949,7 +949,7 @@ class AxisBits { bool hx:1, hy:1, hz:1; #endif }; - // X, Y, Z ... E0, E1, E2 ... HX, HY, HZ + // Axes X, Y, Z ... E0, E1, E2 ... HX, HY, HZ struct { #if NUM_AXES bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); @@ -961,9 +961,9 @@ class AxisBits { bool HX:1, HY:1, HZ:1; #endif }; - // a, b, c, e ... ha, hb, hc + // Joints ja, jb, jc, e ... ha, hb, hc struct { - bool LOGICAL_AXIS_LIST(e:1, a:1, b:1, c:1, _i:1, _j:1, _k:1, _u:1, _v:1, _w:1); + bool LOGICAL_AXIS_LIST(e:1, ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _e##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) @@ -973,9 +973,9 @@ class AxisBits { bool ha:1, hb:1, hc:1; #endif }; - // A, B, C, E ... HA, HB, HC + // Joints JA, JB, JC, E ... HA, HB, HC struct { - bool LOGICAL_AXIS_LIST(E:1, A:1, B:1, C:1, _I:1, _J:1, _K:1, _U:1, _V:1, _W:1); + bool LOGICAL_AXIS_LIST(E:1, JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _E##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index 22fdd9c53c75..74ff22568814 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -822,9 +822,9 @@ void MarlinUI::init() { const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; /** - * For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G1 G-code - * implementation. For moves involving only rotational axes, the planner will convert back to the feedrate# - * in degrees per time unit. + * For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G-code G1 + * (see get_distance_from_command function). For moves involving only rotational axes, the planner will + * convert back to the feedrate in degrees per time unit. */ feedRate_t fr = fr_mm_s; #if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 35f5de8b6e97..91b1b4a29e77 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1326,8 +1326,9 @@ float get_move_distance(const xyze_pos_t &diff OPTARG(HAS_ROTATIONAL_AXES, bool float cartesian_mm = get_move_distance(diff OPTARG(HAS_ROTATIONAL_AXES, cartes_move)); // If the move is very short, check the E move distance - // No E move either? Game over. TERN_(HAS_EXTRUDERS, if (UNEAR_ZERO(cartesian_mm)) cartesian_mm = ABS(diff.e)); + + // No E move either? Game over. if (UNEAR_ZERO(cartesian_mm)) return; // The length divided by the segment size diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index bb2a4ef10c84..a680555c6d49 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1968,27 +1968,27 @@ bool Planner::_populate_block( #endif #if IS_CORE #if CORE_IS_XY - dm.a = (dist.a + dist.b > 0); // Motor A direction - dm.b = (CORESIGN(dist.a - dist.b) > 0); // Motor B direction + dm.ja = (dist.a + dist.b > 0); // Motor A direction + dm.jb = (CORESIGN(dist.a - dist.b) > 0); // Motor B direction #elif CORE_IS_XZ dm.hx = (dist.a > 0); // Save the toolhead's true direction in X dm.y = (dist.b > 0); dm.hz = (dist.c > 0); // ...and Z - dm.a = (dist.a + dist.c > 0); // Motor A direction - dm.c = (CORESIGN(dist.a - dist.c) > 0); // Motor C direction + dm.ja = (dist.a + dist.c > 0); // Motor A direction + dm.jc = (CORESIGN(dist.a - dist.c) > 0); // Motor C direction #elif CORE_IS_YZ dm.x = (dist.a > 0); dm.hy = (dist.b > 0); // Save the toolhead's true direction in Y dm.hz = (dist.c > 0); // ...and Z - dm.b = (dist.b + dist.c > 0); // Motor B direction - dm.c = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction + dm.jb = (dist.b + dist.c > 0); // Motor B direction + dm.jc = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction #endif #elif ENABLED(MARKFORGED_XY) - dm.a = (dist.a + dist.b > 0); // Motor A direction - dm.b = (dist.b > 0); // Motor B direction + dm.ja = (dist.a + dist.b > 0); // Motor A direction + dm.jb = (dist.b > 0); // Motor B direction #elif ENABLED(MARKFORGED_YX) - dm.a = (dist.a > 0); // Motor A direction - dm.b = (dist.b + dist.a > 0); // Motor B direction + dm.ja = (dist.a > 0); // Motor A direction + dm.jb = (dist.b + dist.a > 0); // Motor B direction #else XYZ_CODE( dm.x = (dist.a > 0), @@ -2069,11 +2069,11 @@ bool Planner::_populate_block( /** * This part of the code calculates the total length of the movement. - * For cartesian bots, the X_AXIS is the real X movement and same for Y_AXIS. - * But for corexy bots, that is not true. The "X_AXIS" and "Y_AXIS" motors (that should be named to A_AXIS - * and B_AXIS) cannot be used for X and Y length, because A=X+Y and B=X-Y. - * So we need to create other 2 "AXIS", named X_HEAD and Y_HEAD, meaning the real displacement of the Head. - * Having the real displacement of the head, we can calculate the total movement length and apply the desired speed. + * For cartesian bots, the distance along the X axis equals the X_AXIS joint displacement and same holds true for Y_AXIS. + * But for geometries like CORE_XY that is not true. For these machines we need to create 2 additional variables, named X_HEAD and Y_HEAD, to store the displacent of the head along the X and Y axes in a cartesian coordinate system. + * The displacement of the head along the axes of the cartesian coordinate system has to be calculated from "X_AXIS" and "Y_AXIS" (should be renamed to A_JOINT and B_JOINT) + * displacements in joints space using forward kinematics (A=X+Y and B=X-Y in the case of CORE_XY). + * Next we can calculate the total movement length and apply the desired speed. */ struct DistanceMM : abce_float_t { #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 9bafe7443db1..ce482c4746b4 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2616,15 +2616,15 @@ hal_timer_t Stepper::block_phase_isr() { AxisBits didmove; NUM_AXIS_CODE( - if (X_MOVE_TEST) didmove.a = true, - if (Y_MOVE_TEST) didmove.b = true, - if (Z_MOVE_TEST) didmove.c = true, - if (current_block->steps.i) didmove.i = true, - if (current_block->steps.j) didmove.j = true, - if (current_block->steps.k) didmove.k = true, - if (current_block->steps.u) didmove.u = true, - if (current_block->steps.v) didmove.v = true, - if (current_block->steps.w) didmove.w = true + if (X_MOVE_TEST) didmove.ja = true, + if (Y_MOVE_TEST) didmove.jb = true, + if (Z_MOVE_TEST) didmove.jc = true, + if (current_block->steps.i) didmove.ji = true, + if (current_block->steps.j) didmove.jj = true, + if (current_block->steps.k) didmove.jk = true, + if (current_block->steps.u) didmove.ju = true, + if (current_block->steps.v) didmove.jv = true, + if (current_block->steps.w) didmove.jw = true ); //if (current_block->steps.e) didmove.e = true; //if (current_block->steps.a) didmove.x = true; From 8803c5b5e46ec359dc0974a6242a8e10ec6e95af Mon Sep 17 00:00:00 2001 From: DerAndere <26200979+DerAndere1@users.noreply.github.com> Date: Mon, 16 Oct 2023 11:30:03 +0200 Subject: [PATCH 06/13] distinguish between axes and joints --- Marlin/src/module/planner.cpp | 42 +++++++++++++++++------------------ Marlin/src/module/stepper.cpp | 30 ++++++++++++------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index a680555c6d49..c4f6e9e57380 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1998,8 +1998,8 @@ bool Planner::_populate_block( #endif SECONDARY_AXIS_CODE( - dm.i = (dist.i > 0), dm.j = (dist.j > 0), dm.k = (dist.k > 0), - dm.u = (dist.u > 0), dm.v = (dist.v > 0), dm.w = (dist.w > 0) + dm.i = (dist._i > 0), dm.j = (dist._j > 0), dm.k = (dist._k > 0), + dm.u = (dist._u > 0), dm.v = (dist._v > 0), dm.w = (dist._w > 0) ); #if HAS_EXTRUDERS @@ -2064,7 +2064,7 @@ bool Planner::_populate_block( #else // default non-h-bot planning ABS(dist.a), ABS(dist.b), ABS(dist.c) #endif - , ABS(dist.i), ABS(dist.j), ABS(dist.k), ABS(dist.u), ABS(dist.v), ABS(dist.w) + , ABS(dist._i), ABS(dist._j), ABS(dist._k), ABS(dist._u), ABS(dist._v), ABS(dist._w) )); /** @@ -2118,8 +2118,8 @@ bool Planner::_populate_block( #endif SECONDARY_AXIS_CODE( - dist_mm.i = dist.i * mm_per_step[I_AXIS], dist_mm.j = dist.j * mm_per_step[J_AXIS], dist_mm.k = dist.k * mm_per_step[K_AXIS], - dist_mm.u = dist.u * mm_per_step[U_AXIS], dist_mm.v = dist.v * mm_per_step[V_AXIS], dist_mm.w = dist.w * mm_per_step[W_AXIS] + dist_mm._i = dist._i * mm_per_step[I_AXIS], dist_mm._j = dist._j * mm_per_step[J_AXIS], dist_mm._k = dist._k * mm_per_step[K_AXIS], + dist_mm._u = dist._u * mm_per_step[U_AXIS], dist_mm._v = dist._v * mm_per_step[V_AXIS], dist_mm._w = dist._w * mm_per_step[W_AXIS] ); TERN_(HAS_EXTRUDERS, dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]); @@ -2132,8 +2132,8 @@ bool Planner::_populate_block( if (true NUM_AXIS_GANG( && block->steps.a < MIN_STEPS_PER_SEGMENT, && block->steps.b < MIN_STEPS_PER_SEGMENT, && block->steps.c < MIN_STEPS_PER_SEGMENT, - && block->steps.i < MIN_STEPS_PER_SEGMENT, && block->steps.j < MIN_STEPS_PER_SEGMENT, && block->steps.k < MIN_STEPS_PER_SEGMENT, - && block->steps.u < MIN_STEPS_PER_SEGMENT, && block->steps.v < MIN_STEPS_PER_SEGMENT, && block->steps.w < MIN_STEPS_PER_SEGMENT + && block->steps._i < MIN_STEPS_PER_SEGMENT, && block->steps._j < MIN_STEPS_PER_SEGMENT, && block->steps._k < MIN_STEPS_PER_SEGMENT, + && block->steps._u < MIN_STEPS_PER_SEGMENT, && block->steps._v < MIN_STEPS_PER_SEGMENT, && block->steps._w < MIN_STEPS_PER_SEGMENT ) ) { block->millimeters = TERN0(HAS_EXTRUDERS, ABS(dist_mm.e)); @@ -2178,8 +2178,8 @@ bool Planner::_populate_block( #if NUM_AXES _MAX(LOGICAL_AXIS_LIST(esteps, block->steps.a, block->steps.b, block->steps.c, - block->steps.i, block->steps.j, block->steps.k, - block->steps.u, block->steps.v, block->steps.w + block->steps._i, block->steps._j, block->steps._k, + block->steps._u, block->steps._v, block->steps._w )) #elif HAS_EXTRUDERS esteps @@ -2976,12 +2976,12 @@ bool Planner::buffer_segment(const abce_pos_t &abce int32_t(LROUND(abce.a * settings.axis_steps_per_mm[A_AXIS])), int32_t(LROUND(abce.b * settings.axis_steps_per_mm[B_AXIS])), int32_t(LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS])), - int32_t(LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS])), - int32_t(LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS])), - int32_t(LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS])), - int32_t(LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS])), - int32_t(LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS])), - int32_t(LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS])) + int32_t(LROUND(abce._i * settings.axis_steps_per_mm[I_AXIS])), + int32_t(LROUND(abce._j * settings.axis_steps_per_mm[J_AXIS])), + int32_t(LROUND(abce._k * settings.axis_steps_per_mm[K_AXIS])), + int32_t(LROUND(abce._u * settings.axis_steps_per_mm[U_AXIS])), + int32_t(LROUND(abce._v * settings.axis_steps_per_mm[V_AXIS])), + int32_t(LROUND(abce._w * settings.axis_steps_per_mm[W_AXIS])) ) }; @@ -3248,12 +3248,12 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.a * settings.axis_steps_per_mm[A_AXIS]), LROUND(abce.b * settings.axis_steps_per_mm[B_AXIS]), LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS]), - LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS]), - LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS]), - LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]), - LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS]), - LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS]), - LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS]) + LROUND(abce._i * settings.axis_steps_per_mm[I_AXIS]), + LROUND(abce._j * settings.axis_steps_per_mm[J_AXIS]), + LROUND(abce._k * settings.axis_steps_per_mm[K_AXIS]), + LROUND(abce._u * settings.axis_steps_per_mm[U_AXIS]), + LROUND(abce._v * settings.axis_steps_per_mm[V_AXIS]), + LROUND(abce._w * settings.axis_steps_per_mm[W_AXIS]) ) ); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index ce482c4746b4..97379d7a4dc6 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2616,15 +2616,15 @@ hal_timer_t Stepper::block_phase_isr() { AxisBits didmove; NUM_AXIS_CODE( - if (X_MOVE_TEST) didmove.ja = true, - if (Y_MOVE_TEST) didmove.jb = true, - if (Z_MOVE_TEST) didmove.jc = true, - if (current_block->steps.i) didmove.ji = true, - if (current_block->steps.j) didmove.jj = true, - if (current_block->steps.k) didmove.jk = true, - if (current_block->steps.u) didmove.ju = true, - if (current_block->steps.v) didmove.jv = true, - if (current_block->steps.w) didmove.jw = true + if (X_MOVE_TEST) didmove.ja = true, + if (Y_MOVE_TEST) didmove.jb = true, + if (Z_MOVE_TEST) didmove.jc = true, + if (!!current_block->steps._i) didmove.ji = true, + if (!!current_block->steps._j) didmove.jj = true, + if (!!current_block->steps._k) didmove.jk = true, + if (!!current_block->steps._u) didmove.ju = true, + if (!!current_block->steps._v) didmove.jv = true, + if (!!current_block->steps._w) didmove.jw = true ); //if (current_block->steps.e) didmove.e = true; //if (current_block->steps.a) didmove.x = true; @@ -3244,12 +3244,12 @@ void Stepper::_set_position(const abce_long_t &spos) { count_position.set(spos.a, spos.b - spos.a, spos.c); #endif SECONDARY_AXIS_CODE( - count_position.i = spos.i, - count_position.j = spos.j, - count_position.k = spos.k, - count_position.u = spos.u, - count_position.v = spos.v, - count_position.w = spos.w + count_position.i = spos._i, + count_position.j = spos._j, + count_position.k = spos._k, + count_position.u = spos._u, + count_position.v = spos._v, + count_position.w = spos._w ); TERN_(HAS_EXTRUDERS, count_position.e = spos.e); #else From c53fd599d1dee95b366250e60a2db59d981b6ec0 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 14:37:33 -0600 Subject: [PATCH 07/13] merge followup --- Marlin/src/inc/Conditionals_LCD.h | 2 +- Marlin/src/inc/Conditionals_adv.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 1af10c262eff..bff742a5bcb7 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -507,7 +507,7 @@ #define ROTATIONAL_AXES 0 #endif -#if ROTATIONAL_AXES >= 1 +#if ROTATIONAL_AXES #define HAS_ROTATIONAL_AXES 1 #endif diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 9f182a108d8f..379600d91574 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -1351,6 +1351,11 @@ #undef MANUAL_MOVE_DISTANCE_IN #endif +// Clean up if no rotational axes exist +#if !HAS_ROTATIONAL_AXES + #undef MANUAL_MOVE_DISTANCE_DEG +#endif + // Power-Loss Recovery #if ENABLED(POWER_LOSS_RECOVERY) && defined(PLR_BED_THRESHOLD) #define HAS_PLR_BED_THRESHOLD 1 From 4b1efd7683ae78c89168100614a5c6279a96412d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:21:15 -0600 Subject: [PATCH 08/13] adjust style --- Marlin/src/core/types.h | 36 ++++++++---- Marlin/src/gcode/geometry/G92.cpp | 2 +- Marlin/src/gcode/parser.h | 39 ++++++------- Marlin/src/inc/Conditionals_post.h | 2 +- Marlin/src/lcd/marlinui.cpp | 91 +++++++++++++---------------- Marlin/src/lcd/menu/menu_motion.cpp | 2 +- Marlin/src/module/motion.cpp | 2 +- Marlin/src/module/planner.cpp | 4 +- Marlin/src/module/stepper.cpp | 10 +--- 9 files changed, 95 insertions(+), 93 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 574a15e042ef..fef143b2e5f4 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -939,9 +939,7 @@ class AxisBits { el bits; // Axes x, y, z ... e0, e1, e2 ... hx, hy, hz struct { - #if NUM_AXES - bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); - #endif + bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); #define _EN_ITEM(N) bool e##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM @@ -951,9 +949,7 @@ class AxisBits { }; // Axes X, Y, Z ... E0, E1, E2 ... HX, HY, HZ struct { - #if NUM_AXES - bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); - #endif + bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); #define _EN_ITEM(N) bool E##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM @@ -961,9 +957,9 @@ class AxisBits { bool HX:1, HY:1, HZ:1; #endif }; - // Joints ja, jb, jc, e ... ha, hb, hc + // a, b, c, e ... ha, hb, hc struct { - bool LOGICAL_AXIS_LIST(e:1, ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); + bool LOGICAL_AXIS_LIST(e:1, a:1, b:1, c:1, _i:1, _j:1, _k:1, _u:1, _v:1, _w:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _e##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) @@ -973,9 +969,9 @@ class AxisBits { bool ha:1, hb:1, hc:1; #endif }; - // Joints JA, JB, JC, E ... HA, HB, HC + // A, B, C, E ... HA, HB, HC struct { - bool LOGICAL_AXIS_LIST(E:1, JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); + bool LOGICAL_AXIS_LIST(E:1, A:1, B:1, C:1, _I:1, _J:1, _K:1, _U:1, _V:1, _W:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _E##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) @@ -985,6 +981,26 @@ class AxisBits { bool HA:1, HB:1, HC:1; #endif }; + // Joints ja, jb, jc ... je0, je1, je2 ... jha, jhb, jhc + struct { + bool NUM_AXIS_LIST(ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); + #define _EN_ITEM(N) bool je##N:1; + REPEAT(EXTRUDERS,_EN_ITEM) + #undef _EN_ITEM + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) + bool jha:1, jhb:1, jhc:1; + #endif + }; + // Joints JA, JB, JC ... JE0, JE1, JE2 ... JHA, JHB, JHC + struct { + bool NUM_AXIS_LIST(JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); + #define _EN_ITEM(N) bool JE##N:1; + REPEAT(EXTRUDERS,_EN_ITEM) + #undef _EN_ITEM + #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) + bool JHA:1, JHB:1, JHC:1; + #endif + }; }; AxisBits() { reset(); } diff --git a/Marlin/src/gcode/geometry/G92.cpp b/Marlin/src/gcode/geometry/G92.cpp index da19e0d1497d..cfdff51eba14 100644 --- a/Marlin/src/gcode/geometry/G92.cpp +++ b/Marlin/src/gcode/geometry/G92.cpp @@ -67,7 +67,7 @@ void GcodeSuite::G92() { break; #endif - #if ENABLED(POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES + #if ANY(POWER_LOSS_RECOVERY, HAS_ROTATIONAL_AXES) case 9: // G92.9 - Set Current Position directly (like Marlin 1.0) LOOP_LOGICAL_AXES(i) { if (parser.seenval(AXIS_CHAR(i))) { diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index f9e7bdb8ff53..94c5b284e06f 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -288,18 +288,17 @@ class GCodeParser { // Bool is true with no value or non-zero static bool value_bool() { return !has_value() || !!value_byte(); } - #if HAS_ROTATIONAL_AXES - static constexpr bool axis_is_rotational(const AxisEnum axis) { - return (false - || TERN0(AXIS4_ROTATES, axis == I_AXIS) - || TERN0(AXIS5_ROTATES, axis == J_AXIS) - || TERN0(AXIS6_ROTATES, axis == K_AXIS) - || TERN0(AXIS7_ROTATES, axis == U_AXIS) - || TERN0(AXIS8_ROTATES, axis == V_AXIS) - || TERN0(AXIS9_ROTATES, axis == W_AXIS) - ); - } - #endif + static constexpr bool axis_is_rotational(const AxisEnum axis) { + return (false + || TERN0(AXIS4_ROTATES, axis == I_AXIS) + || TERN0(AXIS5_ROTATES, axis == J_AXIS) + || TERN0(AXIS6_ROTATES, axis == K_AXIS) + || TERN0(AXIS7_ROTATES, axis == U_AXIS) + || TERN0(AXIS8_ROTATES, axis == V_AXIS) + || TERN0(AXIS9_ROTATES, axis == W_AXIS) + ); + } + // Units modes: Inches, Fahrenheit, Kelvin #if ENABLED(INCH_MODE_SUPPORT) @@ -319,9 +318,7 @@ class GCodeParser { } static float axis_unit_factor(const AxisEnum axis) { - #if HAS_ROTATIONAL_AXES - if (axis_is_rotational(axis)) return 1.0f; - #endif + if (axis_is_rotational(axis)) return 1.0f; #if HAS_EXTRUDERS if (axis >= E_AXIS && volumetric_enabled) return volumetric_unit_factor; #endif @@ -334,12 +331,12 @@ class GCodeParser { #else - static float mm_to_linear_unit(const_float_t mm) { return mm; } - static float mm_to_volumetric_unit(const_float_t mm) { return mm; } + static constexpr float mm_to_linear_unit(const_float_t mm) { return mm; } + static constexpr float mm_to_volumetric_unit(const_float_t mm) { return mm; } - static float linear_value_to_mm(const_float_t v) { return v; } - static float axis_value_to_mm(const AxisEnum, const float v) { return v; } - static float per_axis_value(const AxisEnum, const float v) { return v; } + static constexpr float linear_value_to_mm(const_float_t v) { return v; } + static constexpr float axis_value_to_mm(const AxisEnum, const float v) { return v; } + static constexpr float per_axis_value(const AxisEnum, const float v) { return v; } #endif @@ -409,7 +406,7 @@ class GCodeParser { #else // !TEMPERATURE_UNITS_SUPPORT - static float to_temp_units(int16_t c) { return (float)c; } + static constexpr float to_temp_units(int16_t c) { return (float)c; } static celsius_t value_celsius() { return value_int(); } static celsius_t value_celsius_diff() { return value_int(); } diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index ca645882a7a3..1324784e6774 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -3276,7 +3276,7 @@ #endif // Add commands that need sub-codes to this list -#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY) || HAS_ROTATIONAL_AXES +#if ANY(G38_PROBE_TARGET, CNC_COORDINATE_SYSTEMS, POWER_LOSS_RECOVERY, HAS_ROTATIONAL_AXES) #define USE_GCODE_SUBCODES 1 #endif diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index e94c7c55eb8c..1566b6928b4b 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -23,6 +23,7 @@ #include "../inc/MarlinConfig.h" #include "../MarlinCore.h" // for printingIsPaused +#include "../gcode/parser.h" // for axis_is_rotational, using_inch_units #if LED_POWEROFF_TIMEOUT > 0 || ALL(HAS_WIRED_LCD, PRINTER_EVENT_LEDS) || (HAS_BACKLIGHT_TIMEOUT && defined(NEOPIXEL_BKGD_INDEX_FIRST)) #include "../feature/leds/leds.h" @@ -61,10 +62,6 @@ MarlinUI ui; #include "../module/printcounter.h" #endif -#if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES - #include "../gcode/parser.h" -#endif - #if LCD_HAS_WAIT_FOR_MOVE bool MarlinUI::wait_for_move; // = false #endif @@ -851,62 +848,58 @@ void MarlinUI::init() { if (processing) return; // Prevent re-entry from idle() calls // Add a manual move to the queue? - if (axis != NO_AXIS_ENUM && ELAPSED(millis(), start_time) && !planner.is_full()) { - - const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; - - /** - * For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G-code G1 - * (see get_distance_from_command function). For moves involving only rotational axes, the planner will - * convert back to the feedrate in degrees per time unit. - */ - feedRate_t fr = fr_mm_s; - #if ENABLED(INCH_MODE_SUPPORT) && HAS_ROTATIONAL_AXES - if (parser.axis_is_rotational(axis) && parser.using_inch_units()) fr = IN_TO_MM(fr); - #endif + if (axis == NO_AXIS_ENUM || PENDING(millis(), start_time) || planner.is_full()) return; - #if IS_KINEMATIC + const feedRate_t fr_mm_s = (axis < LOGICAL_AXES) ? manual_feedrate_mm_s[axis] : XY_PROBE_FEEDRATE_MM_S; - #if HAS_MULTI_EXTRUDER - REMEMBER(ae, active_extruder); - #if MULTI_E_MANUAL - if (axis == E_AXIS) active_extruder = e_index; - #endif + /** + * For a rotational axis apply the "inch" to "mm" conversion factor. This mimics behaviour of the G-code G1 + * (see get_destination_from_command). For moves involving only rotational axes, the planner will convert + * back to the feedrate in degrees-per-time unit. + */ + const feedRate_t fr = parser.axis_is_rotational(axis) && parser.using_inch_units() ? IN_TO_MM(fr_mm_s) : fr_mm_s; + + #if IS_KINEMATIC + + #if HAS_MULTI_EXTRUDER + REMEMBER(ae, active_extruder); + #if MULTI_E_MANUAL + if (axis == E_AXIS) active_extruder = e_index; #endif + #endif - // Apply a linear offset to a single axis - if (axis == ALL_AXES_ENUM) - destination = all_axes_destination; - else if (axis <= LOGICAL_AXES) { - destination = current_position; - destination[axis] += offset; - } + // Apply a linear offset to a single axis + if (axis == ALL_AXES_ENUM) + destination = all_axes_destination; + else if (axis <= LOGICAL_AXES) { + destination = current_position; + destination[axis] += offset; + } - // Reset for the next move - offset = 0; - axis = NO_AXIS_ENUM; + // Reset for the next move + offset = 0; + axis = NO_AXIS_ENUM; - // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to - // move_to_destination. This will cause idle() to be called, which can then call this function while the - // previous invocation is being blocked. Modifications to offset shouldn't be made while - // processing is true or the planner will get out of sync. - processing = true; - prepare_internal_move_to_destination(fr); // will set current_position from destination - processing = false; + // DELTA and SCARA machines use segmented moves, which could fill the planner during the call to + // move_to_destination. This will cause idle() to be called, which can then call this function while the + // previous invocation is being blocked. Modifications to offset shouldn't be made while + // processing is true or the planner will get out of sync. + processing = true; + prepare_internal_move_to_destination(fr); // will set current_position from destination + processing = false; - #else + #else - // For Cartesian / Core motion simply move to the current_position - planner.buffer_line(current_position, fr, - TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder - ); + // For Cartesian / Core motion simply move to the current_position + planner.buffer_line(current_position, fr, + TERN_(MULTI_E_MANUAL, axis == E_AXIS ? e_index :) active_extruder + ); - //SERIAL_ECHOLNPGM("Add planner.move with Axis ", C(AXIS_CHAR(axis)), " at FR ", fr_mm_s); + //SERIAL_ECHOLNPGM("Add planner.move with Axis ", C(AXIS_CHAR(axis)), " at FR ", fr_mm_s); - axis = NO_AXIS_ENUM; + axis = NO_AXIS_ENUM; - #endif - } + #endif } // diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index 3e0523f5dc15..ebc809fef8f5 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -78,7 +78,7 @@ void lcd_move_axis(const AxisEnum axis) { if (ui.should_draw()) { MenuEditItemBase::itemIndex = axis; const float pos = ui.manual_move.axis_value(axis); - if (parser.using_inch_units && TERN1(HAS_ROTATIONAL_AXES, !parser.axis_is_rotational(axis))) { + if (parser.using_inch_units() && !parser.axis_is_rotational(axis)) { const float imp_pos = parser.per_axis_value(axis, pos); MenuEditItemBase::draw_edit_screen(GET_TEXT_F(MSG_MOVE_N), ftostr63(imp_pos)); } diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index d9d4e40f180e..40ad8bf47757 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1158,7 +1158,7 @@ float get_move_distance(const xyze_pos_t &diff OPTARG(HAS_ROTATIONAL_AXES, bool distance_sqr = ROTATIONAL_AXIS_GANG(sq(diff.i), + sq(diff.j), + sq(diff.k), + sq(diff.u), + sq(diff.v), + sq(diff.w)); } if (!UNEAR_ZERO(distance_sqr)) { - //Move involves rotational axes, not just the extruder + // Move involves rotational axes, not just the extruder is_cartesian_move = false; } #endif diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 167d71798095..87164f150b55 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2309,8 +2309,8 @@ bool Planner::_populate_block( float inverse_secs = inverse_millimeters * ( #if ALL(HAS_ROTATIONAL_AXES, INCH_MODE_SUPPORT) /** - * Work around for the premature feedrate conversion from - * inches/s to mm/s by the get_distance_from_command function. + * Workaround for premature feedrate conversion + * from in/s to mm/s by get_distance_from_command. */ cartesian_move ? fr_mm_s : LINEAR_UNIT(fr_mm_s) #else diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 8334a1c6635f..5d8eb9010584 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2597,9 +2597,9 @@ hal_timer_t Stepper::block_phase_isr() { AxisBits didmove; NUM_AXIS_CODE( - if (X_MOVE_TEST) didmove.ja = true, - if (Y_MOVE_TEST) didmove.jb = true, - if (Z_MOVE_TEST) didmove.jc = true, + if (X_MOVE_TEST) didmove.ja = true, + if (Y_MOVE_TEST) didmove.jb = true, + if (Z_MOVE_TEST) didmove.jc = true, if (!!current_block->steps._i) didmove.ji = true, if (!!current_block->steps._j) didmove.jj = true, if (!!current_block->steps._k) didmove.jk = true, @@ -2607,10 +2607,6 @@ hal_timer_t Stepper::block_phase_isr() { if (!!current_block->steps._v) didmove.jv = true, if (!!current_block->steps._w) didmove.jw = true ); - //if (current_block->steps.e) didmove.e = true; - //if (current_block->steps.a) didmove.x = true; - //if (current_block->steps.b) didmove.y = true; - //if (current_block->steps.c) didmove.z = true; axis_did_move = didmove; // No acceleration / deceleration time elapsed so far From b20d7cafc81a8d9ac57ef229ccb6bd655b31e968 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:34:32 -0600 Subject: [PATCH 09/13] proper members, not placeholders --- Marlin/src/module/planner.cpp | 42 +++++++++++++++++------------------ Marlin/src/module/stepper.cpp | 30 ++++++++++++------------- 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 87164f150b55..d212709cf33e 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2008,8 +2008,8 @@ bool Planner::_populate_block( #endif SECONDARY_AXIS_CODE( - dm.i = (dist._i > 0), dm.j = (dist._j > 0), dm.k = (dist._k > 0), - dm.u = (dist._u > 0), dm.v = (dist._v > 0), dm.w = (dist._w > 0) + dm.i = (dist.i > 0), dm.j = (dist.j > 0), dm.k = (dist.k > 0), + dm.u = (dist.u > 0), dm.v = (dist.v > 0), dm.w = (dist.w > 0) ); #if HAS_EXTRUDERS @@ -2074,7 +2074,7 @@ bool Planner::_populate_block( #else // default non-h-bot planning ABS(dist.a), ABS(dist.b), ABS(dist.c) #endif - , ABS(dist._i), ABS(dist._j), ABS(dist._k), ABS(dist._u), ABS(dist._v), ABS(dist._w) + , ABS(dist.i), ABS(dist.j), ABS(dist.k), ABS(dist.u), ABS(dist.v), ABS(dist.w) )); /** @@ -2126,8 +2126,8 @@ bool Planner::_populate_block( #endif SECONDARY_AXIS_CODE( - dist_mm._i = dist._i * mm_per_step[I_AXIS], dist_mm._j = dist._j * mm_per_step[J_AXIS], dist_mm._k = dist._k * mm_per_step[K_AXIS], - dist_mm._u = dist._u * mm_per_step[U_AXIS], dist_mm._v = dist._v * mm_per_step[V_AXIS], dist_mm._w = dist._w * mm_per_step[W_AXIS] + dist_mm._i = dist.i * mm_per_step[I_AXIS], dist_mm._j = dist.j * mm_per_step[J_AXIS], dist_mm._k = dist.k * mm_per_step[K_AXIS], + dist_mm._u = dist.u * mm_per_step[U_AXIS], dist_mm._v = dist.v * mm_per_step[V_AXIS], dist_mm._w = dist.w * mm_per_step[W_AXIS] ); TERN_(HAS_EXTRUDERS, dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]); @@ -2140,8 +2140,8 @@ bool Planner::_populate_block( if (true NUM_AXIS_GANG( && block->steps.a < MIN_STEPS_PER_SEGMENT, && block->steps.b < MIN_STEPS_PER_SEGMENT, && block->steps.c < MIN_STEPS_PER_SEGMENT, - && block->steps._i < MIN_STEPS_PER_SEGMENT, && block->steps._j < MIN_STEPS_PER_SEGMENT, && block->steps._k < MIN_STEPS_PER_SEGMENT, - && block->steps._u < MIN_STEPS_PER_SEGMENT, && block->steps._v < MIN_STEPS_PER_SEGMENT, && block->steps._w < MIN_STEPS_PER_SEGMENT + && block->steps.i < MIN_STEPS_PER_SEGMENT, && block->steps.j < MIN_STEPS_PER_SEGMENT, && block->steps.k < MIN_STEPS_PER_SEGMENT, + && block->steps.u < MIN_STEPS_PER_SEGMENT, && block->steps.v < MIN_STEPS_PER_SEGMENT, && block->steps.w < MIN_STEPS_PER_SEGMENT ) ) { block->millimeters = TERN0(HAS_EXTRUDERS, ABS(dist_mm.e)); @@ -2186,8 +2186,8 @@ bool Planner::_populate_block( #if NUM_AXES _MAX(LOGICAL_AXIS_LIST(esteps, block->steps.a, block->steps.b, block->steps.c, - block->steps._i, block->steps._j, block->steps._k, - block->steps._u, block->steps._v, block->steps._w + block->steps.i, block->steps.j, block->steps.k, + block->steps.u, block->steps.v, block->steps.w )) #elif HAS_EXTRUDERS esteps @@ -2967,12 +2967,12 @@ bool Planner::buffer_segment(const abce_pos_t &abce int32_t(LROUND(abce.a * settings.axis_steps_per_mm[A_AXIS])), int32_t(LROUND(abce.b * settings.axis_steps_per_mm[B_AXIS])), int32_t(LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS])), - int32_t(LROUND(abce._i * settings.axis_steps_per_mm[I_AXIS])), - int32_t(LROUND(abce._j * settings.axis_steps_per_mm[J_AXIS])), - int32_t(LROUND(abce._k * settings.axis_steps_per_mm[K_AXIS])), - int32_t(LROUND(abce._u * settings.axis_steps_per_mm[U_AXIS])), - int32_t(LROUND(abce._v * settings.axis_steps_per_mm[V_AXIS])), - int32_t(LROUND(abce._w * settings.axis_steps_per_mm[W_AXIS])) + int32_t(LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS])), + int32_t(LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS])), + int32_t(LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS])), + int32_t(LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS])), + int32_t(LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS])), + int32_t(LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS])) ) }; @@ -3239,12 +3239,12 @@ void Planner::set_machine_position_mm(const abce_pos_t &abce) { LROUND(abce.a * settings.axis_steps_per_mm[A_AXIS]), LROUND(abce.b * settings.axis_steps_per_mm[B_AXIS]), LROUND(abce.c * settings.axis_steps_per_mm[C_AXIS]), - LROUND(abce._i * settings.axis_steps_per_mm[I_AXIS]), - LROUND(abce._j * settings.axis_steps_per_mm[J_AXIS]), - LROUND(abce._k * settings.axis_steps_per_mm[K_AXIS]), - LROUND(abce._u * settings.axis_steps_per_mm[U_AXIS]), - LROUND(abce._v * settings.axis_steps_per_mm[V_AXIS]), - LROUND(abce._w * settings.axis_steps_per_mm[W_AXIS]) + LROUND(abce.i * settings.axis_steps_per_mm[I_AXIS]), + LROUND(abce.j * settings.axis_steps_per_mm[J_AXIS]), + LROUND(abce.k * settings.axis_steps_per_mm[K_AXIS]), + LROUND(abce.u * settings.axis_steps_per_mm[U_AXIS]), + LROUND(abce.v * settings.axis_steps_per_mm[V_AXIS]), + LROUND(abce.w * settings.axis_steps_per_mm[W_AXIS]) ) ); diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 5d8eb9010584..67898fbe5b66 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2597,15 +2597,15 @@ hal_timer_t Stepper::block_phase_isr() { AxisBits didmove; NUM_AXIS_CODE( - if (X_MOVE_TEST) didmove.ja = true, - if (Y_MOVE_TEST) didmove.jb = true, - if (Z_MOVE_TEST) didmove.jc = true, - if (!!current_block->steps._i) didmove.ji = true, - if (!!current_block->steps._j) didmove.jj = true, - if (!!current_block->steps._k) didmove.jk = true, - if (!!current_block->steps._u) didmove.ju = true, - if (!!current_block->steps._v) didmove.jv = true, - if (!!current_block->steps._w) didmove.jw = true + if (X_MOVE_TEST) didmove.ja = true, + if (Y_MOVE_TEST) didmove.jb = true, + if (Z_MOVE_TEST) didmove.jc = true, + if (!!current_block->steps.i) didmove.ji = true, + if (!!current_block->steps.j) didmove.jj = true, + if (!!current_block->steps.k) didmove.jk = true, + if (!!current_block->steps.u) didmove.ju = true, + if (!!current_block->steps.v) didmove.jv = true, + if (!!current_block->steps.w) didmove.jw = true ); axis_did_move = didmove; @@ -3243,12 +3243,12 @@ void Stepper::_set_position(const abce_long_t &spos) { count_position.set(spos.a, spos.b TERN(MARKFORGED_INVERSE, +, -) spos.a, spos.c); #endif SECONDARY_AXIS_CODE( - count_position.i = spos._i, - count_position.j = spos._j, - count_position.k = spos._k, - count_position.u = spos._u, - count_position.v = spos._v, - count_position.w = spos._w + count_position.i = spos.i, + count_position.j = spos.j, + count_position.k = spos.k, + count_position.u = spos.u, + count_position.v = spos.v, + count_position.w = spos.w ); TERN_(HAS_EXTRUDERS, count_position.e = spos.e); #else From 49d011abb4fba5359935f0cd0f8bfb7d845ab5ac Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:37:58 -0600 Subject: [PATCH 10/13] also --- Marlin/src/module/planner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index d212709cf33e..1dc38b3a02f1 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -2126,8 +2126,8 @@ bool Planner::_populate_block( #endif SECONDARY_AXIS_CODE( - dist_mm._i = dist.i * mm_per_step[I_AXIS], dist_mm._j = dist.j * mm_per_step[J_AXIS], dist_mm._k = dist.k * mm_per_step[K_AXIS], - dist_mm._u = dist.u * mm_per_step[U_AXIS], dist_mm._v = dist.v * mm_per_step[V_AXIS], dist_mm._w = dist.w * mm_per_step[W_AXIS] + dist_mm.i = dist.i * mm_per_step[I_AXIS], dist_mm.j = dist.j * mm_per_step[J_AXIS], dist_mm.k = dist.k * mm_per_step[K_AXIS], + dist_mm.u = dist.u * mm_per_step[U_AXIS], dist_mm.v = dist.v * mm_per_step[V_AXIS], dist_mm.w = dist.w * mm_per_step[W_AXIS] ); TERN_(HAS_EXTRUDERS, dist_mm.e = esteps_float * mm_per_step[E_AXIS_N(extruder)]); From 2b514649d35fa7fc6981335cfa8edcb0cd212f89 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:41:17 -0600 Subject: [PATCH 11/13] not really "joints" --- Marlin/src/module/planner.cpp | 20 ++++++++++---------- Marlin/src/module/stepper.cpp | 18 +++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/Marlin/src/module/planner.cpp b/Marlin/src/module/planner.cpp index 1dc38b3a02f1..8f7c4ceb72c7 100644 --- a/Marlin/src/module/planner.cpp +++ b/Marlin/src/module/planner.cpp @@ -1979,26 +1979,26 @@ bool Planner::_populate_block( TERN_(HAS_Z_AXIS, dm.z = (dist.c > 0)); #endif #if CORE_IS_XY - dm.ja = (dist.a + dist.b > 0); // Motor A direction - dm.jb = (CORESIGN(dist.a - dist.b) > 0); // Motor B direction + dm.a = (dist.a + dist.b > 0); // Motor A direction + dm.b = (CORESIGN(dist.a - dist.b) > 0); // Motor B direction #elif CORE_IS_XZ dm.hx = (dist.a > 0); // Save the toolhead's true direction in X dm.y = (dist.b > 0); dm.hz = (dist.c > 0); // ...and Z - dm.ja = (dist.a + dist.c > 0); // Motor A direction - dm.jc = (CORESIGN(dist.a - dist.c) > 0); // Motor C direction + dm.a = (dist.a + dist.c > 0); // Motor A direction + dm.c = (CORESIGN(dist.a - dist.c) > 0); // Motor C direction #elif CORE_IS_YZ dm.x = (dist.a > 0); dm.hy = (dist.b > 0); // Save the toolhead's true direction in Y dm.hz = (dist.c > 0); // ...and Z - dm.jb = (dist.b + dist.c > 0); // Motor B direction - dm.jc = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction + dm.b = (dist.b + dist.c > 0); // Motor B direction + dm.c = (CORESIGN(dist.b - dist.c) > 0); // Motor C direction #elif ENABLED(MARKFORGED_XY) - dm.ja = (dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b > 0); // Motor A direction - dm.jb = (dist.b > 0); // Motor B direction + dm.a = (dist.a TERN(MARKFORGED_INVERSE, -, +) dist.b > 0); // Motor A direction + dm.b = (dist.b > 0); // Motor B direction #elif ENABLED(MARKFORGED_YX) - dm.ja = (dist.a > 0); // Motor A direction - dm.jb = (dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a > 0); // Motor B direction + dm.a = (dist.a > 0); // Motor A direction + dm.b = (dist.b TERN(MARKFORGED_INVERSE, -, +) dist.a > 0); // Motor B direction #else XYZ_CODE( dm.x = (dist.a > 0), diff --git a/Marlin/src/module/stepper.cpp b/Marlin/src/module/stepper.cpp index 67898fbe5b66..0ae6ccb9a75c 100644 --- a/Marlin/src/module/stepper.cpp +++ b/Marlin/src/module/stepper.cpp @@ -2597,15 +2597,15 @@ hal_timer_t Stepper::block_phase_isr() { AxisBits didmove; NUM_AXIS_CODE( - if (X_MOVE_TEST) didmove.ja = true, - if (Y_MOVE_TEST) didmove.jb = true, - if (Z_MOVE_TEST) didmove.jc = true, - if (!!current_block->steps.i) didmove.ji = true, - if (!!current_block->steps.j) didmove.jj = true, - if (!!current_block->steps.k) didmove.jk = true, - if (!!current_block->steps.u) didmove.ju = true, - if (!!current_block->steps.v) didmove.jv = true, - if (!!current_block->steps.w) didmove.jw = true + if (X_MOVE_TEST) didmove.a = true, + if (Y_MOVE_TEST) didmove.b = true, + if (Z_MOVE_TEST) didmove.c = true, + if (!!current_block->steps.i) didmove.i = true, + if (!!current_block->steps.j) didmove.j = true, + if (!!current_block->steps.k) didmove.k = true, + if (!!current_block->steps.u) didmove.u = true, + if (!!current_block->steps.v) didmove.v = true, + if (!!current_block->steps.w) didmove.w = true ); axis_did_move = didmove; From d38596b48ae42185faced31fc7fbdddbeeb0ce3d Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:47:25 -0600 Subject: [PATCH 12/13] allow E only --- Marlin/src/core/types.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index fef143b2e5f4..9b637b9f7b60 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -939,7 +939,9 @@ class AxisBits { el bits; // Axes x, y, z ... e0, e1, e2 ... hx, hy, hz struct { - bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); + #if NUM_AXES + bool NUM_AXIS_LIST(x:1, y:1, z:1, i:1, j:1, k:1, u:1, v:1, w:1); + #endif #define _EN_ITEM(N) bool e##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM @@ -949,7 +951,9 @@ class AxisBits { }; // Axes X, Y, Z ... E0, E1, E2 ... HX, HY, HZ struct { - bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); + #if NUM_AXES + bool NUM_AXIS_LIST(X:1, Y:1, Z:1, I:1, J:1, K:1, U:1, V:1, W:1); + #endif #define _EN_ITEM(N) bool E##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM @@ -983,7 +987,9 @@ class AxisBits { }; // Joints ja, jb, jc ... je0, je1, je2 ... jha, jhb, jhc struct { - bool NUM_AXIS_LIST(ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); + #if NUM_AXES + bool NUM_AXIS_LIST(ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); + #endif #define _EN_ITEM(N) bool je##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM @@ -993,7 +999,9 @@ class AxisBits { }; // Joints JA, JB, JC ... JE0, JE1, JE2 ... JHA, JHB, JHC struct { - bool NUM_AXIS_LIST(JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); + #if NUM_AXES + bool NUM_AXIS_LIST(JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); + #endif #define _EN_ITEM(N) bool JE##N:1; REPEAT(EXTRUDERS,_EN_ITEM) #undef _EN_ITEM From 45c206bff26ff1db5d7cc3a789ed52f594302d89 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 15:53:15 -0600 Subject: [PATCH 13/13] fix _U conflict, etc. --- Marlin/src/core/types.h | 28 ++-------------------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/Marlin/src/core/types.h b/Marlin/src/core/types.h index 9b637b9f7b60..e67644e52fc6 100644 --- a/Marlin/src/core/types.h +++ b/Marlin/src/core/types.h @@ -963,7 +963,7 @@ class AxisBits { }; // a, b, c, e ... ha, hb, hc struct { - bool LOGICAL_AXIS_LIST(e:1, a:1, b:1, c:1, _i:1, _j:1, _k:1, _u:1, _v:1, _w:1); + bool LOGICAL_AXIS_LIST(e:1, a:1, b:1, c:1, ii:1, jj:1, kk:1, uu:1, vv:1, ww:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _e##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) @@ -975,7 +975,7 @@ class AxisBits { }; // A, B, C, E ... HA, HB, HC struct { - bool LOGICAL_AXIS_LIST(E:1, A:1, B:1, C:1, _I:1, _J:1, _K:1, _U:1, _V:1, _W:1); + bool LOGICAL_AXIS_LIST(E:1, A:1, B:1, C:1, II:1, JJ:1, KK:1, UU:1, VV:1, WW:1); #if EXTRUDERS > 1 #define _EN_ITEM(N) bool _E##N:1; REPEAT_S(1,EXTRUDERS,_EN_ITEM) @@ -985,30 +985,6 @@ class AxisBits { bool HA:1, HB:1, HC:1; #endif }; - // Joints ja, jb, jc ... je0, je1, je2 ... jha, jhb, jhc - struct { - #if NUM_AXES - bool NUM_AXIS_LIST(ja:1, jb:1, jc:1, ji:1, jj:1, jk:1, ju:1, jv:1, jw:1); - #endif - #define _EN_ITEM(N) bool je##N:1; - REPEAT(EXTRUDERS,_EN_ITEM) - #undef _EN_ITEM - #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) - bool jha:1, jhb:1, jhc:1; - #endif - }; - // Joints JA, JB, JC ... JE0, JE1, JE2 ... JHA, JHB, JHC - struct { - #if NUM_AXES - bool NUM_AXIS_LIST(JA:1, JB:1, JC:1, JI:1, JJ:1, JK:1, JU:1, JV:1, JW:1); - #endif - #define _EN_ITEM(N) bool JE##N:1; - REPEAT(EXTRUDERS,_EN_ITEM) - #undef _EN_ITEM - #if ANY(IS_CORE, MARKFORGED_XY, MARKFORGED_YX) - bool JHA:1, JHB:1, JHC:1; - #endif - }; }; AxisBits() { reset(); }