Browse Source

Enable contrast via LCD_CONTRAST_INIT (#15006)

Tanguy Pruvot 4 years ago
parent
commit
e604f76703

+ 16
- 39
Marlin/src/inc/Conditionals_LCD.h View File

@@ -30,9 +30,9 @@
30 30
 
31 31
   #define DOGLCD
32 32
   #define IS_ULTIPANEL
33
-  #define DEFAULT_LCD_CONTRAST 90
34
-  #define LCD_CONTRAST_MIN 60
33
+  #define LCD_CONTRAST_MIN  60
35 34
   #define LCD_CONTRAST_MAX 140
35
+  #define LCD_CONTRAST_INIT 90
36 36
 
37 37
 #elif ENABLED(ZONESTAR_LCD)
38 38
 
@@ -65,23 +65,23 @@
65 65
   #if ENABLED(miniVIKI)
66 66
     #define LCD_CONTRAST_MIN      75
67 67
     #define LCD_CONTRAST_MAX     115
68
-    #define DEFAULT_LCD_CONTRAST  95
68
+    #define LCD_CONTRAST_INIT     95
69 69
     #define U8GLIB_ST7565_64128N
70 70
   #elif ENABLED(VIKI2)
71 71
     #define LCD_CONTRAST_MIN       0
72 72
     #define LCD_CONTRAST_MAX     255
73
-    #define DEFAULT_LCD_CONTRAST 140
73
+    #define LCD_CONTRAST_INIT    140
74 74
     #define U8GLIB_ST7565_64128N
75 75
   #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
76 76
     #define LCD_CONTRAST_MIN      90
77 77
     #define LCD_CONTRAST_MAX     130
78
-    #define DEFAULT_LCD_CONTRAST 110
78
+    #define LCD_CONTRAST_INIT    110
79 79
     #define U8GLIB_LM6059_AF
80 80
     #define SD_DETECT_INVERTED
81 81
   #elif ENABLED(AZSMZ_12864)
82 82
     #define LCD_CONTRAST_MIN     120
83 83
     #define LCD_CONTRAST_MAX     255
84
-    #define DEFAULT_LCD_CONTRAST 190
84
+    #define LCD_CONTRAST_INIT    190
85 85
     #define U8GLIB_ST7565_64128N
86 86
   #endif
87 87
 
@@ -128,17 +128,17 @@
128 128
 #elif ENABLED(MKS_MINI_12864)
129 129
 
130 130
   #define MINIPANEL
131
-  #define DEFAULT_LCD_CONTRAST 150
132
-  #define LCD_CONTRAST_MAX 255
131
+  #define LCD_CONTRAST_MAX  255
132
+  #define LCD_CONTRAST_INIT 150
133 133
 
134 134
 #elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
135 135
 
136 136
   #define FYSETC_MINI_12864
137 137
   #define DOGLCD
138 138
   #define IS_ULTIPANEL
139
-  #define LCD_CONTRAST_MIN 0
140
-  #define LCD_CONTRAST_MAX 255
141
-  #define DEFAULT_LCD_CONTRAST 220
139
+  #define LCD_CONTRAST_MIN    0
140
+  #define LCD_CONTRAST_MAX  255
141
+  #define LCD_CONTRAST_INIT 220
142 142
   #define LED_COLORS_REDUCE_GREEN
143 143
   #if HAS_POWER_SWITCH && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
144 144
     #define LED_BACKLIGHT_TIMEOUT 10000
@@ -166,9 +166,9 @@
166 166
   #define IS_ULTIPANEL
167 167
   #define U8GLIB_SSD1309
168 168
   #define LCD_RESET_PIN LCD_PINS_D6 //  This controller need a reset pin
169
-  #define LCD_CONTRAST_MIN 0
170
-  #define LCD_CONTRAST_MAX 254
171
-  #define DEFAULT_LCD_CONTRAST 127
169
+  #define LCD_CONTRAST_MIN    0
170
+  #define LCD_CONTRAST_MAX  254
171
+  #define LCD_CONTRAST_INIT 127
172 172
   #define ENCODER_PULSES_PER_STEP 2
173 173
   #define ENCODER_STEPS_PER_MENU_ITEM 2
174 174
 
@@ -190,8 +190,8 @@
190 190
   #if ENABLED(MAKRPANEL)
191 191
     #define U8GLIB_ST7565_64128N
192 192
   #endif
193
-  #ifndef DEFAULT_LCD_CONTRAST
194
-    #define DEFAULT_LCD_CONTRAST 17
193
+  #ifndef LCD_CONTRAST_INIT
194
+    #define LCD_CONTRAST_INIT    17
195 195
   #endif
196 196
 #endif
197 197
 
@@ -382,29 +382,6 @@
382 382
 #define HAS_ADC_BUTTONS      ENABLED(ADC_KEYPAD)
383 383
 
384 384
 /**
385
- * Default LCD contrast for Graphical LCD displays
386
- */
387
-#define HAS_LCD_CONTRAST (                \
388
-     ENABLED(MAKRPANEL)                   \
389
-  || ENABLED(CARTESIO_UI)                 \
390
-  || ENABLED(VIKI2)                       \
391
-  || ENABLED(AZSMZ_12864)                 \
392
-  || ENABLED(miniVIKI)                    \
393
-  || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \
394
-)
395
-#if HAS_LCD_CONTRAST
396
-  #ifndef LCD_CONTRAST_MIN
397
-    #define LCD_CONTRAST_MIN 0
398
-  #endif
399
-  #ifndef LCD_CONTRAST_MAX
400
-    #define LCD_CONTRAST_MAX 63
401
-  #endif
402
-  #ifndef DEFAULT_LCD_CONTRAST
403
-    #define DEFAULT_LCD_CONTRAST 32
404
-  #endif
405
-#endif
406
-
407
-/**
408 385
  * Extruders have some combination of stepper motors and hotends
409 386
  * so we separate these concepts into the defines:
410 387
  *

+ 16
- 0
Marlin/src/inc/Conditionals_post.h View File

@@ -247,6 +247,22 @@
247 247
 #endif
248 248
 
249 249
 /**
250
+ * Default LCD contrast for Graphical LCD displays
251
+ */
252
+#define HAS_LCD_CONTRAST defined(LCD_CONTRAST_INIT)
253
+#if HAS_LCD_CONTRAST
254
+  #ifndef DEFAULT_LCD_CONTRAST
255
+    #define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
256
+  #endif
257
+  #ifndef LCD_CONTRAST_MIN
258
+    #define LCD_CONTRAST_MIN 0
259
+  #endif
260
+  #ifndef LCD_CONTRAST_MAX
261
+    #define LCD_CONTRAST_MAX MAX(63, LCD_CONTRAST_INIT)
262
+  #endif
263
+#endif
264
+
265
+/**
250 266
  * Override here because this is set in Configuration_adv.h
251 267
  */
