From 2c9775313a5a209822c9df4b0a907e406e672158 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Feb 2018 00:42:42 -0600 Subject: [PATCH] Fix Z position on HD44780 Fix #9732 --- Marlin/src/lcd/ultralcd_impl_HD44780.h | 2 +- Marlin/src/module/motion.h | 50 +++++++++++--------------- 2 files changed, 22 insertions(+), 30 deletions(-) diff --git a/Marlin/src/lcd/ultralcd_impl_HD44780.h b/Marlin/src/lcd/ultralcd_impl_HD44780.h index 70dc5294b..61cb35759 100644 --- a/Marlin/src/lcd/ultralcd_impl_HD44780.h +++ b/Marlin/src/lcd/ultralcd_impl_HD44780.h @@ -837,7 +837,7 @@ static void lcd_implementation_status_screen() { lcd.setCursor(LCD_WIDTH - 8, 1); _draw_axis_label(Z_AXIS, PSTR(MSG_Z), blink); - lcd.print(ftostr52sp(FIXFLOAT(current_position[Z_AXIS]))); + lcd.print(ftostr52sp(FIXFLOAT(LOGICAL_Z_POSITION(current_position[Z_AXIS])))); #if HAS_LEVELING && !TEMP_SENSOR_BED lcd.write(planner.leveling_active || blink ? '_' : ' '); diff --git a/Marlin/src/module/motion.h b/Marlin/src/module/motion.h index ea057695b..3222f1299 100644 --- a/Marlin/src/module/motion.h +++ b/Marlin/src/module/motion.h @@ -195,7 +195,9 @@ void homeaxis(const AxisEnum axis); // Macros // -// Workspace offsets +/** + * Workspace offsets + */ #if HAS_WORKSPACE_OFFSET #if HAS_HOME_OFFSET extern float home_offset[XYZ]; @@ -203,36 +205,26 @@ void homeaxis(const AxisEnum axis); #if HAS_POSITION_SHIFT extern float position_shift[XYZ]; #endif -#endif - -#if HAS_HOME_OFFSET && HAS_POSITION_SHIFT - extern float workspace_offset[XYZ]; - #define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS] -#elif HAS_HOME_OFFSET - #define WORKSPACE_OFFSET(AXIS) home_offset[AXIS] -#elif HAS_POSITION_SHIFT - #define WORKSPACE_OFFSET(AXIS) position_shift[AXIS] -#else - #define WORKSPACE_OFFSET(AXIS) 0 -#endif - -#define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS)) -#define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - WORKSPACE_OFFSET(AXIS)) - -#if HAS_POSITION_SHIFT || DISABLED(DELTA) - #define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS) - #define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS) - #define RAW_X_POSITION(POS) LOGICAL_TO_NATIVE(POS, X_AXIS) - #define RAW_Y_POSITION(POS) LOGICAL_TO_NATIVE(POS, Y_AXIS) + #if HAS_HOME_OFFSET && HAS_POSITION_SHIFT + extern float workspace_offset[XYZ]; + #define WORKSPACE_OFFSET(AXIS) workspace_offset[AXIS] + #elif HAS_HOME_OFFSET + #define WORKSPACE_OFFSET(AXIS) home_offset[AXIS] + #elif HAS_POSITION_SHIFT + #define WORKSPACE_OFFSET(AXIS) position_shift[AXIS] + #endif + #define NATIVE_TO_LOGICAL(POS, AXIS) ((POS) + WORKSPACE_OFFSET(AXIS)) + #define LOGICAL_TO_NATIVE(POS, AXIS) ((POS) - WORKSPACE_OFFSET(AXIS)) #else - #define LOGICAL_X_POSITION(POS) (POS) - #define LOGICAL_Y_POSITION(POS) (POS) - #define RAW_X_POSITION(POS) (POS) - #define RAW_Y_POSITION(POS) (POS) + #define NATIVE_TO_LOGICAL(POS, AXIS) (POS) + #define LOGICAL_TO_NATIVE(POS, AXIS) (POS) #endif - -#define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS) -#define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS) +#define LOGICAL_X_POSITION(POS) NATIVE_TO_LOGICAL(POS, X_AXIS) +#define LOGICAL_Y_POSITION(POS) NATIVE_TO_LOGICAL(POS, Y_AXIS) +#define LOGICAL_Z_POSITION(POS) NATIVE_TO_LOGICAL(POS, Z_AXIS) +#define RAW_X_POSITION(POS) LOGICAL_TO_NATIVE(POS, X_AXIS) +#define RAW_Y_POSITION(POS) LOGICAL_TO_NATIVE(POS, Y_AXIS) +#define RAW_Z_POSITION(POS) LOGICAL_TO_NATIVE(POS, Z_AXIS) /** * position_is_reachable family of functions