🩹 Fan Menu / Status fixes

Followup to #21888
This commit is contained in:
Scott Lahteine 2023-03-15 19:13:09 -05:00
parent 10983d0cfe
commit 65b97438fa
8 changed files with 80 additions and 116 deletions

View file

@ -195,7 +195,7 @@ void MarlinUI::draw_status_message(const bool blink) {
}
const bool hash_changed = hash != old_hash;
old_hash = hash;
return hash_changed || !ui.did_first_redraw;
return hash_changed || !did_first_redraw;
};
#if ENABLED(STATUS_MESSAGE_SCROLLING)

View file

@ -61,19 +61,25 @@
#define STATUS_CHR_WIDTH 14
#define STATUS_CHR_HEIGHT 28
bool old_is_printing;
//
// Before homing, blink '123' <-> '???'.
// Homed but unknown... '123' <-> ' '.
// Homed and known, display constantly.
//
FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) {
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
uint8_t vallen = utf8_strlen(value);
if (!ui.did_first_redraw) {
void _draw_axis_value(const AxisEnum axis, const char *value, const bool blink, const uint16_t x, const uint16_t y) {
const bool x_redraw = !ui.did_first_redraw || old_is_printing != print_job_timer.isRunning();
if (x_redraw) {
dwin_string.set('X' + axis);
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x + (vallen * 14 - 14) / 2, y + 2, S(dwin_string.string()));
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black,
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
x + (utf8_strlen(value) * 14 - 14) / 2, y + 2
#else
x, y
#endif
, S(dwin_string.string())
);
}
dwin_string.set();
@ -87,46 +93,22 @@ FORCE_INLINE void _draw_axis_value(const AxisEnum axis, const char *value, const
dwin_string.add(value);
// For E_TOTAL there may be some characters to cover up
if (BOTH(DWIN_MARLINUI_PORTRAIT, LCD_SHOW_E_TOTAL) && axis == X_AXIS)
if (TERN0(LCD_SHOW_E_TOTAL, x_redraw && axis == X_AXIS))
dwin_string.add(F(" "));
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y + 32, S(dwin_string.string()));
#else // !DWIN_MARLINUI_PORTRAIT
if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
dwin_string.set('X' + axis);
DWIN_Draw_String(true, font16x32, Color_IconBlue, Color_Bg_Black, x, y, S(dwin_string.string()));
}
dwin_string.set();
if (blink)
dwin_string.add(value);
else {
if (!TEST(axes_homed, axis))
while (const char c = *value++) dwin_string.add(c <= '.' ? c : '?');
else {
#if NONE(HOME_AFTER_DEACTIVATE, DISABLE_REDUCED_ACCURACY_WARNING)
if (!TEST(axes_trusted, axis))
dwin_string.add(TERN1(DWIN_MARLINUI_PORTRAIT, axis == Z_AXIS) ? PSTR(" ") : PSTR(" "));
else
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black,
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
x, y + 32
#else
x + 32, y + 4
#endif
dwin_string.add(value);
}
}
// For E_TOTAL there may be some characters to cover up
if (ENABLED(LCD_SHOW_E_TOTAL) && (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) && axis == X_AXIS)
dwin_string.add(F(" "));
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x + 32, y + 4, S(dwin_string.string()));
#endif // !DWIN_MARLINUI_PORTRAIT
, S(dwin_string.string())
);
}
#if ENABLED(LCD_SHOW_E_TOTAL)
FORCE_INLINE void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) {
void _draw_e_value(const_float_t value, const uint16_t x, const uint16_t y) {
const uint8_t scale = value >= 100000.0f ? 10 : 1; // show cm after 99,999mm
#if ENABLED(DWIN_MARLINUI_PORTRAIT)
@ -207,72 +189,56 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x
#endif
#endif
#if HAS_HOTEND && HAS_HEATED_BED
float tc, tt;
bool c_draw, t_draw, i_draw, ta;
const bool isBed = heater < 0;
celsius_float_t tc = 0, tt = 0;
bool isBed = (DISABLED(HAS_HOTEND) && ENABLED(HAS_HEATED_BED)) || (BOTH(HAS_HOTEND, HAS_HEATED_BED) && heater < 0),
ta = false, c_draw, t_draw, i_draw;
c_draw = t_draw = i_draw = !ui.did_first_redraw;
if (isBed) {
#if HAS_HEATED_BED
tc = thermalManager.degBed();
tt = thermalManager.degTargetBed();
ta = thermalManager.isHeatingBed();
c_draw = tc != old_bed_temp;
t_draw = tt != old_bed_target;
i_draw = ta != old_bed_on;
c_draw |= tc != old_bed_temp;
t_draw |= tt != old_bed_target;
i_draw |= ta != old_bed_on;
old_bed_temp = tc;
old_bed_target = tt;
old_bed_on = ta;
#if HAS_LEVELING
i_draw |= planner.leveling_active != old_leveling_on;
old_leveling_on = planner.leveling_active;
#endif
#endif
}
else {
#if HAS_HOTEND
tc = thermalManager.degHotend(heater);
tt = thermalManager.degTargetHotend(heater);
ta = thermalManager.isHeatingHotend(heater);
c_draw = tc != old_temp[heater];
t_draw = tt != old_target[heater];
i_draw = ta != old_on[heater];
c_draw |= tc != old_temp[heater];
t_draw |= tt != old_target[heater];
i_draw |= ta != old_on[heater];
old_temp[heater] = tc;
old_target[heater] = tt;
old_on[heater] = ta;
}
#elif HAS_HOTEND
constexpr bool isBed = false;
const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater);
const uint8_t ta = thermalManager.isHeatingHotend(heater);
bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater];
old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta;
#elif HAS_HEATED_BED
constexpr bool isBed = true;
const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed();
const uint8_t ta = thermalManager.isHeatingBed();
bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on;
old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta;
#else
bool c_draw = false, t_draw = false, i_draw = false;
constexpr float tc = 0, tt = 0;
constexpr uint8_t ta = 0;
#endif
#if HAS_HEATED_BED && HAS_LEVELING
if (isBed) {
i_draw |= (planner.leveling_active != old_leveling_on);
old_leveling_on = planner.leveling_active;
}
#endif
// Draw target temperature, if needed
if (!ui.did_first_redraw || t_draw) {
if (t_draw) {
dwin_string.set(i16tostr3rj(tt + 0.5));
dwin_string.add(LCD_STR_DEGREE);
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, x, y, S(dwin_string.string()));
}
// Draw heater icon with on / off / leveled states
if (!ui.did_first_redraw || i_draw) {
if (i_draw) {
const uint8_t ico = isBed ? (TERN0(HAS_LEVELING, planner.leveling_active) ? ICON_BedLevelOff : ICON_BedOff) : ICON_HotendOff;
DWIN_ICON_Show(ICON, ico + ta, x, y + STATUS_CHR_HEIGHT + 2);
}
// Draw current temperature, if needed
if (!ui.did_first_redraw || c_draw) {
if (c_draw) {
dwin_string.set(i16tostr3rj(tc + 0.5));
dwin_string.add(LCD_STR_DEGREE);
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() {
}
DWIN_Draw_String(true, font14x28, Color_White, Color_Bg_Black, 378, 170, S(dwin_string.string()));
}
else if (!ui.did_first_redraw || ui.old_is_printing != print_job_timer.isRunning()) {
else if (!ui.did_first_redraw || old_is_printing != print_job_timer.isRunning()) {
dwin_string.set(F(" "));
DWIN_Draw_String(true, font14x28, Color_IconBlue, Color_Bg_Black, 336, 170, S(dwin_string.string()));
}
@ -470,7 +436,7 @@ void MarlinUI::draw_status_screen() {
draw_status_message(blink);
ui.did_first_redraw = true;
ui.old_is_printing = print_job_timer.isRunning();
old_is_printing = print_job_timer.isRunning();
}
#endif // IS_DWIN_MARLINUI

View file

@ -908,11 +908,3 @@ namespace Language_en {
LSTR DGUS_MSG_FILAMENT_RUNOUT = _UxGT("Filament runout E%d");
}
#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif

View file

@ -351,7 +351,6 @@ void MarlinUI::init() {
#if IS_DWIN_MARLINUI
bool MarlinUI::did_first_redraw;
bool MarlinUI::old_is_printing;
#endif
#if ENABLED(SDSUPPORT)

View file

@ -503,7 +503,6 @@ public:
#if IS_DWIN_MARLINUI
static bool did_first_redraw;
static bool old_is_printing;
#endif
#if EITHER(BABYSTEP_GFX_OVERLAY, MESH_EDIT_GFX_OVERLAY)

View file

@ -555,6 +555,14 @@ class MenuItem_bool : public MenuEditItemBase {
#define EDIT_EXTRA_FAN_SPEED(...)
#endif
#if FAN_COUNT == 1
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED
#else
#define MSG_FIRST_FAN_SPEED MSG_FAN_SPEED_N
#define MSG_EXTRA_FIRST_FAN_SPEED MSG_EXTRA_FAN_SPEED_N
#endif
#define _FAN_EDIT_ITEMS(F,L) do{ \
editable.uint8 = thermalManager.fan_speed[F]; \
EDIT_ITEM_FAST_N(percent, F, MSG_##L, &editable.uint8, 0, 255, on_fan_update); \

View file

@ -156,37 +156,37 @@ void menu_tune() {
#if HAS_FAN0
_FAN_EDIT_ITEMS(0,FIRST_FAN_SPEED);
#endif
#if HAS_FAN1
#if HAS_FAN1 && REDUNDANT_PART_COOLING_FAN != 1
FAN_EDIT_ITEMS(1);
#elif SNFAN(1)
singlenozzle_item(1);
#endif
#if HAS_FAN2
#if HAS_FAN2 && REDUNDANT_PART_COOLING_FAN != 2
FAN_EDIT_ITEMS(2);
#elif SNFAN(2)
singlenozzle_item(2);
#endif
#if HAS_FAN3
#if HAS_FAN3 && REDUNDANT_PART_COOLING_FAN != 3
FAN_EDIT_ITEMS(3);
#elif SNFAN(3)
singlenozzle_item(3);
#endif
#if HAS_FAN4
#if HAS_FAN4 && REDUNDANT_PART_COOLING_FAN != 4
FAN_EDIT_ITEMS(4);
#elif SNFAN(4)
singlenozzle_item(4);
#endif
#if HAS_FAN5
#if HAS_FAN5 && REDUNDANT_PART_COOLING_FAN != 5
FAN_EDIT_ITEMS(5);
#elif SNFAN(5)
singlenozzle_item(5);
#endif
#if HAS_FAN6
#if HAS_FAN6 && REDUNDANT_PART_COOLING_FAN != 6
FAN_EDIT_ITEMS(6);
#elif SNFAN(6)
singlenozzle_item(6);
#endif
#if HAS_FAN7
#if HAS_FAN7 && REDUNDANT_PART_COOLING_FAN != 7
FAN_EDIT_ITEMS(7);
#elif SNFAN(7)
singlenozzle_item(7);

View file

@ -27,7 +27,7 @@
#include "touch.h"
#include "../marlinui.h" // for ui methods
#include "../menu/menu_item.h" // for touch_screen_calibration
#include "../menu/menu_item.h" // for MSG_FIRST_FAN_SPEED
#include "../../module/temperature.h"
#include "../../module/planner.h"