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