Browse Source

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.
Tanguy Pruvot 5 years ago
parent
commit
bae8d0a4bd
2 changed files with 20 additions and 11 deletions
  1. 1
    0
      Marlin/src/inc/Conditionals_LCD.h
  2. 19
    11
      Marlin/src/lcd/dogm/ultralcd_DOGM.cpp

+ 1
- 0
Marlin/src/inc/Conditionals_LCD.h View File

233
  #if ENABLED(MKS_ROBIN_TFT)
233
  #if ENABLED(MKS_ROBIN_TFT)
234
    #define DOGLCD
234
    #define DOGLCD
235
    #define IS_ULTIPANEL
235
    #define IS_ULTIPANEL
236
+   #define DELAYED_BACKLIGHT_INIT
236
  #endif
237
  #endif
237
 
238
 
238
 /**
239
 /**

+ 19
- 11
Marlin/src/lcd/dogm/ultralcd_DOGM.cpp View File

219
 // Initialize or re-initialize the LCD
219
 // Initialize or re-initialize the LCD
220
 void MarlinUI::init_lcd() {
220
 void MarlinUI::init_lcd() {
221
 
221
 
222
-  #if PIN_EXISTS(LCD_BACKLIGHT) // Enable LCD backlight
223
-    OUT_WRITE(LCD_BACKLIGHT_PIN, HIGH);
222
+  #if PIN_EXISTS(LCD_BACKLIGHT)
223
+    OUT_WRITE(LCD_BACKLIGHT_PIN, (
224
+      #if ENABLED(DELAYED_BACKLIGHT_INIT)
225
+        LOW  // Illuminate after reset
226
+      #else
227
+        HIGH // Illuminate right away
228
+      #endif
229
+    ));
224
   #endif
230
   #endif
225
 
231
 
226
   #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
232
   #if EITHER(MKS_12864OLED, MKS_12864OLED_SSD1306)
227
     SET_OUTPUT(LCD_PINS_DC);
233
     SET_OUTPUT(LCD_PINS_DC);
228
-    #if !defined(LCD_RESET_PIN)
234
+    #ifndef LCD_RESET_PIN
229
       #define LCD_RESET_PIN LCD_PINS_RS
235
       #define LCD_RESET_PIN LCD_PINS_RS
230
     #endif
236
     #endif
231
   #endif
237
   #endif
232
 
238
 
233
   #if PIN_EXISTS(LCD_RESET)
239
   #if PIN_EXISTS(LCD_RESET)
234
-    OUT_WRITE(LCD_RESET_PIN, LOW); // perform a clean hardware reset
240
+    // Perform a clean hardware reset with needed delays
241
+    OUT_WRITE(LCD_RESET_PIN, LOW);
242
+    _delay_ms(5);
243
+    WRITE(LCD_RESET_PIN, HIGH);
235
     _delay_ms(5);
244
     _delay_ms(5);
236
-    OUT_WRITE(LCD_RESET_PIN, HIGH);
237
-    _delay_ms(5); // delay to allow the display to initialize
245
+    u8g.begin();
238
   #endif
246
   #endif
239
 
247
 
240
-  #if PIN_EXISTS(LCD_RESET)
241
-    u8g.begin();
248
+  #if PIN_EXISTS(LCD_BACKLIGHT) && ENABLED(DELAYED_BACKLIGHT_INIT)
249
+    WRITE(LCD_BACKLIGHT_PIN, HIGH);
242
   #endif
250
   #endif
243
 
251
 
244
   #if HAS_LCD_CONTRAST
252
   #if HAS_LCD_CONTRAST
246
   #endif
254
   #endif
247
 
255
 
248
   #if ENABLED(LCD_SCREEN_ROT_90)
256
   #if ENABLED(LCD_SCREEN_ROT_90)
249
-    u8g.setRot90();   // Rotate screen by 90°
257
+    u8g.setRot90();
250
   #elif ENABLED(LCD_SCREEN_ROT_180)
258
   #elif ENABLED(LCD_SCREEN_ROT_180)
251
-    u8g.setRot180();  // Rotate screen by 180°
259
+    u8g.setRot180();
252
   #elif ENABLED(LCD_SCREEN_ROT_270)
260
   #elif ENABLED(LCD_SCREEN_ROT_270)
253
-    u8g.setRot270();  // Rotate screen by 270°
261
+    u8g.setRot270();
254
   #endif
262
   #endif
255
 
263
 
256
   uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo));
264
   uxg_SetUtf8Fonts(g_fontinfo, COUNT(g_fontinfo));

Loading…
Cancel
Save