DOGM: Avoid white flash on TFT (re)init (#14631)

- Avoid white flash on TFT (re)init. Unlike Graphical LCD, the TFT init color may be full white if the backlight is on during init.

- Add a conditional for delayed backlight init which can be applied to any backlit display.
This commit is contained in:
Tanguy Pruvot 2019-07-16 00:36:16 +02:00 committed by Scott Lahteine
parent 02859eb2b1
commit bae8d0a4bd
2 changed files with 20 additions and 11 deletions

View file

@ -233,6 +233,7 @@
#if ENABLED(MKS_ROBIN_TFT) #if ENABLED(MKS_ROBIN_TFT)
#define DOGLCD #define DOGLCD
#define IS_ULTIPANEL #define IS_ULTIPANEL
#define DELAYED_BACKLIGHT_INIT
#endif #endif
/** /**

View file

@ -219,26 +219,34 @@ void MarlinUI::set_font(const MarlinFont font_nr) {
// Initialize or re-initialize the LCD // Initialize or re-initialize the LCD
void MarlinUI::init_lcd() { void MarlinUI::init_lcd() {
#if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight #if PIN_EXISTS(LCD_BACKLIGHT)
OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH); OUT_WRITE(LCD_BACKLIGHT_PIN, (
#if ENABLED(DELAYED_BACKLIGHT_INIT)
LOW // Illuminate after reset
#else
HIGH // Illuminate right away
#endif
));
#endif #endif
#if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306) #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
SET_OUTPUT(LCD_PINS_DC); SET_OUTPUT(LCD_PINS_DC);
#if !defined(LCD_RESET_PIN) #ifndef LCD_RESET_PIN
#define LCD_RESET_PIN LCD_PINS_RS #define LCD_RESET_PIN LCD_PINS_RS
#endif #endif
#endif #endif
#if PIN_EXISTS(LCD_RESET) #if PIN_EXISTS(LCD_RESET)
OUT_WRITE(LCD_RESET_PIN, LOW); // perform a clean hardware reset // Perform a clean hardware reset with needed delays
OUT_WRITE(LCD_RESET_PIN, LOW);
_delay_ms(5); _delay_ms(5);
OUT_WRITE(LCD_RESET_PIN, HIGH); WRITE(LCD_RESET_PIN, HIGH);
_delay_ms(5); // delay to allow the display to initialize _delay_ms(5);
u8g.begin();
#endif #endif
#if PIN_EXISTS(LCD_RESET) #if PIN_EXISTS(LCD_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
u8g.begin(); WRITE(LCD_BACKLIGHT_PIN, HIGH);
#endif #endif
#if HAS_LCD_CONTRAST #if HAS_LCD_CONTRAST
@ -246,11 +254,11 @@ void MarlinUI::init_lcd() {
#endif #endif
#if ENABLED(LCD_SCREEN_ROT_90) #if ENABLED(LCD_SCREEN_ROT_90)
u8g.setRot90(); // Rotate screen by 90° u8g.setRot90();
#elif ENABLED(LCD_SCREEN_ROT_180) #elif ENABLED(LCD_SCREEN_ROT_180)
u8g.setRot180(); // Rotate screen by 180° u8g.setRot180();
#elif ENABLED(LCD_SCREEN_ROT_270) #elif ENABLED(LCD_SCREEN_ROT_270)
u8g.setRot270(); // Rotate screen by 270° u8g.setRot270();
#endif #endif
uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo)); uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo));