From a83bf18ee1063798e75ad6324b033752e0b1f66f Mon Sep 17 00:00:00 2001
From: Ed Boston <edward.boston@gmail.com>
Date: Mon, 18 May 2015 05:37:46 -0700
Subject: [PATCH] More functional seperation

Moved SDCARDDETECTINVERTED and SDSLOW to Conditionals.h.
Added U8GLIB_LM6059_AF to define display specific actions.
Added reminder to compile in u8glib
---
 Marlin/Conditionals.h            |  3 +++
 Marlin/Configuration.h           |  4 +++-
 Marlin/dogm_lcd_implementation.h |  2 +-
 Marlin/pins_RAMPS_13.h           |  4 +---
 Marlin/ultralcd.cpp              | 27 ++++++++++++++-------------
 5 files changed, 22 insertions(+), 18 deletions(-)

diff --git a/Marlin/Conditionals.h b/Marlin/Conditionals.h
index 83fcd95a95..358131e4ae 100644
--- a/Marlin/Conditionals.h
+++ b/Marlin/Conditionals.h
@@ -33,6 +33,9 @@
       #define DEFAULT_LCD_CONTRAST 40
     #elif defined(ELB_FULL_GRAPHIC_CONTROLLER)
       #define DEFAULT_LCD_CONTRAST 110
+      #define SDCARDDETECTINVERTED
+      #define SDSLOW
+      #define U8GLIB_LM6059_AF
     #endif
 
     #define ENCODER_PULSES_PER_STEP 4
diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h
index 71a770bd60..bc7e7dda05 100644
--- a/Marlin/Configuration.h
+++ b/Marlin/Configuration.h
@@ -662,7 +662,9 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
 
 // This is a new controller currently under development.  A link to more information will be provided as it
 // becomes available.
-//#define ELB_FULL_GRAPHIC_CONTROLLER
+//
+// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
+#define ELB_FULL_GRAPHIC_CONTROLLER
 
 // The RepRapDiscount Smart Controller (white PCB)
 // http://reprap.org/wiki/RepRapDiscount_Smart_Controller
diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h
index 0fc2e94846..c7e371f67f 100644
--- a/Marlin/dogm_lcd_implementation.h
+++ b/Marlin/dogm_lcd_implementation.h
@@ -126,7 +126,7 @@
 #elif defined(VIKI2) || defined(miniVIKI)
   // Mini Viki and Viki 2.0 LCD, ST7565 controller as well
   U8GLIB_NHD_C12864 u8g(DOGLCD_CS, DOGLCD_A0);
-#elif defined(ELB_FULL_GRAPHIC_CONTROLLER)
+#elif defined(U8GLIB_LM6059_AF)
   // Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
   U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
 #else
diff --git a/Marlin/pins_RAMPS_13.h b/Marlin/pins_RAMPS_13.h
index 4b3eda4f0d..37683b8c59 100644
--- a/Marlin/pins_RAMPS_13.h
+++ b/Marlin/pins_RAMPS_13.h
@@ -181,12 +181,10 @@
       #define LCD_SDSS 53
       #define SDCARDDETECT 49
     #elif defined(ELB_FULL_GRAPHIC_CONTROLLER)
-      #define BTN_EN1 35
+      #define BTN_EN1 35  // reverse if the encoder turns the wrong way.
       #define BTN_EN2 37
       #define BTN_ENC 31
       #define SDCARDDETECT 49
-      #define SDCARDDETECTINVERTED
-      #define SDSLOW
       #define LCD_SDSS 53
       #define KILL_PIN 41
       #define BEEPER 23
diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp
index 593390b324..71f7f28064 100644
--- a/Marlin/ultralcd.cpp
+++ b/Marlin/ultralcd.cpp
@@ -1110,23 +1110,24 @@ static void lcd_control_volumetric_menu() {
 #ifdef HAS_LCD_CONTRAST
   static void lcd_set_contrast() {
     if (encoderPosition != 0) {
-#ifdef ELB_FULL_GRAPHIC_CONTROLLER
-      lcd_contrast += encoderPosition;
-      lcd_contrast &= 0xFF;
-#else
-      lcd_contrast -= encoderPosition;
-      lcd_contrast &= 0x3F;
-#endif
+      #ifdef U8GLIB_ST7920
+        lcd_contrast += encoderPosition;
+        lcd_contrast &= 0xFF;
+      #else
+        lcd_contrast -= encoderPosition;
+        lcd_contrast &= 0x3F;
+      #endif
       encoderPosition = 0;
       lcdDrawUpdate = 1;
       u8g.setContrast(lcd_contrast);
     }
-    if (lcdDrawUpdate) 
-#ifdef ELB_FULL_GRAPHIC_CONTROLLER
-      lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr3(lcd_contrast));
-#else
-      lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
-#endif
+    if (lcdDrawUpdate) {
+      #ifdef U8GLIB_ST7920
+        lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr3(lcd_contrast));
+      #else
+        lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
+      #endif
+    }
     if (LCD_CLICKED) lcd_goto_menu(lcd_control_menu);
   }
 #endif // HAS_LCD_CONTRAST
-- 
GitLab