From f6e8622360609d95464d256be5717db090191583 Mon Sep 17 00:00:00 2001 From: Mike La Spina Date: Sat, 22 Jan 2022 10:16:41 -0600 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20LCD=20contrast/brightness?= =?UTF-8?q?=20init=20(#23567)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_post.h | 1 + Marlin/src/lcd/marlinui.cpp | 3 +-- Marlin/src/module/settings.cpp | 14 +++++++++----- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 734676559c..2f06fe255a 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -377,6 +377,7 @@ #define _LCD_CONTRAST_MIN 255 #define _LCD_CONTRAST_INIT 255 #elif ENABLED(FYSETC_MINI_12864) + #define _LCD_CONTRAST_MIN 180 #define _LCD_CONTRAST_INIT 220 #elif ENABLED(ULTI_CONTROLLER) #define _LCD_CONTRAST_INIT 127 diff --git a/Marlin/src/lcd/marlinui.cpp b/Marlin/src/lcd/marlinui.cpp index c068082c09..7b9dc468e4 100644 --- a/Marlin/src/lcd/marlinui.cpp +++ b/Marlin/src/lcd/marlinui.cpp @@ -96,8 +96,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP; #endif #if HAS_LCD_CONTRAST - uint8_t MarlinUI::contrast; // Initialized by settings.load() - + uint8_t MarlinUI::contrast = LCD_CONTRAST_DEFAULT; // Initialized by settings.load() void MarlinUI::set_contrast(const uint8_t value) { contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX); _set_contrast(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 90bb9f6d6e..b737d41c2d 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -578,6 +578,9 @@ void MarlinSettings::postprocess() { update_software_endstops((AxisEnum)i); } + TERN_(HAS_LCD_CONTRAST, ui.refresh_contrast()); + TERN_(HAS_LCD_BRIGHTNESS, ui.refresh_brightness()); + TERN_(ENABLE_LEVELING_FADE_HEIGHT, set_z_fade_height(new_z_fade_height, false)); // false = no report TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); @@ -1986,10 +1989,10 @@ void MarlinSettings::postprocess() { // LCD Contrast // { - _FIELD_TEST(lcd_contrast); uint8_t lcd_contrast; + _FIELD_TEST(lcd_contrast); EEPROM_READ(lcd_contrast); - TERN_(HAS_LCD_CONTRAST, if (!validating) ui.set_contrast(lcd_contrast)); + TERN_(HAS_LCD_CONTRAST, if (!validating) ui.contrast = lcd_contrast); } // @@ -1997,8 +2000,9 @@ void MarlinSettings::postprocess() { // { uint8_t lcd_brightness; + _FIELD_TEST(lcd_brightness); EEPROM_READ(lcd_brightness); - TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.set_brightness(lcd_brightness)); + TERN_(HAS_LCD_BRIGHTNESS, if (!validating) ui.brightness = lcd_brightness); } // @@ -3018,12 +3022,12 @@ void MarlinSettings::reset() { // // LCD Contrast // - TERN_(HAS_LCD_CONTRAST, ui.set_contrast(DEFAULT_LCD_CONTRAST)); + TERN_(HAS_LCD_CONTRAST, ui.contrast = LCD_CONTRAST_DEFAULT); // // LCD Brightness // - TERN_(HAS_LCD_BRIGHTNESS, ui.set_brightness(DEFAULT_LCD_BRIGHTNESS)); + TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = DEFAULT_LCD_BRIGHTNESS); // // Controller Fan