252 268
 #if HAS_LCD_MENU && DISABLED(ELB_FULL_GRAPHIC_CONTROLLER)

+ 3
- 1
Marlin/src/module/configuration_store.cpp View File

@@ -828,8 +828,10 @@ void MarlinSettings::postprocess() {
828 828
       const int16_t lcd_contrast =
829 829
         #if HAS_LCD_CONTRAST
830 830
           ui.contrast
831
+        #elif defined(DEFAULT_LCD_CONTRAST)
832
+          DEFAULT_LCD_CONTRAST
831 833
         #else
832
-          32
834
+          127
833 835
         #endif
834 836
       ;
835 837
       EEPROM_WRITE(lcd_contrast);

+ 1
- 3
Marlin/src/pins/mega/pins_WANHAO_ONEPLUS.h View File

@@ -105,9 +105,7 @@
105 105
   #define BTN_ENC           5
106 106
 
107 107
   // This display has adjustable contrast
108
-  #undef HAS_LCD_CONTRAST
109
-  #define HAS_LCD_CONTRAST 1
110 108
   #define LCD_CONTRAST_MIN       0
111 109
   #define LCD_CONTRAST_MAX     255
112
-  #define DEFAULT_LCD_CONTRAST 255
110
+  #define LCD_CONTRAST_INIT LCD_CONTRAST_MAX
113 111
 #endif

+ 2
- 2
Marlin/src/pins/ramps/pins_TT_OSCAR.h View File

@@ -436,7 +436,7 @@
436 436
       #define DOGLCD_CS    25
437 437
 
438 438
       // GLCD features
439
-      //#define LCD_CONTRAST 190
439
+      //#define LCD_CONTRAST_INIT 190
440 440
       // Uncomment screen orientation
441 441
       //#define LCD_SCREEN_ROT_90
442 442
       //#define LCD_SCREEN_ROT_180
@@ -463,7 +463,7 @@
463 463
       #define DOGLCD_CS    66
464 464
 
465 465
       // GLCD features
466
-      //#define LCD_CONTRAST 190
466
+      //#define LCD_CONTRAST_INIT 190
467 467
       // Uncomment screen orientation
468 468
       //#define LCD_SCREEN_ROT_90
469 469
       //#define LCD_SCREEN_ROT_180

+ 1
- 1
Marlin/src/pins/stm32/pins_FYSETC_AIO_II.h View File

@@ -137,7 +137,7 @@
137 137
       #define DOGLCD_CS    PB7
138 138
     #endif
139 139
 
140
-    //#define LCD_CONTRAST 190
140
+    //#define LCD_CONTRAST_INIT 190
141 141
     //#define LCD_SCREEN_ROT_90
142 142
     //#define LCD_SCREEN_ROT_180
143 143
     //#define LCD_SCREEN_ROT_270

+ 1
- 1
Marlin/src/pins/stm32/pins_FYSETC_CHEETAH.h View File

@@ -140,7 +140,7 @@
140 140
     #define RGB_LED_B_PIN  PB6
141 141
   #endif
142 142
 
143
-  //#define LCD_CONTRAST   190
143
+  //#define LCD_CONTRAST_INIT 190
144 144
 
145 145
   #if ENABLED(NEWPANEL)
146 146
     #define BTN_EN1        PC11

Loading…
Cancel
Save