Просмотр исходного кода

Merge pull request #3944 from thinkyhead/rc_eboston_lcd_contrast

Improved LCD contrast handling
Scott Lahteine 9 лет назад
Родитель
Сommit
32f8300cc6
5 измененных файлов: 42 добавлений и 21 удалений
  1. 22
    3
      Marlin/Conditionals.h
  2. 1
    1
      Marlin/Marlin_main.cpp
  3. 8
    1
      Marlin/SanityCheck.h
  4. 10
    15
      Marlin/ultralcd.cpp
  5. 1
    1
      Marlin/ultralcd.h

+ 22
- 3
Marlin/Conditionals.h Просмотреть файл

61
     #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
61
     #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
62
 
62
 
63
     #if ENABLED(miniVIKI)
63
     #if ENABLED(miniVIKI)
64
+      #define LCD_CONTRAST_MIN  75
65
+      #define LCD_CONTRAST_MAX 115
64
       #define DEFAULT_LCD_CONTRAST 95
66
       #define DEFAULT_LCD_CONTRAST 95
65
     #elif ENABLED(VIKI2)
67
     #elif ENABLED(VIKI2)
66
       #define DEFAULT_LCD_CONTRAST 40
68
       #define DEFAULT_LCD_CONTRAST 40
67
     #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
69
     #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
70
+      #define LCD_CONTRAST_MIN  90
71
+      #define LCD_CONTRAST_MAX 130
68
       #define DEFAULT_LCD_CONTRAST 110
72
       #define DEFAULT_LCD_CONTRAST 110
69
       #define U8GLIB_LM6059_AF
73
       #define U8GLIB_LM6059_AF
70
       #define SD_DETECT_INVERTED
74
       #define SD_DETECT_INVERTED
245
    * Default LCD contrast for dogm-like LCD displays
249
    * Default LCD contrast for dogm-like LCD displays
246
    */
250
    */
247
   #if ENABLED(DOGLCD)
251
   #if ENABLED(DOGLCD)
248
-    #define HAS_LCD_CONTRAST (DISABLED(U8GLIB_ST7920) && DISABLED(U8GLIB_SSD1306) && DISABLED(U8GLIB_SH1106))
249
-    #if HAS_LCD_CONTRAST && !defined(DEFAULT_LCD_CONTRAST)
250
-      #define DEFAULT_LCD_CONTRAST 32
252
+
253
+    #define HAS_LCD_CONTRAST ( \
254
+        ENABLED(MAKRPANEL) \
255
+     || ENABLED(VIKI2) \
256
+     || ENABLED(miniVIKI) \
257
+     || ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \
258
+    )
259
+
260
+    #if HAS_LCD_CONTRAST
261
+      #ifndef LCD_CONTRAST_MIN
262
+        #define LCD_CONTRAST_MIN 0
263
+      #endif
264
+      #ifndef LCD_CONTRAST_MAX
265
+        #define LCD_CONTRAST_MAX 63
266
+      #endif
267
+      #ifndef DEFAULT_LCD_CONTRAST
268
+        #define DEFAULT_LCD_CONTRAST 32
269
+      #endif
251
     #endif
270
     #endif
252
   #endif
271
   #endif
253
 
272
 

+ 1
- 1
Marlin/Marlin_main.cpp Просмотреть файл

5655
    * M250: Read and optionally set the LCD contrast
5655
    * M250: Read and optionally set the LCD contrast
5656
    */
5656
    */
