Skip to content

Commit 0665c72

Browse files
trivalikthinkyhead
authored andcommitted
🚸 Negative temperature display option (MarlinFirmware#25036)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent a40c8b7 commit 0665c72

File tree

3 files changed

+33
-8
lines changed

3 files changed

+33
-8
lines changed

Marlin/Configuration_adv.h

+3
Original file line numberDiff line numberDiff line change
@@ -1455,6 +1455,9 @@
14551455
// Show the E position (filament used) during printing
14561456
//#define LCD_SHOW_E_TOTAL
14571457

1458+
// Display a negative temperature instead of "err"
1459+
//#define SHOW_TEMPERATURE_BELOW_ZERO
1460+
14581461
/**
14591462
* LED Control Menu
14601463
* Add LED Control to the LCD menu

Marlin/src/lcd/HD44780/marlinui_HD44780.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
537537
*/
538538
FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char prefix, const bool blink) {
539539
#if HAS_HEATED_BED
540-
const bool isBed = TERN(HAS_HEATED_CHAMBER, heater_id == H_BED, heater_id < 0);
540+
const bool isBed = heater_id == H_BED;
541541
const celsius_t t1 = (isBed ? thermalManager.wholeDegBed() : thermalManager.wholeDegHotend(heater_id)),
542542
t2 = (isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater_id));
543543
#else
@@ -546,7 +546,17 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater_id, const char pr
546546

547547
if (prefix >= 0) lcd_put_lchar(prefix);
548548

549-
lcd_put_u8str(t1 < 0 ? "err" : i16tostr3rj(t1));
549+
if (t1 >= 0)
550+
lcd_put_u8str(ui16tostr3rj(t1));
551+
else {
552+
#if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO)
553+
char * const str = i16tostr3rj(t1);
554+
lcd_put_u8str(&str[1]);
555+
#else
556+
lcd_put_u8str(F("err"));
557+
#endif
558+
}
559+
550560
lcd_put_u8str(F("/"));
551561

552562
#if !HEATER_IDLE_HANDLER

Marlin/src/lcd/dogm/status_screen_DOGM.cpp

+18-6
Original file line numberDiff line numberDiff line change
@@ -192,14 +192,26 @@
192192
#define PROGRESS_BAR_WIDTH (LCD_PIXEL_WIDTH - PROGRESS_BAR_X)
193193

194194
FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, const uint8_t ty) {
195-
if (temp < 0)
196-
lcd_put_u8str(tx - 3 * (INFO_FONT_WIDTH) / 2 + 1, ty, F("err"));
195+
const char *str;
196+
uint8_t len;
197+
if (temp >= 0) {
198+
str = i16tostr3left(temp);
199+
len = strlen(str);
200+
lcd_moveto(tx + 1 - len * (INFO_FONT_WIDTH) / 2, ty);
201+
}
197202
else {
198-
const char *str = i16tostr3rj(temp);
199-
const uint8_t len = str[0] != ' ' ? 3 : str[1] != ' ' ? 2 : 1;
200-
lcd_put_u8str(tx - len * (INFO_FONT_WIDTH) / 2 + 1, ty, &str[3-len]);
201-
lcd_put_lchar(LCD_STR_DEGREE[0]);
203+
#if ENABLED(SHOW_TEMPERATURE_BELOW_ZERO)
204+
str = i16tostr3left((-temp) % 100);
205+
len = strlen(str) + 1;
206+
lcd_moveto(tx + 1 - len * (INFO_FONT_WIDTH) / 2, ty);
207+
lcd_put_lchar('-');
208+
#else
209+
lcd_put_u8str(tx + 1 - 3 * (INFO_FONT_WIDTH) / 2, ty, F("err"));
210+
return;
211+
#endif
202212
}
213+
lcd_put_u8str(str);
214+
lcd_put_lchar(LCD_STR_DEGREE[0]);
203215
}
204216

205217
#if DO_DRAW_FLOWMETER

0 commit comments

Comments
 (0)