Skip to content

Commit

Permalink
🐛 Fix LCD contrast/brightness init (MarlinFirmware#23567)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
  • Loading branch information
2 people authored and tomek2k1 committed Jan 13, 2023
1 parent 45534a4 commit 8878fcc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
14 changes: 9 additions & 5 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -1986,19 +1989,20 @@ 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);
}

//
// LCD Brightness
//
{
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);
}

//
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8878fcc

Please sign in to comment.