5657
   inline void gcode_M250() {
5657
   inline void gcode_M250() {
5658
-    if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F);
5658
+    if (code_seen('C')) set_lcd_contrast(code_value_short());
5659
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
5659
     SERIAL_PROTOCOLPGM("lcd contrast value: ");
5660
     SERIAL_PROTOCOL(lcd_contrast);
5660
     SERIAL_PROTOCOL(lcd_contrast);
5661
     SERIAL_EOL;
5661
     SERIAL_EOL;

+ 8
- 1
Marlin/SanityCheck.h Просмотреть файл

367
 #endif
367
 #endif
368
 
368
 
369
 #if ENCODER_PULSES_PER_STEP < 0
369
 #if ENCODER_PULSES_PER_STEP < 0
370
-  #error "ENCODER_PULSES_PER_STEP should not be negative, use REVERSE_MENU_DIRECTION instead"
370
+  #error "ENCODER_PULSES_PER_STEP should not be negative, use REVERSE_MENU_DIRECTION instead."
371
+#endif
372
+
373
+/**
374
+ * SAV_3DGLCD display options
375
+ */
376
+#if ENABLED(U8GLIB_SSD1306) && ENABLED(U8GLIB_SH1106)
377
+  #error "Only enable one SAV_3DGLCD display type: U8GLIB_SSD1306 or U8GLIB_SH1106."
371
 #endif
378
 #endif
372
 
379
 
373
 /**
380
 /**

+ 10
- 15
Marlin/ultralcd.cpp Просмотреть файл

1720
   static void lcd_set_contrast() {
1720
   static void lcd_set_contrast() {
1721
     ENCODER_DIRECTION_NORMAL();
1721
     ENCODER_DIRECTION_NORMAL();
1722
     if (encoderPosition) {
1722
     if (encoderPosition) {
1723
-      #if ENABLED(U8GLIB_LM6059_AF)
1724
-        lcd_contrast += encoderPosition;
1725
-        lcd_contrast &= 0xFF;
1726
-      #else
1727
-        lcd_contrast -= encoderPosition;
1728
-        lcd_contrast &= 0x3F;
1729
-      #endif
1723
+      set_lcd_contrast(lcd_contrast + encoderPosition);
1730
       encoderPosition = 0;
1724
       encoderPosition = 0;
1731
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1725
       lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
1732
-      u8g.setContrast(lcd_contrast);
1733
     }
1726
     }
1734
     if (lcdDrawUpdate) {
1727
     if (lcdDrawUpdate) {
1735
-      #if ENABLED(U8GLIB_LM6059_AF)
1736
-        lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr3(lcd_contrast));
1737
-      #else
1738
-        lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast));
1739
-      #endif
1728
+      lcd_implementation_drawedit(PSTR(MSG_CONTRAST),
1729
+        #if LCD_CONTRAST_MAX >= 100
1730
+          itostr3(lcd_contrast)
1731
+        #else
1732
+          itostr2(lcd_contrast)
1733
+        #endif
1734
+      );
1740
     }
1735
     }
1741
     if (LCD_CLICKED) lcd_goto_previous_menu(true);
1736
     if (LCD_CLICKED) lcd_goto_previous_menu(true);
1742
   }
1737
   }
2388
 void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2383
 void lcd_reset_alert_level() { lcd_status_message_level = 0; }
2389
 
2384
 
2390
 #if HAS_LCD_CONTRAST
2385
 #if HAS_LCD_CONTRAST
2391
-  void lcd_setcontrast(uint8_t value) {
2392
-    lcd_contrast = value & 0x3F;
2386
+  void set_lcd_contrast(int value) {
2387
+    lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
2393
     u8g.setContrast(lcd_contrast);
2388
     u8g.setContrast(lcd_contrast);
2394
   }
2389
   }
2395
 #endif
2390
 #endif

+ 1
- 1
Marlin/ultralcd.h Просмотреть файл

53
 
53
 
54
   #if ENABLED(DOGLCD)
54
   #if ENABLED(DOGLCD)
55
     extern int lcd_contrast;
55
     extern int lcd_contrast;
56
-    void lcd_setcontrast(uint8_t value);
56
+    void set_lcd_contrast(int value);
57
   #endif
57
   #endif
58
 
58
 
59
   #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))
59
   #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))

Загрузка…
Отмена
Сохранить