|
61 | 61 | #define STATUS_CHR_WIDTH 14 |
62 | 62 | #define STATUS_CHR_HEIGHT 28 |
63 | 63 |
|
| 64 | +bool old_is_printing; |
| 65 | + |
64 | 66 | // |
65 | 67 | // Before homing, blink '123' <-> '???'. |
66 | 68 | // Homed but unknown... '123' <-> ' '. |
67 | 69 | // Homed and known, display constantly. |
68 | 70 | // |
69 | | -FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) { |
70 | | - |
71 | | - #if ENABLED(DWIN_MARLINUI_PORTRAIT) |
72 | | - |
73 | | - uint8_t vallen = utf8_strlen(value); |
74 | | - if (!ui.did_first_redraw) { |
75 | | - dwin_string.set('X' + axis); |
76 | | - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string())); |
77 | | - } |
78 | | - |
79 | | - dwin_string.set(); |
80 | | - if (blink) |
81 | | - dwin_string.add(value); |
82 | | - else if (!TEST(axes_homed, axis)) |
83 | | - while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); |
84 | | - else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axes_trusted, axis)) |
85 | | - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); |
86 | | - else |
87 | | - dwin_string.add(value); |
88 | | - |
89 | | - // For E_TOTAL there may be some characters to cover up |
90 | | - if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS) |
91 | | - dwin_string.add(F(" ")); |
92 | | - |
93 | | - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string())); |
94 | | - |
95 | | - #else // !DWIN_MARLINUI_PORTRAIT |
96 | | - |
97 | | - if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { |
98 | | - dwin_string.set('X' + axis); |
99 | | - DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string())); |
100 | | - } |
101 | | - |
102 | | - dwin_string.set(); |
103 | | - if (blink) |
104 | | - dwin_string.add(value); |
105 | | - else { |
106 | | - if (!TEST(axes_homed, axis)) |
107 | | - while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); |
108 | | - else { |
109 | | - #if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) |
110 | | - if (!TEST(axes_trusted, axis)) |
111 | | - dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); |
112 | | - else |
113 | | - #endif |
114 | | - dwin_string.add(value); |
115 | | - } |
116 | | - } |
117 | | - |
118 | | - // For E_TOTAL there may be some characters to cover up |
119 | | - if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS) |
120 | | - dwin_string.add(F(" ")); |
121 | | - |
122 | | - DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string())); |
| 71 | +void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) { |
| 72 | + const bool x_redraw = !ui.did_first_redraw || old_is_printing != print_job_timer.isRunning(); |
| 73 | + if (x_redraw) { |
| 74 | + dwin_string.set('X' + axis); |
| 75 | + DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, |
| 76 | + #if ENABLED(DWIN_MARLINUI_PORTRAIT) |
| 77 | + x + (utf8_strlen(value) * 14 - 14) / 2, y + 2 |
| 78 | + #else |
| 79 | + x, y |
| 80 | + #endif |
| 81 | + , S(dwin_string.string()) |
| 82 | + ); |
| 83 | + } |
123 | 84 |
|
124 | | - #endif // !DWIN_MARLINUI_PORTRAIT |
| 85 | + dwin_string.set(); |
| 86 | + if (blink) |
| 87 | + dwin_string.add(value); |
| 88 | + else if (!TEST(axes_homed, axis)) |
| 89 | + while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?'); |
| 90 | + else if (NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING) && !TEST(axes_trusted, axis)) |
| 91 | + dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" ")); |
| 92 | + else |
| 93 | + dwin_string.add(value); |
| 94 | + |
| 95 | + // For E_TOTAL there may be some characters to cover up |
| 96 | + if (TERN0(LCD_SHOW_E_TOTAL, x_redraw && axis == X_AXIS)) |
| 97 | + dwin_string.add(F(" ")); |
| 98 | + |
| 99 | + DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, |
| 100 | + #if ENABLED(DWIN_MARLINUI_PORTRAIT) |
| 101 | + x, y + 32 |
| 102 | + #else |
| 103 | + x + 32, y + 4 |
| 104 | + #endif |
| 105 | + , S(dwin_string.string()) |
| 106 | + ); |
125 | 107 | } |
126 | 108 |
|
127 | 109 | #if ENABLED(LCD_SHOW_E_TOTAL) |
128 | 110 |
|
129 | | - FORCE_INLINE void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) { |
| 111 | + void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) { |
130 | 112 | const uint8_t scale = value >= 100000.0f ? 10 : 1; // show cm after 99,999mm |
131 | 113 |
|
132 | 114 | #if ENABLED(DWIN_MARLINUI_PORTRAIT) |
@@ -207,72 +189,56 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x |
207 | 189 | #endif |
208 | 190 | #endif |
209 | 191 |
|
210 | | - #if HAS_HOTEND && HAS_HEATED_BED |
211 | | - float tc, tt; |
212 | | - bool c_draw, t_draw, i_draw, ta; |
213 | | - const bool isBed = heater < 0; |
214 | | - if (isBed) { |
| 192 | + celsius_float_t tc = 0, tt = 0; |
| 193 | + bool isBed = (DISABLED(HAS_HOTEND) && ENABLED(HAS_HEATED_BED)) || (BOTH(HAS_HOTEND, HAS_HEATED_BED) && heater < 0), |
| 194 | + ta = false, c_draw, t_draw, i_draw; |
| 195 | + c_draw = t_draw = i_draw = !ui.did_first_redraw; |
| 196 | + if (isBed) { |
| 197 | + #if HAS_HEATED_BED |
215 | 198 | tc = thermalManager.degBed(); |
216 | 199 | tt = thermalManager.degTargetBed(); |
217 | 200 | ta = thermalManager.isHeatingBed(); |
218 | | - c_draw = tc != old_bed_temp; |
219 | | - t_draw = tt != old_bed_target; |
220 | | - i_draw = ta != old_bed_on; |
| 201 | + c_draw |= tc != old_bed_temp; |
| 202 | + t_draw |= tt != old_bed_target; |
| 203 | + i_draw |= ta != old_bed_on; |
221 | 204 | old_bed_temp = tc; |
222 | 205 | old_bed_target = tt; |
223 | 206 | old_bed_on = ta; |
224 | | - } |
225 | | - else { |
| 207 | + #if HAS_LEVELING |
| 208 | + i_draw |= planner.leveling_active != old_leveling_on; |
| 209 | + old_leveling_on = planner.leveling_active; |
| 210 | + #endif |
| 211 | + #endif |
| 212 | + } |
| 213 | + else { |
| 214 | + #if HAS_HOTEND |
226 | 215 | tc = thermalManager.degHotend(heater); |
227 | 216 | tt = thermalManager.degTargetHotend(heater); |
228 | 217 | ta = thermalManager.isHeatingHotend(heater); |
229 | | - c_draw = tc != old_temp[heater]; |
230 | | - t_draw = tt != old_target[heater]; |
231 | | - i_draw = ta != old_on[heater]; |
| 218 | + c_draw |= tc != old_temp[heater]; |
| 219 | + t_draw |= tt != old_target[heater]; |
| 220 | + i_draw |= ta != old_on[heater]; |
232 | 221 | old_temp[heater] = tc; |
233 | 222 | old_target[heater] = tt; |
234 | 223 | old_on[heater] = ta; |
235 | | - } |
236 | | - #elif HAS_HOTEND |
237 | | - constexpr bool isBed = false; |
238 | | - const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); |
239 | | - const uint8_t ta = thermalManager.isHeatingHotend(heater); |
240 | | - bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; |
241 | | - old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; |
242 | | - #elif HAS_HEATED_BED |
243 | | - constexpr bool isBed = true; |
244 | | - const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); |
245 | | - const uint8_t ta = thermalManager.isHeatingBed(); |
246 | | - bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; |
247 | | - old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; |
248 | | - #else |
249 | | - bool c_draw = false, t_draw = false, i_draw = false; |
250 | | - constexpr float tc = 0, tt = 0; |
251 | | - constexpr uint8_t ta = 0; |
252 | | - #endif |
253 | | - |
254 | | - #if HAS_HEATED_BED && HAS_LEVELING |
255 | | - if (isBed) { |
256 | | - i_draw |= (planner.leveling_active != old_leveling_on); |
257 | | - old_leveling_on = planner.leveling_active; |
258 | | - } |
259 | | - #endif |
| 224 | + #endif |
| 225 | + } |
260 | 226 |
|
261 | 227 | // Draw target temperature, if needed |
262 | | - if (!ui.did_first_redraw || t_draw) { |
| 228 | + if (t_draw) { |
263 | 229 | dwin_string.set(i16tostr3rj(tt + 0.5)); |
264 | 230 | dwin_string.add(LCD_STR_DEGREE); |
265 | 231 | DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string())); |
266 | 232 | } |
267 | 233 |
|
268 | 234 | // Draw heater icon with on / off / leveled states |
269 | | - if (!ui.did_first_redraw || i_draw) { |
| 235 | + if (i_draw) { |
270 | 236 | const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff; |
271 | 237 | DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2); |
272 | 238 | } |
273 | 239 |
|
274 | 240 | // Draw current temperature, if needed |
275 | | - if (!ui.did_first_redraw || c_draw) { |
| 241 | + if (c_draw) { |
276 | 242 | dwin_string.set(i16tostr3rj(tc + 0.5)); |
277 | 243 | dwin_string.add(LCD_STR_DEGREE); |
278 | 244 | DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 70, S(dwin_string.string())); |
@@ -414,7 +380,7 @@ void MarlinUI::draw_status_screen() { |
414 | 380 | } |
415 | 381 | DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string())); |
416 | 382 | } |
417 | | - else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) { |
| 383 | + else if (!ui.did_first_redraw || old_is_printing != print_job_timer.isRunning()) { |
418 | 384 | dwin_string.set(F(" ")); |
419 | 385 | DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string())); |
420 | 386 | } |
@@ -470,7 +436,7 @@ void MarlinUI::draw_status_screen() { |
470 | 436 | draw_status_message(blink); |
471 | 437 |
|
472 | 438 | ui.did_first_redraw = true; |
473 | | - ui.old_is_printing = print_job_timer.isRunning(); |
| 439 | + old_is_printing = print_job_timer.isRunning(); |
474 | 440 | } |
475 | 441 |
|
476 | 442 | #endif // IS_DWIN_MARLINUI |
0 commit comments