From f390b3f31454a0cb9506957d15cc49ba3e5a0b0f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 6 Dec 2014 20:59:06 -0800 Subject: [PATCH] Patch to make Z look more like X and Y on UltraLCD --- Marlin/ultralcd.cpp | 14 ++++++++++++++ Marlin/ultralcd.h | 1 + Marlin/ultralcd_implementation_hitachi_HD44780.h | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index fe12761f12..fbfa859c58 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -1443,6 +1443,20 @@ char *ftostr12ns(const float &x) return conv; } +// convert float to space-padded string with -_23.4_ format +char *ftostr32np(const float &x) { + char *c = ftostr32(x); + if (c[0] == '0' || c[0] == '-') { + if (c[0] == '0') c[0] = ' '; + if (c[1] == '0') c[1] = ' '; + } + if (c[5] == '0') { + c[5] = ' '; + if (c[4] == '0') c[4] = c[3] = ' '; + } + return c; +} + char *itostr31(const int &xx) { conv[0]=(xx>=0)?'+':'-'; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 339955e592..44f176a809 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -119,6 +119,7 @@ char *ftostr31ns(const float &x); // float to string without sign character char *ftostr31(const float &x); char *ftostr32(const float &x); char *ftostr12ns(const float &x); +char *ftostr32np(const float &x); // remove zero-padding from ftostr32 char *ftostr5(const float &x); char *ftostr51(const float &x); char *ftostr52(const float &x); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index 923e249c85..b7ab9c6c4b 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -475,7 +475,7 @@ static void lcd_implementation_status_screen() # endif//LCD_WIDTH > 19 lcd.setCursor(LCD_WIDTH - 8, 1); lcd.print('Z'); - lcd.print(ftostr32(current_position[Z_AXIS] + 0.00001)); + lcd.print(ftostr32np(current_position[Z_AXIS] + 0.00001)); #endif//LCD_HEIGHT > 2 #if LCD_HEIGHT > 3