Browse Source

Merge pull request #3944 from thinkyhead/rc_eboston_lcd_contrast

Improved LCD contrast handling
pull/1/head
Scott Lahteine 9 years ago
parent
commit
32f8300cc6
  1. 23
      Marlin/Conditionals.h
  2. 2
      Marlin/Marlin_main.cpp
  3. 9
      Marlin/SanityCheck.h
  4. 21
      Marlin/ultralcd.cpp
  5. 2
      Marlin/ultralcd.h

23
Marlin/Conditionals.h

@ -61,10 +61,14 @@
#define ULTIMAKERCONTROLLER //as available from the Ultimaker online store. #define ULTIMAKERCONTROLLER //as available from the Ultimaker online store.
#if ENABLED(miniVIKI) #if ENABLED(miniVIKI)
#define LCD_CONTRAST_MIN 75
#define LCD_CONTRAST_MAX 115
#define DEFAULT_LCD_CONTRAST 95 #define DEFAULT_LCD_CONTRAST 95
#elif ENABLED(VIKI2) #elif ENABLED(VIKI2)
#define DEFAULT_LCD_CONTRAST 40 #define DEFAULT_LCD_CONTRAST 40
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) #elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define LCD_CONTRAST_MIN 90
#define LCD_CONTRAST_MAX 130
#define DEFAULT_LCD_CONTRAST 110 #define DEFAULT_LCD_CONTRAST 110
#define U8GLIB_LM6059_AF #define U8GLIB_LM6059_AF
#define SD_DETECT_INVERTED #define SD_DETECT_INVERTED
@ -245,11 +249,26 @@
* Default LCD contrast for dogm-like LCD displays * Default LCD contrast for dogm-like LCD displays
*/ */
#if ENABLED(DOGLCD) #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 HAS_LCD_CONTRAST ( \
ENABLED(MAKRPANEL) \
|| ENABLED(VIKI2) \
|| ENABLED(miniVIKI) \
|| ENABLED(ELB_FULL_GRAPHIC_CONTROLLER) \
)
#if HAS_LCD_CONTRAST
#ifndef LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN 0
#endif
#ifndef LCD_CONTRAST_MAX
#define LCD_CONTRAST_MAX 63
#endif
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST 32 #define DEFAULT_LCD_CONTRAST 32
#endif #endif
#endif #endif
#endif
#else // CONFIGURATION_LCD #else // CONFIGURATION_LCD

2
Marlin/Marlin_main.cpp

@ -5655,7 +5655,7 @@ inline void gcode_M226() {
* M250: Read and optionally set the LCD contrast * M250: Read and optionally set the LCD contrast
*/ */
inline void gcode_M250() { inline void gcode_M250() {
if (code_seen('C')) lcd_setcontrast(code_value_short() & 0x3F); if (code_seen('C')) set_lcd_contrast(code_value_short());
SERIAL_PROTOCOLPGM("lcd contrast value: "); SERIAL_PROTOCOLPGM("lcd contrast value: ");
SERIAL_PROTOCOL(lcd_contrast); SERIAL_PROTOCOL(lcd_contrast);
SERIAL_EOL; SERIAL_EOL;

9
Marlin/SanityCheck.h

@ -367,7 +367,14 @@
#endif #endif
#if ENCODER_PULSES_PER_STEP < 0 #if ENCODER_PULSES_PER_STEP < 0
#error "ENCODER_PULSES_PER_STEP should not be negative, use REVERSE_MENU_DIRECTION instead" #error "ENCODER_PULSES_PER_STEP should not be negative, use REVERSE_MENU_DIRECTION instead."
#endif
/**
* SAV_3DGLCD display options
*/
#if ENABLED(U8GLIB_SSD1306) && ENABLED(U8GLIB_SH1106)
#error "Only enable one SAV_3DGLCD display type: U8GLIB_SSD1306 or U8GLIB_SH1106."
#endif #endif
/** /**

21
Marlin/ultralcd.cpp

@ -1720,23 +1720,18 @@ static void lcd_control_volumetric_menu() {
static void lcd_set_contrast() { static void lcd_set_contrast() {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
if (encoderPosition) { if (encoderPosition) {
#if ENABLED(U8GLIB_LM6059_AF) set_lcd_contrast(lcd_contrast + encoderPosition);
lcd_contrast += encoderPosition;
lcd_contrast &= 0xFF;
#else
lcd_contrast -= encoderPosition;
lcd_contrast &= 0x3F;
#endif
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_REDRAW_NOW; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
u8g.setContrast(lcd_contrast);
} }
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
#if ENABLED(U8GLIB_LM6059_AF) lcd_implementation_drawedit(PSTR(MSG_CONTRAST),
lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr3(lcd_contrast)); #if LCD_CONTRAST_MAX >= 100
itostr3(lcd_contrast)
#else #else
lcd_implementation_drawedit(PSTR(MSG_CONTRAST), itostr2(lcd_contrast)); itostr2(lcd_contrast)
#endif #endif
);
} }
if (LCD_CLICKED) lcd_goto_previous_menu(true); if (LCD_CLICKED) lcd_goto_previous_menu(true);
} }
@ -2388,8 +2383,8 @@ void lcd_setalertstatuspgm(const char* message) {
void lcd_reset_alert_level() { lcd_status_message_level = 0; } void lcd_reset_alert_level() { lcd_status_message_level = 0; }
#if HAS_LCD_CONTRAST #if HAS_LCD_CONTRAST
void lcd_setcontrast(uint8_t value) { void set_lcd_contrast(int value) {
lcd_contrast = value & 0x3F; lcd_contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
u8g.setContrast(lcd_contrast); u8g.setContrast(lcd_contrast);
} }
#endif #endif

2
Marlin/ultralcd.h

@ -53,7 +53,7 @@
#if ENABLED(DOGLCD) #if ENABLED(DOGLCD)
extern int lcd_contrast; extern int lcd_contrast;
void lcd_setcontrast(uint8_t value); void set_lcd_contrast(int value);
#endif #endif
#define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x)) #define LCD_MESSAGEPGM(x) lcd_setstatuspgm(PSTR(x))

Loading…
Cancel
Save