M256 LCD brightness (#22478)

This commit is contained in:
Scott Lahteine
2021-08-01 14:28:53 -05:00
parent eeac85642f
commit 4b2fdbeeb1
10 changed files with 114 additions and 13 deletions

View File

@ -98,6 +98,17 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
}
#endif
#if HAS_LCD_BRIGHTNESS
uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS;
bool MarlinUI::backlight = true;
void MarlinUI::set_brightness(const uint8_t value) {
backlight = !!value;
if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
// Set brightness on enabled LCD here
}
#endif
#if ENABLED(SOUND_MENU_ITEM)
bool MarlinUI::buzzer_enabled = true;
#endif

View File

@ -239,6 +239,22 @@ public:
static void media_changed(const uint8_t old_stat, const uint8_t stat);
#endif
#if HAS_LCD_BRIGHTNESS
#ifndef MIN_LCD_BRIGHTNESS
#define MIN_LCD_BRIGHTNESS 1
#endif
#ifndef MAX_LCD_BRIGHTNESS
#define MAX_LCD_BRIGHTNESS 255
#endif
#ifndef DEFAULT_LCD_BRIGHTNESS
#define DEFAULT_LCD_BRIGHTNESS MAX_LCD_BRIGHTNESS
#endif
static uint8_t brightness;
static bool backlight;
static void set_brightness(const uint8_t value);
FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
#endif
#if ENABLED(DWIN_CREALITY_LCD)
static void refresh();
#else