diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp index cce94621d54b1..ddacecd3073a0 100644 --- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp +++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp @@ -227,27 +227,20 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co UNUSED(blink); #endif - #if ENABLED(STATUS_HEAT_POWER) - const uint16_t power = thermalManager.getHeaterPower(heater_id); - const bool isHeat = power > 0; - #else - const bool isHeat = HOTEND_ALT(heater_id); - #endif + const bool isHeat = HOTEND_ALT(heater_id); const uint8_t tx = STATUS_HOTEND_TEXT_X(heater_id); const celsius_t temp = thermalManager.wholeDegHotend(heater_id), target = thermalManager.degTargetHotend(heater_id); - - #if DISABLED(STATUS_HOTEND_ANIM) - #define STATIC_HOTEND true - #define HOTEND_DOT isHeat - #else - #define STATIC_HOTEND false - #define HOTEND_DOT false + #if ENABLED(STATUS_HEAT_POWER) + const uint16_t power = thermalManager.getHeaterPower(heater_id); #endif + #define STATIC_HOTEND DISABLED(STATUS_HOTEND_ANIM) + #define HOTEND_DOT TERN(STATUS_HOTEND_ANIM, false, isHeat) + #if ENABLED(STATUS_HOTEND_NUMBERLESS) #define OFF_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend_b_bmp, status_hotend_a_bmp) #define ON_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend_a_bmp, status_hotend_b_bmp) @@ -278,13 +271,14 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2) + uint8_t tall = 0; #if ENABLED(STATUS_HEAT_POWER) - // integer round up. At least 1 pixel height on minimal PWM - uint8_t tall = (power <= 0) ? 0 : ((power >= 127) ? BAR_TALL : (uint16_t((uint8_t(power) * BAR_TALL) + 127U) / 128U)); - #elif ENABLED(STATUS_HEAT_PERCENT) + // Rounded int. At least 1 pixel tall on minimal PWM. + tall = power ? (power >= 127 ? BAR_TALL : (uint16_t((uint8_t(power) * BAR_TALL) + 127U) / 128U)) : 0; + #elif ENABLED(STATUS_HEAT_PERCENT) const float prop = target - 20, perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0; - uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f); + tall = uint8_t(perc * BAR_TALL + 0.5f); #endif // Draw hotend bitmap, either whole or split by the heating percent @@ -292,13 +286,17 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co bw = STATUS_HOTEND_BYTEWIDTH(heater_id); #if EITHER(STATUS_HEAT_PERCENT, STATUS_HEAT_POWER) NOMORE(tall, BAR_TALL); - if (isHeat && tall <= BAR_TALL) { + const bool draw_partial = isHeat && tall < BAR_TALL; + if (draw_partial) { const uint8_t ph = STATUS_HEATERS_HEIGHT - 1 - tall; u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, ph, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), false)); u8g.drawBitmapP(hx, STATUS_HEATERS_Y + ph, bw, tall + 1, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), true) + ph * bw); } - else + #else + constexpr bool draw_partial = false; #endif + + if (!draw_partial) u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), isHeat)); } // PAGE_CONTAINS @@ -340,31 +338,24 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co const celsius_t temp = thermalManager.wholeDegBed(), target = thermalManager.degTargetBed(); - #if ENABLED(STATUS_HEAT_POWER) - const uint16_t power = thermalManager.getHeaterPower(H_BED); - const bool isHeat = target > 0; - #elif ENABLED(STATUS_HEAT_PERCENT) || DISABLED(STATUS_BED_ANIM) + #if EITHER(STATUS_HEAT_PERCENT, STATUS_HEAT_POWER) || DISABLED(STATUS_BED_ANIM) const bool isHeat = BED_ALT(); #endif - #if DISABLED(STATUS_BED_ANIM) - #define STATIC_BED true - #define BED_DOT isHeat - #else - #define STATIC_BED false - #define BED_DOT false - #endif + #define STATIC_BED DISABLED(STATUS_BED_ANIM) + #define BED_DOT TERN(STATUS_BED_ANIM, false, isHeat) if (PAGE_CONTAINS(STATUS_HEATERS_Y, STATUS_HEATERS_BOT)) { #define BAR_TALL (STATUS_HEATERS_HEIGHT - 2) + uint8_t tall = 0; #if ENABLED(STATUS_HEAT_POWER) - uint8_t tall = (power <= 0) ? 0 : ((power >= 127) ? BAR_TALL : (uint16_t((uint8_t(power) * BAR_TALL) + 127U) / 128U)); + tall = power ? (power >= 127) ? BAR_TALL : uint16_t((uint8_t(power) * BAR_TALL) + 127U) / 128U : 0; #elif ENABLED(STATUS_HEAT_PERCENT) const float prop = target - 20, perc = prop > 0 && temp >= 20 ? (temp - 20) / prop : 0; - uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f); + tall = uint8_t(perc * BAR_TALL + 0.5f); #endif // Draw a heating progress bar, if specified @@ -533,9 +524,11 @@ void MarlinUI::draw_status_screen() { #if ANIM_HBCC uint8_t new_bits = 0; #if ANIM_HOTEND - HOTEND_LOOP() if (thermalManager.isHeatingHotend(e)) SBI(new_bits, DRAWBIT_HOTEND + e); + HOTEND_LOOP() if (thermalManager.TERN(STATUS_HEAT_POWER, getHeaterPower, isHeatingHotend)(e)) SBI(new_bits, DRAWBIT_HOTEND + e); + #endif + #if ANIM_BED + if (thermalManager.TERN(STATUS_HEAT_POWER, getHeaterPower(H_BED), isHeatingBed())) SBI(new_bits, DRAWBIT_BED); #endif - if (TERN0(ANIM_BED, thermalManager.isHeatingBed())) SBI(new_bits, DRAWBIT_BED); #if DO_DRAW_CHAMBER && HAS_HEATED_CHAMBER if (thermalManager.isHeatingChamber()) SBI(new_bits, DRAWBIT_CHAMBER); #endif