From 6bf6973e9d02caab4dab8190e1191b7675cd8549 Mon Sep 17 00:00:00 2001
From: ellensp <ellensp@hotmail.com>
Date: Tue, 22 Jun 2021 08:09:21 +1200
Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20heater=20display=20options?=
 =?UTF-8?q?/compile=20(#22185)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 Marlin/Configuration_adv.h                 |  2 +-
 Marlin/src/inc/SanityCheck.h               |  4 +++
 Marlin/src/lcd/dogm/status/hotend.h        | 35 +++++++++++++------
 Marlin/src/lcd/dogm/status_screen_DOGM.cpp | 40 +++++++++-------------
 4 files changed, 45 insertions(+), 36 deletions(-)

diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h
index 7b642cc3556..ed1a672e485 100644
--- a/Marlin/Configuration_adv.h
+++ b/Marlin/Configuration_adv.h
@@ -1594,7 +1594,7 @@
    */
   //#define STATUS_COMBINE_HEATERS    // Use combined heater images instead of separate ones
   //#define STATUS_HOTEND_NUMBERLESS  // Use plain hotend icons instead of numbered ones (with 2+ hotends)
-  #define STATUS_HOTEND_INVERTED      // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM)
+  #define STATUS_HOTEND_INVERTED      // Show solid nozzle bitmaps when heating (Requires STATUS_HOTEND_ANIM for numbered hotends)
   #define STATUS_HOTEND_ANIM          // Use a second bitmap to indicate hotend heating
   #define STATUS_BED_ANIM             // Use a second bitmap to indicate bed heating
   #define STATUS_CHAMBER_ANIM         // Use a second bitmap to indicate chamber heating
diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h
index 7a178db3aa6..dd71364ee76 100644
--- a/Marlin/src/inc/SanityCheck.h
+++ b/Marlin/src/inc/SanityCheck.h
@@ -1039,6 +1039,10 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
     #error "EXTRUDERS must be 1 with HEATERS_PARALLEL."
   #endif
 
+  #if ENABLED(STATUS_HOTEND_INVERTED) && NONE(STATUS_HOTEND_NUMBERLESS, STATUS_HOTEND_ANIM)
+    #error "With multiple hotends STATUS_HOTEND_INVERTED requires STATUS_HOTEND_ANIM or STATUS_HOTEND_NUMBERLESS."
+  #endif
+
   #if ENABLED(TOOLCHANGE_FILAMENT_SWAP)
     #ifndef TOOLCHANGE_FS_LENGTH
       #error "TOOLCHANGE_FILAMENT_SWAP requires TOOLCHANGE_FS_LENGTH."
diff --git a/Marlin/src/lcd/dogm/status/hotend.h b/Marlin/src/lcd/dogm/status/hotend.h
index 3a6e02acb60..aac29da4512 100644
--- a/Marlin/src/lcd/dogm/status/hotend.h
+++ b/Marlin/src/lcd/dogm/status/hotend.h
@@ -39,20 +39,33 @@
 
 #define STATUS_HOTEND1_WIDTH  16
 
-#if STATUS_HOTEND_BITMAPS == 1 || ENABLED(STATUS_HOTEND_NUMBERLESS)
+#if STATUS_HOTEND_BITMAPS == 1 || defined(STATUS_HOTEND_NUMBERLESS)
 
   const unsigned char status_hotend_a_bmp[] PROGMEM = {
     B00011111,B11100000,
-    B00111111,B11110000,
-    B00111111,B11110000,
-    B00111111,B11110000,
-    B00011111,B11100000,
-    B00011111,B11100000,
-    B00111111,B11110000,
-    B00111111,B11110000,
-    B00111111,B11110000,
-    B00001111,B11000000,
-    B00000111,B10000000,
+    #if defined(STATUS_HOTEND_INVERTED) && !defined(STATUS_HOTEND_ANIM)
+      B00100000,B00010000,
+      B00100000,B00010000,
+      B00100000,B00010000,
+      B00010000,B00100000,
+      B00010000,B00100000,
+      B00100000,B00010000,
+      B00100000,B00010000,
+      B00110000,B00110000,
+      B00001000,B01000000,
+      B00000100,B10000000,
+    #else
+      B00111111,B11110000,
+      B00111111,B11110000,
+      B00111111,B11110000,
+      B00011111,B11100000,
+      B00011111,B11100000,
+      B00111111,B11110000,
+      B00111111,B11110000,
+      B00111111,B11110000,
+      B00001111,B11000000,
+      B00000111,B10000000,
+    #endif
     B00000011,B00000000
   };
 
diff --git a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
index 8309c3a00e8..d58be4dbaf5 100644
--- a/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
+++ b/Marlin/src/lcd/dogm/status_screen_DOGM.cpp
@@ -236,18 +236,12 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co
       #define HOTEND_DOT    false
     #endif
 
-    #if ANIM_HOTEND && BOTH(STATUS_HOTEND_INVERTED, STATUS_HOTEND_NUMBERLESS)
-      #define OFF_BMP(N) status_hotend_b_bmp
-      #define ON_BMP(N)  status_hotend_a_bmp
-    #elif ANIM_HOTEND && DISABLED(STATUS_HOTEND_INVERTED) && ENABLED(STATUS_HOTEND_NUMBERLESS)
-      #define OFF_BMP(N) status_hotend_a_bmp
-      #define ON_BMP(N)  status_hotend_b_bmp
-    #elif BOTH(ANIM_HOTEND, STATUS_HOTEND_INVERTED)
-      #define OFF_BMP(N) status_hotend##N##_b_bmp
-      #define ON_BMP(N)  status_hotend##N##_a_bmp
+    #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)
     #else
-      #define OFF_BMP(N) status_hotend##N##_a_bmp
-      #define ON_BMP(N)  status_hotend##N##_b_bmp
+      #define OFF_BMP(N) TERN(STATUS_HOTEND_INVERTED, status_hotend##N##_b_bmp, status_hotend##N##_a_bmp)
+      #define ON_BMP(N)  TERN(STATUS_HOTEND_INVERTED, status_hotend##N##_a_bmp, status_hotend##N##_b_bmp)
     #endif
 
     #if STATUS_HOTEND_BITMAPS > 1
@@ -275,20 +269,18 @@ FORCE_INLINE void _draw_centered_temp(const celsius_t temp, const uint8_t tx, co
       uint8_t tall = uint8_t(perc * BAR_TALL + 0.5f);
       NOMORE(tall, BAR_TALL);
 
-      #if ANIM_HOTEND
-        // Draw hotend bitmap, either whole or split by the heating percent
-        const uint8_t hx = STATUS_HOTEND_X(heater_id),
-                      bw = STATUS_HOTEND_BYTEWIDTH(heater_id);
-        #if ENABLED(STATUS_HEAT_PERCENT)
-          if (isHeat && tall <= BAR_TALL) {
-            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
-        #endif
-            u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), isHeat));
+      // Draw hotend bitmap, either whole or split by the heating percent
+      const uint8_t hx = STATUS_HOTEND_X(heater_id),
+                    bw = STATUS_HOTEND_BYTEWIDTH(heater_id);
+      #if ENABLED(STATUS_HEAT_PERCENT)
+        if (isHeat && tall <= BAR_TALL) {
+          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
       #endif
+          u8g.drawBitmapP(hx, STATUS_HEATERS_Y, bw, STATUS_HEATERS_HEIGHT, HOTEND_BITMAP(TERN(HAS_MMU, active_extruder, heater_id), isHeat));
 
     } // PAGE_CONTAINS