Skip to content

Commit

Permalink
Fix: Contrast override in pins files
Browse files Browse the repository at this point in the history
Move contrast handling to `Conditionals_post.h` so pins files can override the LCD defaults.
  • Loading branch information
thinkyhead committed Aug 24, 2019
1 parent 8c73017 commit 04a9962
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 33 deletions.
26 changes: 0 additions & 26 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@

#define DOGLCD
#define IS_ULTIPANEL
#define LCD_CONTRAST_MIN 60
#define LCD_CONTRAST_MAX 140
#define LCD_CONTRAST_INIT 90

#elif ENABLED(ZONESTAR_LCD)

Expand Down Expand Up @@ -63,25 +60,13 @@
#define IS_ULTIPANEL

#if ENABLED(miniVIKI)
#define LCD_CONTRAST_MIN 75
#define LCD_CONTRAST_MAX 115
#define LCD_CONTRAST_INIT 95
#define U8GLIB_ST7565_64128N
#elif ENABLED(VIKI2)
#define LCD_CONTRAST_MIN 0
#define LCD_CONTRAST_MAX 255
#define LCD_CONTRAST_INIT 140
#define U8GLIB_ST7565_64128N
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define LCD_CONTRAST_MIN 90
#define LCD_CONTRAST_MAX 130
#define LCD_CONTRAST_INIT 110
#define U8GLIB_LM6059_AF
#define SD_DETECT_INVERTED
#elif ENABLED(AZSMZ_12864)
#define LCD_CONTRAST_MIN 120
#define LCD_CONTRAST_MAX 255
#define LCD_CONTRAST_INIT 190
#define U8GLIB_ST7565_64128N
#endif

Expand Down Expand Up @@ -128,17 +113,12 @@
#elif ENABLED(MKS_MINI_12864)

#define MINIPANEL
#define LCD_CONTRAST_MAX 255
#define LCD_CONTRAST_INIT 150

#elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)

#define FYSETC_MINI_12864
#define DOGLCD
#define IS_ULTIPANEL
#define LCD_CONTRAST_MIN 0
#define LCD_CONTRAST_MAX 255
#define LCD_CONTRAST_INIT 220
#define LED_COLORS_REDUCE_GREEN
#if HAS_POWER_SWITCH && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
#define LED_BACKLIGHT_TIMEOUT 10000
Expand Down Expand Up @@ -166,9 +146,6 @@
#define IS_ULTIPANEL
#define U8GLIB_SSD1309
#define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin
#define LCD_CONTRAST_MIN 0
#define LCD_CONTRAST_MAX 254
#define LCD_CONTRAST_INIT 127
#define ENCODER_PULSES_PER_STEP 2
#define ENCODER_STEPS_PER_MENU_ITEM 2

Expand All @@ -190,9 +167,6 @@
#if ENABLED(MAKRPANEL)
#define U8GLIB_ST7565_64128N
#endif
#ifndef LCD_CONTRAST_INIT
#define LCD_CONTRAST_INIT 17
#endif
#endif

#if ENABLED(IS_U8GLIB_SSD1306)
Expand Down
53 changes: 46 additions & 7 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,18 +247,57 @@
#endif

/**
* Default LCD contrast for Graphical LCD displays
* LCD Contrast for Graphical Displays
*/
#define HAS_LCD_CONTRAST defined(LCD_CONTRAST_INIT)
#if ENABLED(CARTESIO_UI)
#define _LCD_CONTRAST_MIN 60
#define _LCD_CONTRAST_INIT 90
#define _LCD_CONTRAST_MAX 140
#elif ENABLED(miniVIKI)
#define _LCD_CONTRAST_MIN 75
#define _LCD_CONTRAST_INIT 95
#define _LCD_CONTRAST_MAX 115
#elif ENABLED(VIKI2)
#define _LCD_CONTRAST_INIT 140
#elif ENABLED(ELB_FULL_GRAPHIC_CONTROLLER)
#define _LCD_CONTRAST_MIN 90
#define _LCD_CONTRAST_INIT 110
#define _LCD_CONTRAST_MAX 130
#elif ENABLED(AZSMZ_12864)
#define _LCD_CONTRAST_MIN 120
#define _LCD_CONTRAST_INIT 190
#elif ENABLED(MKS_MINI_12864)
#define _LCD_CONTRAST_INIT 150
#elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
#define _LCD_CONTRAST_INIT 220
#elif ENABLED(ULTI_CONTROLLER)
#define _LCD_CONTRAST_INIT 127
#define _LCD_CONTRAST_MAX 254
#elif EITHER(MAKRPANEL, MINIPANEL)
#define _LCD_CONTRAST_INIT 17
#endif

#define HAS_LCD_CONTRAST defined(_LCD_CONTRAST_INIT)
#if HAS_LCD_CONTRAST
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
#endif
#ifndef LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN 0
#ifdef _LCD_CONTRAST_MIN
#define LCD_CONTRAST_MIN _LCD_CONTRAST_MIN
#else
#define LCD_CONTRAST_MIN 0
#endif
#endif
#ifndef LCD_CONTRAST_INIT
#define LCD_CONTRAST_INIT _LCD_CONTRAST_INIT
#endif
#ifndef LCD_CONTRAST_MAX
#define LCD_CONTRAST_MAX MAX(63, LCD_CONTRAST_INIT)
#ifdef _LCD_CONTRAST_MAX
#define LCD_CONTRAST_MAX _LCD_CONTRAST_MAX
#else
#define LCD_CONTRAST_MAX 63
#endif
#endif
#ifndef DEFAULT_LCD_CONTRAST
#define DEFAULT_LCD_CONTRAST LCD_CONTRAST_INIT
#endif
#endif

Expand Down

0 comments on commit 04a9962

Please sign in to comment.