From 5fea79fd07e5d874fbd217d8d9e8afceec60ef9e Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 23 Jan 2024 16:02:33 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20Fix=20ROTATIONAL=5FAXIS=5FGANG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: DerAndere <26200979+DerAndere1@users.noreply.github.com> --- Marlin/src/gcode/parser.h | 32 +++++++++++++++++------------- Marlin/src/inc/Conditionals_LCD.h | 4 ++++ Marlin/src/inc/Conditionals_adv.h | 5 +++++ Marlin/src/inc/Conditionals_post.h | 6 ------ 4 files changed, 27 insertions(+), 20 deletions(-) diff --git a/Marlin/src/gcode/parser.h b/Marlin/src/gcode/parser.h index 5d162c0a41..94c5b284e0 100644 --- a/Marlin/src/gcode/parser.h +++ b/Marlin/src/gcode/parser.h @@ -288,6 +288,17 @@ public: // Bool is true with no value or non-zero static bool value_bool() { return !has_value() || !!value_byte(); } + 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) @@ -307,14 +318,7 @@ public: } 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 (axis_is_rotational(axis)) return 1.0f; #if HAS_EXTRUDERS if (axis >= E_AXIS && volumetric_enabled) return volumetric_unit_factor; #endif @@ -327,12 +331,12 @@ public: #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 @@ -402,7 +406,7 @@ public: #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_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index 64056d40f9..bff742a5bc 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -507,6 +507,10 @@ #define ROTATIONAL_AXES 0 #endif +#if ROTATIONAL_AXES + #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_adv.h b/Marlin/src/inc/Conditionals_adv.h index 9f182a108d..379600d915 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 diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 49562cb856..a1ef4a4fe0 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -96,12 +96,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 -#else - #undef MANUAL_MOVE_DISTANCE_DEG -#endif - #if HAS_X_AXIS #define X_MAX_LENGTH (X_MAX_POS - (X_MIN_POS)) #endif