1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-28 14:24:34 +00:00

🐛 Fix LCD contrast/brightness init (#23567)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Mike La Spina 2022-01-22 10:16:41 -06:00 committed by GitHub
parent d5f2334140
commit f6e8622360
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 7 deletions

View File

@ -377,6 +377,7 @@
#define _LCD_CONTRAST_MIN 255 #define _LCD_CONTRAST_MIN 255
#define _LCD_CONTRAST_INIT 255 #define _LCD_CONTRAST_INIT 255
#elif ENABLED(FYSETC_MINI_12864) #elif ENABLED(FYSETC_MINI_12864)
#define _LCD_CONTRAST_MIN 180
#define _LCD_CONTRAST_INIT 220 #define _LCD_CONTRAST_INIT 220
#elif ENABLED(ULTI_CONTROLLER) #elif ENABLED(ULTI_CONTROLLER)
#define _LCD_CONTRAST_INIT 127 #define _LCD_CONTRAST_INIT 127

View File

@ -96,8 +96,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
#endif #endif
#if HAS_LCD_CONTRAST #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) { void MarlinUI::set_contrast(const uint8_t value) {
contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX); contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
_set_contrast(); _set_contrast();

View File

@ -578,6 +578,9 @@ void MarlinSettings::postprocess() {
update_software_endstops((AxisEnum)i); 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_(ENABLE_LEVELING_FADE_HEIGHT, set_z_fade_height(new_z_fade_height, false)); // false = no report
TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level()); TERN_(AUTO_BED_LEVELING_BILINEAR, refresh_bed_level());
@ -1986,10 +1989,10 @@ void MarlinSettings::postprocess() {
// LCD Contrast // LCD Contrast
// //
{ {
_FIELD_TEST(lcd_contrast);
uint8_t lcd_contrast; uint8_t lcd_contrast;
_FIELD_TEST(lcd_contrast);
EEPROM_READ(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; uint8_t lcd_brightness;
_FIELD_TEST(lcd_brightness);
EEPROM_READ(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 // LCD Contrast
// //
TERN_(HAS_LCD_CONTRAST, ui.set_contrast(DEFAULT_LCD_CONTRAST)); TERN_(HAS_LCD_CONTRAST, ui.contrast = LCD_CONTRAST_DEFAULT);
// //
// LCD Brightness // LCD Brightness
// //
TERN_(HAS_LCD_BRIGHTNESS, ui.set_brightness(DEFAULT_LCD_BRIGHTNESS)); TERN_(HAS_LCD_BRIGHTNESS, ui.brightness = DEFAULT_LCD_BRIGHTNESS);
// //
// Controller Fan // Controller Fan