From cad792e7025380185691420a751bc3535cf3f0ed Mon Sep 17 00:00:00 2001
From: Scott Lahteine <sourcetree@thinkyhead.com>
Date: Thu, 3 Nov 2016 18:03:02 -0500
Subject: [PATCH] Reduce code for invariant lcd_detected

---
 Marlin/ultralcd.cpp | 10 +++-------
 Marlin/ultralcd.h   |  9 +++++++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 98bcda321d..448f319bee 100755
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -2982,13 +2982,9 @@ void lcd_reset_alert_level() { lcd_status_message_level = 0; }
     lastEncoderBits = enc;
   }
 
-  bool lcd_detected(void) {
-    #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
-      return lcd.LcdDetected() == 1;
-    #else
-      return true;
-    #endif
-  }
+  #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
+    bool lcd_detected() { return lcd.LcdDetected() == 1; }
+  #endif
 
 #endif // ULTIPANEL
 
diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h
index 9c35891a68..3cd0711142 100644
--- a/Marlin/ultralcd.h
+++ b/Marlin/ultralcd.h
@@ -41,10 +41,15 @@
   void lcd_setstatuspgm(const char* message, const uint8_t level=0);
   void lcd_setalertstatuspgm(const char* message);
   void lcd_reset_alert_level();
-  bool lcd_detected(void);
   void lcd_kill_screen();
   void kill_screen(const char* lcd_msg);
 
+  #if (ENABLED(LCD_I2C_TYPE_MCP23017) || ENABLED(LCD_I2C_TYPE_MCP23008)) && ENABLED(DETECT_DEVICE)
+    bool lcd_detected();
+  #else
+    inline bool lcd_detected() { return true; }
+  #endif
+
   #if HAS_BUZZER
     void lcd_buzz(long duration, uint16_t freq);
   #endif
@@ -155,7 +160,7 @@
   inline void lcd_setstatuspgm(const char* message, const uint8_t level=0) { UNUSED(message); UNUSED(level); }
   inline void lcd_buttons_update() {}
   inline void lcd_reset_alert_level() {}
-  inline bool lcd_detected(void) { return true; }
+  inline bool lcd_detected() { return true; }
 
   #define LCD_MESSAGEPGM(x) NOOP
   #define LCD_ALERTMESSAGEPGM(x) NOOP
-- 
GitLab