From c28c662bcd3f93fcecf64db9e6282ac83f477109 Mon Sep 17 00:00:00 2001 From: Trivalik <3148279+trivalik@users.noreply.github.com> Date: Sun, 12 Feb 2023 05:14:53 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Negative=20temperature=20display?= =?UTF-8?q?=20option=20(#25036)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/Configuration_adv.h | 3 +++ Marlin/src/lcd/HD44780/marlinui_HD44780.cpp | 14 ++++++++++-- Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 24 +++++++++++++++------ 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 31cbd678bfd4..a9e6d4928f07 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1455,6 +1455,9 @@ // Show the E position (filament used) during printing //#define LCD_SHOW_E_TOTAL + // Display a negative temperature instead of "err" + //#define SHOW_TEMPERATURE_BELOW_ZERO + /** * LED Control Menu * Add LED Control to the LCD menu diff --git a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp index 9445198a22c1..9093fa3eab9e 100644 --- a/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp +++ b/Marlin/src/lcd/HD44780/marlinui_HD44780.cpp @@ -537,7 +537,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const */ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) { #if HAS_HEATED_BED - const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0); + const bool isBed = heater_id == H_BED; const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)), t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id)); #else @@ -546,7 +546,17 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr if (prefix >= 0) lcd_put_lchar(prefix); - lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1)); + if (t1 >= 0) + lcd_put_u8str(ui16tostr3rj(t1)); + else { + #if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO) + char * const str = i16tostr3rj(t1); + lcd_put_u8str(&str[1]); + #else + lcd_put_u8str(F("err")); + #endif + } + lcd_put_u8str(F("/")); #if !HEATER_IDLE_HANDLER diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index 8bdba4234282..721dcb63ffbe 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -192,14 +192,26 @@ #define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X) FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) { - if (temp < 0) - lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, F("err")); + const char *str; + uint8_t len; + if (temp >= 0) { + str = i16tostr3left(temp); + len = strlen(str); + lcd_moveto(tx + 1 - len * (INFO_FONT_WIDTH) / 2, ty); + } else { - const char *str = i16tostr3rj(temp); - const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1; - lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]); - lcd_put_lchar(LCD_STR_DEGREE[0]); + #if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO) + str = i16tostr3left((-temp) % 100); + len = strlen(str) + 1; + lcd_moveto(tx + 1 - len * (INFO_FONT_WIDTH) / 2, ty); + lcd_put_lchar('-'); + #else + lcd_put_u8str(tx + 1 - 3 * (INFO_FONT_WIDTH) / 2, ty, F("err")); + return; + #endif } + lcd_put_u8str(str); + lcd_put_lchar(LCD_STR_DEGREE[0]); } #if DO_DRAW_FLOWMETER