Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for SH1106 and SSD1306 LCD modules. #2574

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@
#if ENABLED(U8GLIB_SSD1306)
#define ULTRA_LCD //general LCD support, also 16x2
#define DOGLCD // Support for I2C LCD 128x64 (Controller SSD1306 graphic Display Family)
#define ULTIMAKERCONTROLLER
#endif
// Generic support for SH1106 OLED based LCDs.
#if ENABLED(U8GLIB_SH1106)
#define ULTRA_LCD //general LCD support, also 16x2
#define DOGLCD // Support for I2C LCD 128x64 (Controller SSD1306 graphic Display Family)
#define ULTIMAKERCONTROLLER
#endif


Expand Down Expand Up @@ -203,13 +210,11 @@
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fmalpartida
Aha, and this can be in the block below too, so…

  /**
   * LCD contrast for dogm-like LCD displays
   */
  #if ENABLED(DOGLCD)
    #define HAS_LCD_CONTRAST (DISABLED(U8GLIB_ST7920) && DISABLED(U8GLIB_SSD1306) && DISABLED(U8GLIB_SH1106))
    #if HAS_LCD_CONTRAST && !defined(DEFAULT_LCD_CONTRAST)
      #define DEFAULT_LCD_CONTRAST 32
    #endif
  #endif

Note the correction from DISABLED(DEFAULT_LCD_CONTRAST) to #if !defined(DEFAULT_LCD_CONTRAST).


#if ENABLED(DOGLCD)
#define HAS_LCD_CONTRAST
#if ENABLED(U8GLIB_ST7920)
#undef HAS_LCD_CONTRAST
#if ENABLED(U8GLIB_ST7920) || ENABLED(U8GLIB_SSD1306) || ENABLED(U8GLIB_SH1106)
#define HAS_LCD_CONTRAST false
#else
#define HAS_LCD_CONTRAST true
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way most HAS_SOMETHING defines work would also work well here:

#define HAS_LCD_CONTRAST (ENABLED(DOGLCD) && DISABLED(U8GLIB_ST7920) && DISABLED(U8GLIB_SSD1306) && DISABLED(U8GLIB_SH1106))

I see HAS_LCD_CONTRAST is used in few other files, so those should be patched up to use #if ... too.

#if ENABLED(U8GLIB_SSD1306)
#undef HAS_LCD_CONTRAST
#endif
#endif

#else // CONFIGURATION_LCD
Expand Down
14 changes: 14 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -726,9 +726,23 @@ const bool Z_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the logic
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define U8GLIB_SSD1306

// SH1106 OLED generic display support
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define U8GLIB_SH1106


// SAV OLEd LCD module support using either SSD1306 or SH1106 based LCD modules
// ==> REMEMBER TO INSTALL U8glib to your ARDUINO library folder: http://code.google.com/p/u8glib/wiki/u8glib
//#define SAV_3DGLCD
#if ENABLED(SAV_3DGLCD)
//#define U8GLIB_SSD1306
#define U8GLIB_SH1106
#endif

// Shift register panels
// ---------------------
// 2 wire Non-latching LCD SR from:

// https://bitbucket.org/fmalpartida/new-liquidcrystal/wiki/schematics#!shiftregister-connection
// LCD configuration: http://reprap.org/wiki/SAV_3D_LCD
//#define SAV_3DLCD
Expand Down
9 changes: 6 additions & 3 deletions Marlin/dogm_lcd_implementation.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,15 @@
#elif ENABLED(U8GLIB_LM6059_AF)
// Based on the Adafruit ST7565 (http://www.adafruit.com/products/250)
U8GLIB_LM6059 u8g(DOGLCD_CS, DOGLCD_A0);
#elif defined U8GLIB_SSD1306
#elif ENABLED(U8GLIB_SSD1306)
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE);
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST);
#elif ENABLED(U8GLIB_SH1106)
// Generic support for SSD1306 OLED I2C LCDs
U8GLIB_SH1106_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_FAST);
#elif defined(MINIPANEL)
// The MINIPanel display
U8GLIB_MINI12864 u8g(DOGLCD_CS, DOGLCD_A0);
U8GLIB_MINI12864 u8g(DOGLCD_CS, DOGLCD_A0);
#else
// for regular DOGM128 display with HW-SPI
U8GLIB_DOGM128 u8g(DOGLCD_CS, DOGLCD_A0); // HW-SPI Com: CS, A0
Expand Down