🚸 Case Light, LED menus for E3V2 DWIN Enhanced UI (#23590)
This commit is contained in:
@ -95,6 +95,14 @@
|
||||
#include "printstats.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
#include "../../../feature/caselight.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
#include "../../../feature/leds/leds.h"
|
||||
#endif
|
||||
|
||||
#include <WString.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -249,6 +257,12 @@ MenuClass *MaxJerkMenu = nullptr;
|
||||
MenuClass *StepsMenu = nullptr;
|
||||
MenuClass *HotendPIDMenu = nullptr;
|
||||
MenuClass *BedPIDMenu = nullptr;
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
MenuClass *CaseLightMenu = nullptr;
|
||||
#endif
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
MenuClass *LedControlMenu = nullptr;
|
||||
#endif
|
||||
#if HAS_BED_PROBE
|
||||
MenuClass *ZOffsetWizMenu = nullptr;
|
||||
#endif
|
||||
@ -991,7 +1005,7 @@ void Redraw_SD_List() {
|
||||
}
|
||||
else {
|
||||
DWIN_Draw_Rectangle(1, HMI_data.AlertBg_Color, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
|
||||
DWINUI::Draw_CenteredString(font16x32, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED));
|
||||
DWINUI::Draw_CenteredString(font12x24, HMI_data.AlertTxt_Color, MBASE(3), GET_TEXT_F(MSG_MEDIA_NOT_INSERTED));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1891,12 +1905,22 @@ void DWIN_StoreSettings(char *buff) {
|
||||
}
|
||||
|
||||
void DWIN_LoadSettings(const char *buff) {
|
||||
memcpy(&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size));
|
||||
// (void *)-> Avoid Warning when save data different from uintX_t in HMI_data_t struct
|
||||
memcpy((void *)&HMI_data, buff, _MIN(sizeof(HMI_data), eeprom_data_size));
|
||||
dwin_zoffset = TERN0(HAS_BED_PROBE, probe.offset.z);
|
||||
if (HMI_data.Text_Color == HMI_data.Background_Color) DWIN_SetColorDefaults();
|
||||
DWINUI::SetColors(HMI_data.Text_Color, HMI_data.Background_Color);
|
||||
TERN_(PREVENT_COLD_EXTRUSION, ApplyExtMinT());
|
||||
feedrate_percentage = 100;
|
||||
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
|
||||
// Apply Case light brightness
|
||||
caselight.brightness = HMI_data.CaseLight_Brightness;
|
||||
caselight.update_brightness();
|
||||
#endif
|
||||
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
|
||||
// Apply Led Color
|
||||
leds.set_color(HMI_data.Led_Color);
|
||||
#endif
|
||||
}
|
||||
|
||||
void MarlinUI::kill_screen(FSTR_P const lcd_error, FSTR_P const lcd_component) {
|
||||
@ -2288,6 +2312,41 @@ void SetPID(celsius_t t, heater_id_t h) {
|
||||
void SetBrightness() { SetIntOnClick(LCD_BRIGHTNESS_MIN, LCD_BRIGHTNESS_MAX, ui.brightness, nullptr, LiveBrightness); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
void SetCaseLight() {
|
||||
caselight.on = !caselight.on;
|
||||
caselight.update_enabled();
|
||||
Draw_Chkb_Line(CurrentMenu->line(), caselight.on);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
void LiveCaseLightBrightness() { HMI_data.CaseLight_Brightness = caselight.brightness = HMI_value.Value; caselight.update_brightness(); }
|
||||
void SetCaseLightBrightness() { SetIntOnClick(0, 255, caselight.brightness, nullptr, LiveCaseLightBrightness); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
#if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
|
||||
void SetLedStatus() {
|
||||
leds.toggle();
|
||||
Draw_Chkb_Line(CurrentMenu->line(), leds.lights_on);
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
#endif
|
||||
#if ENABLED(HAS_COLOR_LEDS)
|
||||
void LiveLedColorR() { leds.color.r = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); }
|
||||
void SetLedColorR() { SetIntOnClick(0, 255, leds.color.r, nullptr, LiveLedColorR); }
|
||||
void LiveLedColorG() { leds.color.g = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); }
|
||||
void SetLedColorG() { SetIntOnClick(0, 255, leds.color.g, nullptr, LiveLedColorG); }
|
||||
void LiveLedColorB() { leds.color.b = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); }
|
||||
void SetLedColorB() { SetIntOnClick(0, 255, leds.color.b, nullptr, LiveLedColorB); }
|
||||
#if HAS_WHITE_LED
|
||||
void LiveLedColorW() { leds.color.w = HMI_value.Value; HMI_data.Led_Color = leds.color; leds.update(); }
|
||||
void SetLedColorW() { SetIntOnClick(0, 255, leds.color.w, nullptr, LiveLedColorW); }
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
void SetEnableSound() {
|
||||
ui.buzzer_enabled = !ui.buzzer_enabled;
|
||||
@ -2774,6 +2833,16 @@ void onDrawLanguage(MenuItemClass* menuitem, int8_t line) {
|
||||
void onDrawPwrLossR(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, recovery.enabled); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
void onDrawCaseLight(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, caselight.on); }
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
#if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
|
||||
void onDrawLedStatus(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, leds.lights_on); }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(SOUND_MENU_ITEM)
|
||||
void onDrawEnableSound(MenuItemClass* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, ui.buzzer_enabled); }
|
||||
#endif
|
||||
@ -3265,8 +3334,18 @@ void Draw_Control_Menu() {
|
||||
if (CurrentMenu != ControlMenu) {
|
||||
CurrentMenu = ControlMenu;
|
||||
SetMenuTitle({103, 1, 28, 14}, GET_TEXT_F(MSG_CONTROL));
|
||||
DWINUI::MenuItemsPrepare(9);
|
||||
DWINUI::MenuItemsPrepare(11);
|
||||
MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_Main_Menu);
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawSubMenu, Draw_CaseLight_Menu);
|
||||
#else
|
||||
MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight);
|
||||
#endif
|
||||
#endif
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LED_CONTROL), onDrawSubMenu, Draw_LedControl_Menu);
|
||||
#endif
|
||||
MENU_ITEM(ICON_Temperature, GET_TEXT_F(MSG_TEMPERATURE), onDrawTempSubMenu, Draw_Temperature_Menu);
|
||||
MENU_ITEM(ICON_Motion, GET_TEXT_F(MSG_MOTION), onDrawMotionSubMenu, Draw_Motion_Menu);
|
||||
#if ENABLED(EEPROM_SETTINGS)
|
||||
@ -3469,6 +3548,47 @@ void Draw_GetColor_Menu() {
|
||||
DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
|
||||
}
|
||||
|
||||
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
|
||||
void Draw_CaseLight_Menu() {
|
||||
checkkey = Menu;
|
||||
if (!CaseLightMenu) CaseLightMenu = new MenuClass();
|
||||
if (CurrentMenu != CaseLightMenu) {
|
||||
CurrentMenu = CaseLightMenu;
|
||||
SetMenuTitle({0}, GET_TEXT_F(MSG_CASE_LIGHT)); // TODO: Chinese, English "Case Light" JPG
|
||||
DWINUI::MenuItemsPrepare(3);
|
||||
MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu);
|
||||
MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight);
|
||||
EDIT_ITEM(ICON_Brightness, GET_TEXT_F(MSG_CASE_LIGHT_BRIGHTNESS), onDrawPInt8Menu, SetCaseLightBrightness, &caselight.brightness);
|
||||
}
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
void Draw_LedControl_Menu() {
|
||||
checkkey = Menu;
|
||||
if (!LedControlMenu) LedControlMenu = new MenuClass();
|
||||
if (CurrentMenu != LedControlMenu) {
|
||||
CurrentMenu = LedControlMenu;
|
||||
SetMenuTitle({0}, GET_TEXT_F(MSG_LED_CONTROL)); // TODO: Chinese, English "LED Control" JPG
|
||||
DWINUI::MenuItemsPrepare(6);
|
||||
MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Draw_Control_Menu);
|
||||
#if !BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
|
||||
MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LEDS), onDrawLedStatus, SetLedStatus);
|
||||
#endif
|
||||
#if (HAS_COLOR_LEDS)
|
||||
EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_RED), onDrawPInt8Menu, SetLedColorR, &leds.color.r);
|
||||
EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_GREEN), onDrawPInt8Menu, SetLedColorG, &leds.color.g);
|
||||
EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_BLUE), onDrawPInt8Menu, SetLedColorB, &leds.color.b);
|
||||
#if ENABLED(HAS_WHITE_LED)
|
||||
EDIT_ITEM(ICON_LedControl, GET_TEXT_F(MSG_COLORS_WHITE), onDrawPInt8Menu, SetLedColorW, &leds.color.w);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
void Draw_Tune_Menu() {
|
||||
checkkey = Menu;
|
||||
if (!TuneMenu) TuneMenu = new MenuClass();
|
||||
@ -3477,6 +3597,11 @@ void Draw_Tune_Menu() {
|
||||
SetMenuTitle({73, 2, 28, 12}, GET_TEXT_F(MSG_TUNE)); // TODO: Chinese, English "Tune" JPG
|
||||
DWINUI::MenuItemsPrepare(14);
|
||||
MENU_ITEM(ICON_Back, GET_TEXT_F(MSG_BUTTON_BACK), onDrawBack, Goto_PrintProcess);
|
||||
#if ENABLED(CASE_LIGHT_MENU)
|
||||
MENU_ITEM(ICON_CaseLight, GET_TEXT_F(MSG_CASE_LIGHT), onDrawCaseLight, SetCaseLight);
|
||||
#elif ENABLED(LED_CONTROL_MENU) && DISABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
MENU_ITEM(ICON_LedControl, GET_TEXT_F(MSG_LEDS), onDrawLedStatus, SetLedStatus);
|
||||
#endif
|
||||
EDIT_ITEM(ICON_Speed, GET_TEXT_F(MSG_SPEED), onDrawSpeedItem, SetSpeed, &feedrate_percentage);
|
||||
#if HAS_HOTEND
|
||||
HotendTargetItem = EDIT_ITEM(ICON_HotendTemp, GET_TEXT_F(MSG_UBL_SET_TEMP_HOTEND), onDrawHotendTemp, SetHotendTemp, &thermalManager.temp_hotend[0].target);
|
||||
|
@ -223,6 +223,12 @@ void Draw_Tramming_Menu();
|
||||
#endif
|
||||
void Draw_SelectColors_Menu();
|
||||
void Draw_GetColor_Menu();
|
||||
#if BOTH(CASE_LIGHT_MENU, CASELIGHT_USES_BRIGHTNESS)
|
||||
void Draw_CaseLight_Menu();
|
||||
#endif
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
void Draw_LedControl_Menu();
|
||||
#endif
|
||||
void Draw_Tune_Menu();
|
||||
void Draw_Motion_Menu();
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
|
@ -30,6 +30,9 @@
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "../common/dwin_color.h"
|
||||
#if ENABLED(LED_CONTROL_MENU)
|
||||
#include "../../../feature/leds/leds.h"
|
||||
#endif
|
||||
|
||||
#define Def_Background_Color RGB( 1, 12, 8)
|
||||
#define Def_Cursor_color RGB(20, 49, 31)
|
||||
@ -53,8 +56,15 @@
|
||||
#define HAS_ESDIAG 1
|
||||
#define DEFAULT_LCD_BRIGHTNESS 127
|
||||
|
||||
#if ENABLED(LED_CONTROL_MENU, HAS_COLOR_LEDS)
|
||||
#define Def_Leds_Color LEDColorWhite()
|
||||
#endif
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
#define Def_CaseLight_Brightness 255
|
||||
#endif
|
||||
|
||||
typedef struct {
|
||||
// Color settings
|
||||
// Color settings
|
||||
uint16_t Background_Color = Def_Background_Color;
|
||||
uint16_t Cursor_color = Def_Cursor_color;
|
||||
uint16_t TitleBg_color = Def_TitleBg_color;
|
||||
@ -73,19 +83,27 @@ typedef struct {
|
||||
uint16_t Barfill_Color = Def_Barfill_Color;
|
||||
uint16_t Indicator_Color = Def_Indicator_Color;
|
||||
uint16_t Coordinate_Color = Def_Coordinate_Color;
|
||||
//
|
||||
#if defined(PREHEAT_1_TEMP_HOTEND) && HAS_HOTEND
|
||||
// Temperatures
|
||||
#if HAS_HOTEND && defined(PREHEAT_1_TEMP_HOTEND)
|
||||
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
|
||||
#endif
|
||||
#if defined(PREHEAT_1_TEMP_BED) && HAS_HEATED_BED
|
||||
#if HAS_HEATED_BED && defined(PREHEAT_1_TEMP_BED)
|
||||
int16_t BedPidT = PREHEAT_1_TEMP_BED;
|
||||
#endif
|
||||
#if ANY(HAS_HOTEND, HAS_HEATED_BED)
|
||||
#if HAS_HOTEND || HAS_HEATED_BED
|
||||
int16_t PidCycles = 10;
|
||||
#endif
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
int16_t ExtMinT = EXTRUDE_MINTEMP;
|
||||
#endif
|
||||
// Led
|
||||
#if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS)
|
||||
LEDColor Led_Color = Def_Leds_Color;
|
||||
#endif
|
||||
// Case Light
|
||||
#if ENABLED(CASELIGHT_USES_BRIGHTNESS)
|
||||
uint8_t CaseLight_Brightness = Def_CaseLight_Brightness;
|
||||
#endif
|
||||
} HMI_data_t;
|
||||
|
||||
static constexpr size_t eeprom_data_size = 64;
|
||||
|
@ -76,6 +76,8 @@
|
||||
#define ICON_Scolor ICON_MaxSpeed
|
||||
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
||||
#define ICON_Sound ICON_Cool
|
||||
#define ICON_CaseLight ICON_Motion
|
||||
#define ICON_LedControl ICON_Motion
|
||||
|
||||
// Extended and default UI Colors
|
||||
#define Color_Black 0
|
||||
|
@ -609,6 +609,7 @@ namespace Language_en {
|
||||
LSTR MSG_COLORS_RED = _UxGT("Red");
|
||||
LSTR MSG_COLORS_GREEN = _UxGT("Green");
|
||||
LSTR MSG_COLORS_BLUE = _UxGT("Blue");
|
||||
LSTR MSG_COLORS_WHITE = _UxGT("White");
|
||||
LSTR MSG_UI_LANGUAGE = _UxGT("UI Language");
|
||||
LSTR MSG_SOUND_ENABLE = _UxGT("Enable sound");
|
||||
LSTR MSG_LOCKSCREEN = _UxGT("Lock Screen");
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "../MarlinCore.h" // for printingIsPaused
|
||||
|
||||
#ifdef LED_BACKLIGHT_TIMEOUT
|
||||
#if LED_POWEROFF_TIMEOUT > 0 || BOTH(HAS_WIRED_LCD, PRINTER_EVENT_LEDS)
|
||||
#include "../feature/leds/leds.h"
|
||||
#endif
|
||||
|
||||
@ -277,7 +277,7 @@ void MarlinUI::init() {
|
||||
#include "../feature/power_monitor.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT)
|
||||
#if LED_POWEROFF_TIMEOUT > 0
|
||||
#include "../feature/power.h"
|
||||
#endif
|
||||
|
||||
@ -676,7 +676,7 @@ void MarlinUI::init() {
|
||||
TERN_(HAS_MARLINUI_MENU, return_to_status());
|
||||
|
||||
// RED ALERT. RED ALERT.
|
||||
#ifdef LED_BACKLIGHT_TIMEOUT
|
||||
#if ENABLED(PRINTER_EVENT_LEDS)
|
||||
leds.set_color(LEDColorRed());
|
||||
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
|
||||
neo.set_background_color(255, 0, 0, 0);
|
||||
@ -884,7 +884,7 @@ void MarlinUI::init() {
|
||||
static uint16_t max_display_update_time = 0;
|
||||
millis_t ms = millis();
|
||||
|
||||
#if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT)
|
||||
#if LED_POWEROFF_TIMEOUT > 0
|
||||
leds.update_timeout(powerManager.psu_on);
|
||||
#endif
|
||||
|
||||
@ -1035,7 +1035,7 @@ void MarlinUI::init() {
|
||||
|
||||
refresh(LCDVIEW_REDRAW_NOW);
|
||||
|
||||
#if ENABLED(PSU_CONTROL) && defined(LED_BACKLIGHT_TIMEOUT)
|
||||
#if LED_POWEROFF_TIMEOUT > 0
|
||||
if (!powerManager.psu_on) leds.reset_timeout(ms);
|
||||
#endif
|
||||
}
|
||||
@ -1701,13 +1701,13 @@ void MarlinUI::init() {
|
||||
|
||||
refresh();
|
||||
|
||||
#if HAS_WIRED_LCD || defined(LED_BACKLIGHT_TIMEOUT)
|
||||
#if HAS_WIRED_LCD || LED_POWEROFF_TIMEOUT > 0
|
||||
const millis_t ms = millis();
|
||||
#endif
|
||||
|
||||
TERN_(HAS_WIRED_LCD, next_lcd_update_ms = ms + LCD_UPDATE_INTERVAL); // Delay LCD update for SD activity
|
||||
|
||||
#ifdef LED_BACKLIGHT_TIMEOUT
|
||||
#if LED_POWEROFF_TIMEOUT > 0
|
||||
leds.reset_timeout(ms);
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user