mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 13:56:24 +00:00
🐛 E3V2 Brightness followup (#22821)
Co-authored-by: Scott Lahteine <github@thinkyhead.com>
This commit is contained in:
parent
a7fdaabd54
commit
1ac7a56a82
@ -32,7 +32,7 @@
|
||||
*/
|
||||
void GcodeSuite::M250() {
|
||||
if (parser.seenval('C'))
|
||||
ui.set_contrast(parser.value_int());
|
||||
ui.set_contrast(parser.value_byte());
|
||||
else
|
||||
M250_report();
|
||||
}
|
||||
|
@ -500,6 +500,20 @@
|
||||
#define HAS_DWIN_E3V2 1
|
||||
#endif
|
||||
|
||||
// E3V2 extras
|
||||
#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
|
||||
#define SERIAL_CATCHALL 0
|
||||
#ifndef LCD_SERIAL_PORT
|
||||
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO)
|
||||
#define LCD_SERIAL_PORT 1
|
||||
#else
|
||||
#define LCD_SERIAL_PORT 3 // Creality 4.x board
|
||||
#endif
|
||||
#endif
|
||||
#define HAS_LCD_BRIGHTNESS 1
|
||||
#define LCD_BRIGHTNESS_MAX 250
|
||||
#endif
|
||||
|
||||
#if IS_ULTRA_LCD
|
||||
#define HAS_WIRED_LCD 1
|
||||
#if ENABLED(DOGLCD)
|
||||
@ -1111,17 +1125,6 @@
|
||||
#define HAS_ETHERNET 1
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||
#define SERIAL_CATCHALL 0
|
||||
#ifndef LCD_SERIAL_PORT
|
||||
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO)
|
||||
#define LCD_SERIAL_PORT 1
|
||||
#else
|
||||
#define LCD_SERIAL_PORT 3 // Creality 4.x board
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
// Fallback Stepper Driver types that don't depend on Configuration_adv.h
|
||||
#ifndef X_DRIVER_TYPE
|
||||
#define X_DRIVER_TYPE A4988
|
||||
|
@ -423,11 +423,6 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||
#define HAS_LCD_BRIGHTNESS 1
|
||||
#define MAX_LCD_BRIGHTNESS 31
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Override the SD_DETECT_STATE set in Configuration_adv.h
|
||||
* and enable sharing of onboard SD host drives (all platforms but AGCM4)
|
||||
|
@ -376,12 +376,9 @@ void MarlinUI::clear_lcd() {
|
||||
lcd.clear_buffer();
|
||||
}
|
||||
|
||||
int16_t MarlinUI::contrast; // Initialized by settings.load()
|
||||
|
||||
void MarlinUI::set_contrast(const int16_t value) {
|
||||
contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
|
||||
lcd.setContrast(contrast);
|
||||
}
|
||||
#if HAS_LCD_CONTRAST
|
||||
void MarlinUI::_set_contrast() { lcd.setContrast(contrast); }
|
||||
#endif
|
||||
|
||||
static void center_text_P(PGM_P pstart, uint8_t y) {
|
||||
uint8_t len = utf8_strlen_P(pstart);
|
||||
|
@ -93,14 +93,7 @@ U8G_CLASS u8g;
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_CONTRAST
|
||||
|
||||
int16_t MarlinUI::contrast = DEFAULT_LCD_CONTRAST;
|
||||
|
||||
void MarlinUI::set_contrast(const int16_t value) {
|
||||
contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
|
||||
u8g.setContrast(contrast);
|
||||
}
|
||||
|
||||
void MarlinUI::_set_contrast() { u8g.setContrast(contrast); }
|
||||
#endif
|
||||
|
||||
void MarlinUI::set_font(const MarlinFont font_nr) {
|
||||
|
@ -78,14 +78,16 @@ bool DWIN_Handshake() {
|
||||
&& databuf[3] == 'K' );
|
||||
}
|
||||
|
||||
// Set the backlight brightness
|
||||
// brightness: (0x00-0x1F)
|
||||
void DWIN_LCD_Brightness(const uint8_t brightness) {
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
// Set LCD backlight (from DWIN Enhanced)
|
||||
// brightness: 0x00-0xFF
|
||||
void DWIN_LCD_Brightness(const uint8_t brightness) {
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x30);
|
||||
DWIN_Byte(i, _MAX(brightness, 0x1F));
|
||||
DWIN_Byte(i, brightness);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// Set screen display direction
|
||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||
|
@ -87,9 +87,11 @@ bool DWIN_Handshake();
|
||||
// DWIN startup
|
||||
void DWIN_Startup();
|
||||
|
||||
// Set the backlight brightness
|
||||
// brightness: (0x00-0xFF)
|
||||
void DWIN_LCD_Brightness(const uint8_t brightness);
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
// Set the backlight brightness
|
||||
// brightness: (0x00-0xFF)
|
||||
void DWIN_LCD_Brightness(const uint8_t brightness);
|
||||
#endif
|
||||
|
||||
// Set screen display direction
|
||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||
|
@ -1816,6 +1816,10 @@ void HMI_SDCardInit() { card.cdroot(); }
|
||||
|
||||
void MarlinUI::refresh() { /* Nothing to see here */ }
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(SCROLL_LONG_FILENAMES)
|
||||
|
||||
char shift_name[LONG_FILENAME_LENGTH + 1];
|
||||
|
@ -865,6 +865,10 @@ void HMI_SDCardInit() { card.cdroot(); }
|
||||
|
||||
void MarlinUI::refresh() { /* Nothing to see here */ }
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); }
|
||||
#endif
|
||||
|
||||
#define ICON_Folder ICON_More
|
||||
|
||||
#if ENABLED(SCROLL_LONG_FILENAMES)
|
||||
@ -2186,9 +2190,8 @@ void SetPID(celsius_t t, heater_id_t h) {
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
void ApplyBrightness() { ui.set_brightness(HMI_value.Value); }
|
||||
void LiveBrightness() { DWIN_LCD_Brightness(HMI_value.Value); }
|
||||
void SetBrightness() { SetIntOnClick(MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS, ui.brightness, ApplyBrightness, LiveBrightness); }
|
||||
void LiveBrightness() { ui.set_brightness(HMI_value.Value); }
|
||||
void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, nullptr, LiveBrightness); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
|
@ -2717,7 +2717,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
Draw_Float(ui.brightness, row, false, 1);
|
||||
}
|
||||
else
|
||||
Modify_Value(ui.brightness, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS, 1, ui.refresh_brightness);
|
||||
Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness);
|
||||
break;
|
||||
case VISUAL_TIME_FORMAT:
|
||||
if (draw) {
|
||||
@ -3879,7 +3879,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||
Draw_Float(ui.brightness, row, false, 1);
|
||||
}
|
||||
else
|
||||
Modify_Value(ui.brightness, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS, 1, ui.refresh_brightness);
|
||||
Modify_Value(ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, 1, ui.refresh_brightness);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@ -4800,6 +4800,10 @@ void CrealityDWINClass::Update() {
|
||||
|
||||
void MarlinUI::update() { CrealityDWIN.Update(); }
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); }
|
||||
#endif
|
||||
|
||||
void CrealityDWINClass::State_Update() {
|
||||
if ((print_job_timer.isRunning() || print_job_timer.isPaused()) != printing) {
|
||||
if (!printing) Start_Print(card.isFileOpen() || TERN0(POWER_LOSS_RECOVERY, recovery.valid()));
|
||||
|
@ -254,6 +254,10 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||
#endif
|
||||
}
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
void MarlinUI::_set_brightness() { DWIN_LCD_Brightness(backlight ? brightness : 0); }
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_MENU
|
||||
|
||||
#include "../../menu/menu.h"
|
||||
|
@ -95,16 +95,23 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_CONTRAST
|
||||
uint8_t MarlinUI::contrast; // Initialized by settings.load()
|
||||
|
||||
void MarlinUI::set_contrast(const uint8_t value) {
|
||||
contrast = constrain(value, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX);
|
||||
_set_contrast();
|
||||
}
|
||||
#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
|
||||
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
|
||||
TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_LCD_Brightness(backlight ? brightness : 0));
|
||||
if (backlight) brightness = constrain(value, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX);
|
||||
_set_brightness();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -247,17 +247,18 @@ public:
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
#ifndef MIN_LCD_BRIGHTNESS
|
||||
#define MIN_LCD_BRIGHTNESS 1
|
||||
#ifndef LCD_BRIGHTNESS_MIN
|
||||
#define LCD_BRIGHTNESS_MIN 1
|
||||
#endif
|
||||
#ifndef MAX_LCD_BRIGHTNESS
|
||||
#define MAX_LCD_BRIGHTNESS 255
|
||||
#ifndef LCD_BRIGHTNESS_MAX
|
||||
#define LCD_BRIGHTNESS_MAX 255
|
||||
#endif
|
||||
#ifndef DEFAULT_LCD_BRIGHTNESS
|
||||
#define DEFAULT_LCD_BRIGHTNESS MAX_LCD_BRIGHTNESS
|
||||
#define DEFAULT_LCD_BRIGHTNESS LCD_BRIGHTNESS_MAX
|
||||
#endif
|
||||
static uint8_t brightness;
|
||||
static bool backlight;
|
||||
static void _set_brightness(); // Implementation-specific
|
||||
static void set_brightness(const uint8_t value);
|
||||
FORCE_INLINE static void refresh_brightness() { set_brightness(brightness); }
|
||||
#endif
|
||||
@ -425,8 +426,9 @@ public:
|
||||
static uint8_t lcd_status_update_delay;
|
||||
|
||||
#if HAS_LCD_CONTRAST
|
||||
static int16_t contrast;
|
||||
static void set_contrast(const int16_t value);
|
||||
static uint8_t contrast;
|
||||
static void _set_contrast(); // Implementation-specific
|
||||
static void set_contrast(const uint8_t value);
|
||||
FORCE_INLINE static void refresh_contrast() { set_contrast(contrast); }
|
||||
#endif
|
||||
|
||||
|
@ -528,8 +528,11 @@ void menu_configuration() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_LCD_BRIGHTNESS
|
||||
EDIT_ITEM_FAST(uint8, MSG_BRIGHTNESS, &ui.brightness, LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.refresh_brightness, true);
|
||||
#endif
|
||||
#if HAS_LCD_CONTRAST
|
||||
EDIT_ITEM(int3, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
|
||||
EDIT_ITEM_FAST(uint8, MSG_CONTRAST, &ui.contrast, LCD_CONTRAST_MIN, LCD_CONTRAST_MAX, ui.refresh_contrast, true);
|
||||
#endif
|
||||
#if ENABLED(FWRETRACT)
|
||||
SUBMENU(MSG_RETRACT, menu_config_retract);
|
||||
|
@ -352,7 +352,7 @@ typedef struct SettingsDataStruct {
|
||||
//
|
||||
// HAS_LCD_CONTRAST
|
||||
//
|
||||
int16_t lcd_contrast; // M250 C
|
||||
uint8_t lcd_contrast; // M250 C
|
||||
|
||||
//
|
||||
// HAS_LCD_BRIGHTNESS
|
||||
@ -1017,7 +1017,7 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
{
|
||||
_FIELD_TEST(lcd_contrast);
|
||||
const int16_t lcd_contrast = TERN(HAS_LCD_CONTRAST, ui.contrast, 127);
|
||||
const uint8_t lcd_contrast = TERN(HAS_LCD_CONTRAST, ui.contrast, 127);
|
||||
EEPROM_WRITE(lcd_contrast);
|
||||
}
|
||||
|
||||
@ -1884,7 +1884,7 @@ void MarlinSettings::postprocess() {
|
||||
//
|
||||
{
|
||||
_FIELD_TEST(lcd_contrast);
|
||||
int16_t lcd_contrast;
|
||||
uint8_t lcd_contrast;
|
||||
EEPROM_READ(lcd_contrast);
|
||||
if (!validating) {
|
||||
TERN_(HAS_LCD_CONTRAST, ui.set_contrast(lcd_contrast));
|
||||
|
@ -24,7 +24,7 @@ opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY
|
||||
exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
|
||||
|
||||
use_example_configs "Creality/Ender-3 V2/MarlinUI"
|
||||
opt_add SDCARD_EEPROM_EMULATION NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
|
||||
opt_add SDCARD_EEPROM_EMULATION AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
|
||||
exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
|
||||
|
||||
restore_configs
|
||||
|
Loading…
Reference in New Issue
Block a user