From df8420aa62bd00685e9a7c4e0288fd6f02f043e5 Mon Sep 17 00:00:00 2001 From: Dan Delaney Date: Sat, 16 Dec 2017 17:44:34 -0600 Subject: [PATCH] Adding support for using the MKS_12864OLED with the SSD1306 controller --- Marlin/Conditionals_LCD.h | 5 +++++ Marlin/Configuration.h | 6 ++++-- Marlin/Marlin_main.cpp | 2 +- Marlin/SanityCheck.h | 12 +++++++++--- Marlin/pins_RAMPS.h | 2 +- Marlin/pins_RAMPS_PLUS.h | 2 +- Marlin/ultralcd_impl_DOGM.h | 4 ++++ 7 files changed, 25 insertions(+), 8 deletions(-) diff --git a/Marlin/Conditionals_LCD.h b/Marlin/Conditionals_LCD.h index c563b64d8..423552fed 100644 --- a/Marlin/Conditionals_LCD.h +++ b/Marlin/Conditionals_LCD.h @@ -125,6 +125,11 @@ #define REPRAP_DISCOUNT_SMART_CONTROLLER #define U8GLIB_SH1106 + #elif ENABLED(MKS_12864OLED_SSD1306) + + #define REPRAP_DISCOUNT_SMART_CONTROLLER + #define U8GLIB_SSD1306 + #elif ENABLED(MKS_MINI_12864) #define MINIPANEL diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 0736ed9b5..0b036f39c 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1625,12 +1625,14 @@ //#define CR10_STOCKDISPLAY // -// MKS OLED 1.3" 128 × 64 FULL GRAPHICS CONTROLLER +// MKS OLED 1.3" 128x64 FULL GRAPHICS CONTROLLER // http://reprap.org/wiki/MKS_12864OLED // // Tiny, but very sharp OLED display +// If there is a pixel shift, try the other controller. // -//#define MKS_12864OLED +//#define MKS_12864OLED // Uses the SH1106 controller (default) +//#define MKS_12864OLED_SSD1306 // Uses the SSD1306 controller // Silvergate GLCD controller // http://github.com/android444/Silvergate diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 3b016afde..25e6fe95a 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -14515,7 +14515,7 @@ void setup() { pe_deactivate_magnet(1); #endif #endif - #if ENABLED(MKS_12864OLED) + #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) SET_OUTPUT(LCD_PINS_DC); OUT_WRITE(LCD_PINS_RS, LOW); delay(1000); diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 170b30518..8b4f527b1 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -1275,6 +1275,7 @@ static_assert(1 >= 0 * REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER => REPRAP_DISCOUNT_SMART_CONTROLLER * SAV_3DGLCD => U8GLIB_SH1106 => ULTIMAKERCONTROLLER * MKS_12864OLED => U8GLIB_SH1106 => ULTIMAKERCONTROLLER + * MKS_12864OLED_SSD1306 => U8GLIB_SSD1306 => ULTIMAKERCONTROLLER * miniVIKI => ULTIMAKERCONTROLLER * VIKI2 => ULTIMAKERCONTROLLER * ELB_FULL_GRAPHIC_CONTROLLER => ULTIMAKERCONTROLLER @@ -1287,14 +1288,16 @@ static_assert(1 >= 0 && DISABLED(VIKI2) \ && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER) \ && DISABLED(PANEL_ONE) \ - && DISABLED(MKS_12864OLED) + && DISABLED(MKS_12864OLED) \ + && DISABLED(MKS_12864OLED_SSD1306) + 1 #endif #if ENABLED(REPRAP_DISCOUNT_SMART_CONTROLLER) \ && DISABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) \ && DISABLED(LCD_FOR_MELZI) \ && DISABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) \ - && DISABLED(MKS_12864OLED) + && DISABLED(MKS_12864OLED) \ + && DISABLED(MKS_12864OLED_SSD1306) + 1 #endif #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) \ @@ -1307,6 +1310,9 @@ static_assert(1 >= 0 #if ENABLED(MKS_12864OLED) + 1 #endif + #if ENABLED(MKS_12864OLED_SSD1306) + + 1 + #endif #if ENABLED(MAKEBOARD_MINI_2_LINE_DISPLAY_1602) + 1 #endif @@ -1363,7 +1369,7 @@ static_assert(1 >= 0 #if ENABLED(LCD_I2C_VIKI) + 1 #endif - #if ENABLED(U8GLIB_SSD1306) && DISABLED(OLED_PANEL_TINYBOY2) + #if ENABLED(U8GLIB_SSD1306) && DISABLED(OLED_PANEL_TINYBOY2) && DISABLED(MKS_12864OLED_SSD1306) + 1 #endif #if ENABLED(SAV_3DLCD) diff --git a/Marlin/pins_RAMPS.h b/Marlin/pins_RAMPS.h index e070e8fb9..9b10751e5 100644 --- a/Marlin/pins_RAMPS.h +++ b/Marlin/pins_RAMPS.h @@ -334,7 +334,7 @@ #else - #if ENABLED(MKS_12864OLED) + #if ENABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) #define LCD_PINS_DC 25 // Set as output on init #define LCD_PINS_RS 27 // Pull low for 1s to init // DOGM SPI LCD Support diff --git a/Marlin/pins_RAMPS_PLUS.h b/Marlin/pins_RAMPS_PLUS.h index 5b9fd50f9..77e0e140c 100644 --- a/Marlin/pins_RAMPS_PLUS.h +++ b/Marlin/pins_RAMPS_PLUS.h @@ -76,7 +76,7 @@ #undef E1_CS_PIN #if ENABLED(ULTRA_LCD) && DISABLED(REPRAPWORLD_GRAPHICAL_LCD) && (DISABLED(NEWPANEL) || DISABLED(PANEL_ONE)) && DISABLED(CR10_STOCKDISPLAY) - #if DISABLED(MKS_12864OLED) + #if DISABLED(MKS_12864OLED) || ENABLED(MKS_12864OLED_SSD1306) #undef LCD_PINS_RS #define LCD_PINS_RS 42 // 3DYMY boards pin 16 -> 42 #undef LCD_PINS_ENABLE diff --git a/Marlin/ultralcd_impl_DOGM.h b/Marlin/ultralcd_impl_DOGM.h index 2ecb8233b..0cd66872b 100644 --- a/Marlin/ultralcd_impl_DOGM.h +++ b/Marlin/ultralcd_impl_DOGM.h @@ -187,6 +187,10 @@ // U8GLIB_ST7565_64128n_2x_VIKI u8g(0); // using SW-SPI DOGLCD_MOSI != -1 && DOGLCD_SCK U8GLIB_ST7565_64128n_2x_VIKI u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0); // using SW-SPI //U8GLIB_NHD_C12864_2X u8g(DOGLCD_CS, DOGLCD_A0); // 4 stripes HWSPI +#elif ENABLED(MKS_12864OLED_SSD1306) + // MKS 128x64 (SSD1306) OLED I2C LCD + U8GLIB_SSD1306_128X64 u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0); // 8 stripes + //U8GLIB_SSD1306_128X64_2X u8g(DOGLCD_SCK, DOGLCD_MOSI, DOGLCD_CS, DOGLCD_A0); // 4 stripes #elif ENABLED(U8GLIB_SSD1306) // Generic support for SSD1306 OLED I2C LCDs //U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST); // 8 stripes