@@ -193,11 +193,11 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
193
193
#define HOTEND_STATS 3
194
194
#elif HOTENDS > 1
195
195
#define HOTEND_STATS 2
196
- #elif HAS_HOTEND
196
+ #else
197
197
#define HOTEND_STATS 1
198
198
#endif
199
199
static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1 (HOTEND_STATS, 500 ),
200
- old_target[HOTEND_STATS] = ARRAY_N_1 (HOTEND_STATS, 500 );
200
+ old_target[HOTEND_STATS] = ARRAY_N_1 (HOTEND_STATS, 500 );
201
201
static bool old_on[HOTEND_STATS] = ARRAY_N_1 (HOTEND_STATS, false );
202
202
#endif
203
203
@@ -211,24 +211,23 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
211
211
212
212
#if HAS_HOTEND && HAS_HEATED_BED
213
213
const bool isBed = heater < 0 ;
214
- const float tc = isBed ? thermalManager.degBed () : thermalManager.degHotend (heater),
215
- tt = isBed ? thermalManager.degTargetBed () : thermalManager.degTargetHotend (heater);
216
- const bool ta = isBed ? thermalManager.isHeatingBed () : thermalManager.isHeatingHotend (heater);
217
-
218
- bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]),
219
- t_draw = tt != (isBed ? old_bed_target : old_target[heater]),
220
- i_draw = ta != (isBed ? old_bed_on : old_on[heater]);
221
-
214
+ bool c_draw, t_draw, i_draw;
222
215
if (isBed) {
223
- #if HAS_LEVELING
224
- if (!i_draw && planner.leveling_active != old_leveling_on) i_draw = true ;
225
- old_leveling_on = planner.leveling_active ;
226
- #endif
216
+ const float tc = thermalManager.degBed (), tt = thermalManager.degTargetBed ();
217
+ const bool ta = thermalManager.isHeatingBed ();
218
+ c_draw = tc != old_bed_temp;
219
+ t_draw = tt != old_bed_target;
220
+ i_draw = ta != old_bed_on;
227
221
old_bed_temp = tc;
228
222
old_bed_target = tt;
229
223
old_bed_on = ta;
230
224
}
231
225
else {
226
+ const float tc = thermalManager.degHotend (heater), tt = thermalManager.degTargetHotend (heater);
227
+ const bool ta = thermalManager.isHeatingHotend (heater);
228
+ c_draw = tc != old_temp[heater];
229
+ t_draw = tt != old_target[heater];
230
+ i_draw = ta != old_on[heater];
232
231
old_temp[heater] = tc;
233
232
old_target[heater] = tt;
234
233
old_on[heater] = ta;
@@ -237,31 +236,41 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
237
236
constexpr bool isBed = false ;
238
237
const float tc = thermalManager.degHotend (heater), tt = thermalManager.degTargetHotend (heater);
239
238
const uint8_t ta = thermalManager.isHeatingHotend (heater);
240
- const bool c_draw = tc != old_bed_temp , t_draw = tt != old_bed_target , i_draw = ta != old_bed_on ;
239
+ bool c_draw = tc != old_temp[heater] , t_draw = tt != old_target[heater] , i_draw = ta != old_on[heater] ;
241
240
old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta;
242
241
#elif HAS_HEATED_BED
243
242
constexpr bool isBed = true ;
244
243
const float tc = thermalManager.degBed (), tt = thermalManager.degTargetBed ();
245
244
const uint8_t ta = thermalManager.isHeatingBed ();
246
- bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater];
247
- #if HAS_LEVELING
248
- if (!idraw && planner.leveling_active != old_leveling_on) i_draw = true ;
249
- old_leveling_on = tl;
250
- #endif
245
+ bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on;
251
246
old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta;
247
+ #else
248
+ bool c_draw = false , t_draw = false , i_draw = false ;
249
+ constexpr float tc = 0 , tt = 0 ;
250
+ constexpr uint8_t ta = 0 ;
252
251
#endif
253
252
253
+ #if HAS_HEATED_BED && HAS_LEVELING
254
+ if (isBed) {
255
+ i_draw |= (planner.leveling_active != old_leveling_on);
256
+ old_leveling_on = planner.leveling_active ;
257
+ }
258
+ #endif
259
+
260
+ // Draw target temperature, if needed
254
261
if (!ui.did_first_redraw || t_draw) {
255
262
dwin_string.set (i16tostr3rj (tt + 0.5 ));
256
263
dwin_string.add (LCD_STR_DEGREE);
257
264
DWIN_Draw_String (true , font14x28, Color_White, Color_Bg_Black, x, y, S (dwin_string.string ()));
258
265
}
259
266
260
- if (!ui.did_first_redraw || i_draw){
267
+ // Draw heater icon with on / off / leveled states
268
+ if (!ui.did_first_redraw || i_draw) {
261
269
const uint8_t ico = isBed ? (TERN0 (HAS_LEVELING, planner.leveling_active ) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff;
262
270
DWIN_ICON_Show (ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2 );
263
271
}
264
272
273
+ // Draw current temperature, if needed
265
274
if (!ui.did_first_redraw || c_draw) {
266
275
dwin_string.set (i16tostr3rj (tc + 0.5 ));
267
276
dwin_string.add (LCD_STR_DEGREE);
@@ -412,43 +421,45 @@ void MarlinUI::draw_status_screen() {
412
421
//
413
422
// Progress Bar
414
423
//
415
- constexpr int16_t pb_margin = 5 ,
416
- pb_left = pb_margin + TERN (DWIN_MARLINUI_PORTRAIT, 0 , 90 ),
417
- pb_height = TERN (DWIN_MARLINUI_PORTRAIT, 60 , 20 ),
418
- pb_right = LCD_PIXEL_WIDTH - pb_margin,
419
- pb_bottom = TERN (DWIN_MARLINUI_PORTRAIT, 410 , 220 ),
420
- pb_top = pb_bottom - pb_height,
421
- pb_width = pb_right - pb_left;
422
-
423
- const progress_t progress = TERN (HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
424
-
425
- if (!ui.did_first_redraw )
426
- DWIN_Draw_Rectangle (0 , Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline
427
-
428
- static uint16_t old_solid = 50 ;
429
- const uint16_t pb_solid = (pb_width - 2 ) * (progress / (PROGRESS_SCALE)) * 0 .01f ;
430
- const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid;
431
-
432
- if (p_draw) {
433
- // if (pb_solid)
434
- DWIN_Draw_Rectangle (1 , Select_Color, pb_left + 1 , pb_top + 1 , pb_left + pb_solid, pb_bottom - 1 ); // Fill the solid part
435
-
436
- // if (pb_solid < old_solid)
437
- DWIN_Draw_Rectangle (1 , Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1 , pb_right - 1 , pb_bottom - 1 ); // Erase the rest
438
-
439
- #if ENABLED(SHOW_SD_PERCENT)
440
- dwin_string.set (TERN (PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4 (progress), ui8tostr3rj (progress / (PROGRESS_SCALE))));
441
- dwin_string.add (PSTR (" %" ));
442
- DWIN_Draw_String (
443
- false , font16x32, Percent_Color, Color_Bg_Black,
444
- pb_left + (pb_width - dwin_string.length () * 16 ) / 2 ,
445
- pb_top + (pb_height - 32 ) / 2 ,
446
- S (dwin_string.string ())
447
- );
448
- #endif
424
+ #if HAS_PRINT_PROGRESS
425
+ constexpr int16_t pb_margin = 5 ,
426
+ pb_left = pb_margin + TERN (DWIN_MARLINUI_PORTRAIT, 0 , 90 ),
427
+ pb_height = TERN (DWIN_MARLINUI_PORTRAIT, 60 , 20 ),
428
+ pb_right = LCD_PIXEL_WIDTH - pb_margin,
429
+ pb_bottom = TERN (DWIN_MARLINUI_PORTRAIT, 410 , 220 ),
430
+ pb_top = pb_bottom - pb_height,
431
+ pb_width = pb_right - pb_left;
432
+
433
+ const progress_t progress = TERN (HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)();
434
+
435
+ if (!ui.did_first_redraw )
436
+ DWIN_Draw_Rectangle (0 , Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline
437
+
438
+ static uint16_t old_solid = 50 ;
439
+ const uint16_t pb_solid = (pb_width - 2 ) * (progress / (PROGRESS_SCALE)) * 0 .01f ;
440
+ const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid;
441
+
442
+ if (p_draw) {
443
+ // if (pb_solid)
444
+ DWIN_Draw_Rectangle (1 , Select_Color, pb_left + 1 , pb_top + 1 , pb_left + pb_solid, pb_bottom - 1 ); // Fill the solid part
445
+
446
+ // if (pb_solid < old_solid)
447
+ DWIN_Draw_Rectangle (1 , Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1 , pb_right - 1 , pb_bottom - 1 ); // Erase the rest
448
+
449
+ #if ENABLED(SHOW_SD_PERCENT)
450
+ dwin_string.set (TERN (PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4 (progress), ui8tostr3rj (progress / (PROGRESS_SCALE))));
451
+ dwin_string.add (PSTR (" %" ));
452
+ DWIN_Draw_String (
453
+ false , font16x32, Percent_Color, Color_Bg_Black,
454
+ pb_left + (pb_width - dwin_string.length () * 16 ) / 2 ,
455
+ pb_top + (pb_height - 32 ) / 2 ,
456
+ S (dwin_string.string ())
457
+ );
458
+ #endif
449
459
450
- old_solid = pb_solid;
451
- }
460
+ old_solid = pb_solid;
461
+ }
462
+ #endif // HAS_PRINT_PROGRESS
452
463
453
464
//
454
465
// Status Message
0 commit comments