From efc55e748874b6e0cafb1ecba18081c3d8bb4d69 Mon Sep 17 00:00:00 2001 From: ellensp <530024+ellensp@users.noreply.github.com> Date: Fri, 1 Apr 2022 18:49:21 +1300 Subject: [PATCH 1/3] fix comple issue --- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 92 ++++++++++--------- 1 file changed, 49 insertions(+), 43 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index c2948048c119..d9fa84a5ec1f 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -196,9 +196,11 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #elif HAS_HOTEND #define HOTEND_STATS 1 #endif - static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), + #if HAS_HEATED_BED + static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); - static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); + static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); + #endif #endif #if HAS_HEATED_BED @@ -237,10 +239,12 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x constexpr bool isBed = false; const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); const uint8_t ta = thermalManager.isHeatingHotend(heater); - const bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; - old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; + #if HAS_HEATED_BED + old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; + #endif #elif HAS_HEATED_BED constexpr bool isBed = true; + const bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); const uint8_t ta = thermalManager.isHeatingBed(); bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; @@ -251,18 +255,18 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; #endif - if (!ui.did_first_redraw || t_draw) { + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,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())); } - if (!ui.did_first_redraw || i_draw){ + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,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); } - if (!ui.did_first_redraw || c_draw) { + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,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())); @@ -412,43 +416,45 @@ void MarlinUI::draw_status_screen() { // // Progress Bar // - constexpr int16_t pb_margin = 5, - pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), - pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), - pb_right = LCD_PIXEL_WIDTH - pb_margin, - pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), - pb_top = pb_bottom - pb_height, - pb_width = pb_right - pb_left; - - const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); - - if (!ui.did_first_redraw) - DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline - - static uint16_t old_solid = 50; - const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; - const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; - - if (p_draw) { - //if (pb_solid) - DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part - - //if (pb_solid < old_solid) - DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest - - #if ENABLED(SHOW_SD_PERCENT) - dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); - dwin_string.add(PSTR("%")); - DWIN_Draw_String( - false, font16x32, Percent_Color, Color_Bg_Black, - pb_left + (pb_width - dwin_string.length() * 16) / 2, - pb_top + (pb_height - 32) / 2, - S(dwin_string.string()) - ); - #endif + #if HAS_PRINT_PROGRESS + constexpr int16_t pb_margin = 5, + pb_left = pb_margin + TERN(DWIN_MARLINUI_PORTRAIT, 0, 90), + pb_height = TERN(DWIN_MARLINUI_PORTRAIT, 60, 20), + pb_right = LCD_PIXEL_WIDTH - pb_margin, + pb_bottom = TERN(DWIN_MARLINUI_PORTRAIT, 410, 220), + pb_top = pb_bottom - pb_height, + pb_width = pb_right - pb_left; + + const progress_t progress = TERN(HAS_PRINT_PROGRESS_PERMYRIAD, get_progress_permyriad, get_progress_percent)(); + + if (!ui.did_first_redraw) + DWIN_Draw_Rectangle(0, Select_Color, pb_left, pb_top, pb_right, pb_bottom); // Outline + + static uint16_t old_solid = 50; + const uint16_t pb_solid = (pb_width - 2) * (progress / (PROGRESS_SCALE)) * 0.01f; + const bool p_draw = !ui.did_first_redraw || old_solid != pb_solid; + + if (p_draw) { + //if (pb_solid) + DWIN_Draw_Rectangle(1, Select_Color, pb_left + 1, pb_top + 1, pb_left + pb_solid, pb_bottom - 1); // Fill the solid part + + //if (pb_solid < old_solid) + DWIN_Draw_Rectangle(1, Color_Bg_Black, pb_left + 1 + pb_solid, pb_top + 1, pb_right - 1, pb_bottom - 1); // Erase the rest + + #if ENABLED(SHOW_SD_PERCENT) + dwin_string.set(TERN(PRINT_PROGRESS_SHOW_DECIMALS, permyriadtostr4(progress), ui8tostr3rj(progress / (PROGRESS_SCALE)))); + dwin_string.add(PSTR("%")); + DWIN_Draw_String( + false, font16x32, Percent_Color, Color_Bg_Black, + pb_left + (pb_width - dwin_string.length() * 16) / 2, + pb_top + (pb_height - 32) / 2, + S(dwin_string.string()) + ); + #endif - old_solid = pb_solid; - } + old_solid = pb_solid; + } + #endif // HAS_PRINT_PROGRESS // // Status Message From 54c85c1853ef64aced25ed6bb179b0f50a7a69a9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 1 Apr 2022 02:17:19 -0500 Subject: [PATCH 2/3] sp --- Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index d9fa84a5ec1f..b8e098f886c2 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -255,18 +255,18 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x old_bed_temp = tc; old_bed_target = tt; old_bed_on = ta; #endif - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,t_draw)) { + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, 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())); } - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,i_draw)){ + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, 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); } - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED,c_draw)) { + if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, 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())); From 05346f62a76c559bd5bf9b22d1bc29b21ab27079 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 1 Apr 2022 02:21:49 -0500 Subject: [PATCH 3/3] move draw flags around --- .../lcd/e3v2/marlinui/ui_status_480x272.cpp | 65 ++++++++++--------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp index b8e098f886c2..822b73a44c72 100644 --- a/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp +++ b/Marlin/src/lcd/e3v2/marlinui/ui_status_480x272.cpp @@ -193,14 +193,12 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #define HOTEND_STATS 3 #elif HOTENDS > 1 #define HOTEND_STATS 2 - #elif HAS_HOTEND + #else #define HOTEND_STATS 1 #endif - #if HAS_HEATED_BED - static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), - old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); - static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); - #endif + static celsius_t old_temp[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500), + old_target[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, 500); + static bool old_on[HOTEND_STATS] = ARRAY_N_1(HOTEND_STATS, false); #endif #if HAS_HEATED_BED @@ -213,24 +211,23 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x #if HAS_HOTEND && HAS_HEATED_BED const bool isBed = heater < 0; - const float tc = isBed ? thermalManager.degBed() : thermalManager.degHotend(heater), - tt = isBed ? thermalManager.degTargetBed() : thermalManager.degTargetHotend(heater); - const bool ta = isBed ? thermalManager.isHeatingBed() : thermalManager.isHeatingHotend(heater); - - bool c_draw = tc != (isBed ? old_bed_temp : old_temp[heater]), - t_draw = tt != (isBed ? old_bed_target : old_target[heater]), - i_draw = ta != (isBed ? old_bed_on : old_on[heater]); - + bool c_draw, t_draw, i_draw; if (isBed) { - #if HAS_LEVELING - if (!i_draw && planner.leveling_active != old_leveling_on) i_draw = true; - old_leveling_on = planner.leveling_active; - #endif + const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); + const bool ta = thermalManager.isHeatingBed(); + 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 { + const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); + const bool ta = thermalManager.isHeatingHotend(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; @@ -239,34 +236,42 @@ FORCE_INLINE void _draw_heater_status(const heater_id_t heater, const uint16_t x constexpr bool isBed = false; const float tc = thermalManager.degHotend(heater), tt = thermalManager.degTargetHotend(heater); const uint8_t ta = thermalManager.isHeatingHotend(heater); - #if HAS_HEATED_BED - old_temp[heater] = tc; old_target[heater] = tt; old_on[heater] = ta; - #endif + 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 bool c_draw = tc != old_bed_temp, t_draw = tt != old_bed_target, i_draw = ta != old_bed_on; const float tc = thermalManager.degBed(), tt = thermalManager.degTargetBed(); const uint8_t ta = thermalManager.isHeatingBed(); - bool c_draw = tc != old_temp[heater], t_draw = tt != old_target[heater], i_draw = ta != old_on[heater]; - #if HAS_LEVELING - if (!idraw && planner.leveling_active != old_leveling_on) i_draw = true; - old_leveling_on = tl; - #endif + 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 - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, t_draw)) { + // Draw target temperature, if needed + if (!ui.did_first_redraw || 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())); } - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, i_draw)){ + // Draw heater icon with on / off / leveled states + if (!ui.did_first_redraw || 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); } - if (!ui.did_first_redraw || TERN0(HAS_HEATED_BED, c_draw)) { + // Draw current temperature, if needed + if (!ui.did_first_redraw || 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()));