Skip to content

Commit eb5d1fb

Browse files
committed
🩹 Fan Menu / Status fixes
Followup to MarlinFirmware#21888
1 parent 9e9c6bd commit eb5d1fb

File tree

8 files changed

+82
-118
lines changed

8 files changed

+82
-118
lines changed

Marlin/src/lcd/e3v2/marlinui/ui_common.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ void MarlinUI::draw_status_message(const bool blink) {
195195
}
196196
const bool hash_changed = hash != old_hash;
197197
old_hash = hash;
198-
return hash_changed || !ui.did_first_redraw;
198+
return hash_changed || !did_first_redraw;
199199
};
200200

201201
#if ENABLED(STATUS_MESSAGE_SCROLLING)

Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp

Lines changed: 65 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -61,72 +61,54 @@
6161
#define STATUS_CHR_WIDTH 14
6262
#define STATUS_CHR_HEIGHT 28
6363

64+
bool old_is_printing;
65+
6466
//
6567
// Before homing, blink '123' <-> '???'.
6668
// Homed but unknown... '123' <-> ' '.
6769
// Homed and known, display constantly.
6870
//
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+
}
12384

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+
);
125107
}
126108

127109
#if ENABLED(LCD_SHOW_E_TOTAL)
128110

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) {
130112
const uint8_t scale = value >= 100000.0f ? 10 : 1; // show cm after 99,999mm
131113

132114
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
@@ -207,72 +189,56 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
207189
#endif
208190
#endif
209191

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
215198
tc = thermalManager.degBed();
216199
tt = thermalManager.degTargetBed();
217200
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;
221204
old_bed_temp = tc;
222205
old_bed_target = tt;
223206
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
226215
tc = thermalManager.degHotend(heater);
227216
tt = thermalManager.degTargetHotend(heater);
228217
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];
232221
old_temp[heater] = tc;
233222
old_target[heater] = tt;
234223
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+
}
260226

261227
// Draw target temperature, if needed
262-
if (!ui.did_first_redraw || t_draw) {
228+
if (t_draw) {
263229
dwin_string.set(i16tostr3rj(tt + 0.5));
264230
dwin_string.add(LCD_STR_DEGREE);
265231
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string()));
266232
}
267233

268234
// Draw heater icon with on / off / leveled states
269-
if (!ui.did_first_redraw || i_draw) {
235+
if (i_draw) {
270236
const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff;
271237
DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2);
272238
}
273239

274240
// Draw current temperature, if needed
275-
if (!ui.did_first_redraw || c_draw) {
241+
if (c_draw) {
276242
dwin_string.set(i16tostr3rj(tc + 0.5));
277243
dwin_string.add(LCD_STR_DEGREE);
278244
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() {
414380
}
415381
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
416382
}
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()) {
418384
dwin_string.set(F(" "));
419385
DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
420386
}
@@ -470,7 +436,7 @@ void MarlinUI::draw_status_screen() {
470436
draw_status_message(blink);
471437

472438
ui.did_first_redraw = true;
473-
ui.old_is_printing = print_job_timer.isRunning();
439+
old_is_printing = print_job_timer.isRunning();
474440
}
475441

476442
#endif // IS_DWIN_MARLINUI

Marlin/src/lcd/language/language_en.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -908,11 +908,3 @@ namespace Language_en {
908908
LSTR DGUS_MSG_FILAMENT_RUNOUT = _UxGT("Filament runout E%d");
909909

910910
}
911-
912-
#if FAN_COUNT == 1
913-
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
914-
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
915-
#else
916-
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
917-
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
918-
#endif

Marlin/src/lcd/marlinui.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,6 @@ void MarlinUI::init() {
351351

352352
#if IS_DWIN_MARLINUI
353353
bool MarlinUI::did_first_redraw;
354-
bool MarlinUI::old_is_printing;
355354
#endif
356355

357356
#if ENABLED(SDSUPPORT)

Marlin/src/lcd/marlinui.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,6 @@ class MarlinUI {
503503

504504
#if IS_DWIN_MARLINUI
505505
static bool did_first_redraw;
506-
static bool old_is_printing;
507506
#endif
508507

509508
#if EITHER(BABYSTEP_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)

Marlin/src/lcd/menu/menu_item.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,14 @@ class MenuItem_bool : public MenuEditItemBase {
555555
#define EDIT_EXTRA_FAN_SPEED(...)
556556
#endif
557557

558+
#if FAN_COUNT == 1
559+
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
560+
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
561+
#else
562+
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
563+
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
564+
#endif
565+
558566
#define _FAN_EDIT_ITEMS(F,L) do{ \
559567
editable.uint8 = thermalManager.fan_speed[F]; \
560568
EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \

Marlin/src/lcd/menu/menu_tune.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -156,37 +156,37 @@ void menu_tune() {
156156
#if HAS_FAN0
157157
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
158158
#endif
159-
#if HAS_FAN1
159+
#if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1
160160
FAN_EDIT_ITEMS(1);
161161
#elif SNFAN(1)
162162
singlenozzle_item(1);
163163
#endif
164-
#if HAS_FAN2
164+
#if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2
165165
FAN_EDIT_ITEMS(2);
166166
#elif SNFAN(2)
167167
singlenozzle_item(2);
168168
#endif
169-
#if HAS_FAN3
169+
#if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3
170170
FAN_EDIT_ITEMS(3);
171171
#elif SNFAN(3)
172172
singlenozzle_item(3);
173173
#endif
174-
#if HAS_FAN4
174+
#if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4
175175
FAN_EDIT_ITEMS(4);
176176
#elif SNFAN(4)
177177
singlenozzle_item(4);
178178
#endif
179-
#if HAS_FAN5
179+
#if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5
180180
FAN_EDIT_ITEMS(5);
181181
#elif SNFAN(5)
182182
singlenozzle_item(5);
183183
#endif
184-
#if HAS_FAN6
184+
#if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6
185185
FAN_EDIT_ITEMS(6);
186186
#elif SNFAN(6)
187187
singlenozzle_item(6);
188188
#endif
189-
#if HAS_FAN7
189+
#if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7
190190
FAN_EDIT_ITEMS(7);
191191
#elif SNFAN(7)
192192
singlenozzle_item(7);

Marlin/src/lcd/tft/touch.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include "touch.h"
2828

2929
#include "../marlinui.h" // for ui methods
30-
#include "../menu/menu_item.h" // for touch_screen_calibration
30+
#include "../menu/menu_item.h" // for MSG_FIRST_FAN_SPEED
3131

3232
#include "../../module/temperature.h"
3333
#include "../../module/planner.h"

0 commit comments

Comments
 (0)