🚸 Case Light, LED menus for E3V2 DWIN Enhanced UI (#23590)

This commit is contained in:
GHGiampy 2022-02-02 00:35:38 +01:00 committed by Scott Lahteine
parent 4ba4ab1c75
commit ac76ed7ece
19 changed files with 278 additions and 112 deletions

View file

@ -373,6 +373,7 @@
//#define PSU_DEFAULT_OFF // Keep power off until enabled directly with M80
//#define PSU_POWERUP_DELAY 250 // (ms) Delay for the PSU to warm up to full power
//#define LED_POWEROFF_TIMEOUT 10000 // (ms) Turn off LEDs after power-off, with this amount of delay
//#define POWER_OFF_TIMER // Enable M81 D<seconds> to power off after a delay
//#define POWER_OFF_WAIT_FOR_COOLDOWN // Enable M81 S to power off only after cooldown

View file

@ -1294,7 +1294,6 @@
#if HAS_MARLINUI_MENU
// Add Probe Z Offset calibration to the Z Probe Offsets menu
#if BOTH(HAS_BED_PROBE, AUTO_BED_LEVELING_BILINEAR)
// Add calibration in the Probe Offsets menu to compensate for X-axis twist.
//#define X_AXIS_TWIST_COMPENSATION
@ -1319,32 +1318,6 @@
// BACK menu items keep the highlight at the top
//#define TURBO_BACK_MENU_ITEM
/**
* LED Control Menu
* Add LED Control to the LCD menu
*/
//#define LED_CONTROL_MENU
#if ENABLED(LED_CONTROL_MENU)
#define LED_COLOR_PRESETS // Enable the Preset Color menu option
//#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option
#if ENABLED(LED_COLOR_PRESETS)
#define LED_USER_PRESET_RED 255 // User defined RED value
#define LED_USER_PRESET_GREEN 128 // User defined GREEN value
#define LED_USER_PRESET_BLUE 0 // User defined BLUE value
#define LED_USER_PRESET_WHITE 255 // User defined WHITE value
#define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
#define NEO2_USER_PRESET_RED 255 // User defined RED value
#define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value
#define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value
#define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value
#define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip
#endif
#endif
// Insert a menu for preheating at the top level to allow for quick access
//#define PREHEAT_SHORTCUT_MENU_ITEM
@ -1376,6 +1349,33 @@
// Show the E position (filament used) during printing
//#define LCD_SHOW_E_TOTAL
/**
* LED Control Menu
* Add LED Control to the LCD menu
*/
//#define LED_CONTROL_MENU
#if ENABLED(LED_CONTROL_MENU)
#define LED_COLOR_PRESETS // Enable the Preset Color menu option
//#define NEO2_COLOR_PRESETS // Enable a second NeoPixel Preset Color menu option
#if ENABLED(LED_COLOR_PRESETS)
#define LED_USER_PRESET_RED 255 // User defined RED value
#define LED_USER_PRESET_GREEN 128 // User defined GREEN value
#define LED_USER_PRESET_BLUE 0 // User defined BLUE value
#define LED_USER_PRESET_WHITE 255 // User defined WHITE value
#define LED_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define LED_USER_PRESET_STARTUP // Have the printer display the user preset color on startup
#endif
#if ENABLED(NEO2_COLOR_PRESETS)
#define NEO2_USER_PRESET_RED 255 // User defined RED value
#define NEO2_USER_PRESET_GREEN 128 // User defined GREEN value
#define NEO2_USER_PRESET_BLUE 0 // User defined BLUE value
#define NEO2_USER_PRESET_WHITE 255 // User defined WHITE value
#define NEO2_USER_PRESET_BRIGHTNESS 255 // User defined intensity
//#define NEO2_USER_PRESET_STARTUP // Have the printer display the user preset color on startup for the second strip
#endif
#endif
#endif
// LCD Print Progress options

View file

@ -64,7 +64,17 @@ void CaseLight::update(const bool sflag) {
#endif
#if CASE_LIGHT_IS_COLOR_LED
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL)
if (on)
// Use current color of (NeoPixel) leds and new brightness level
leds.set_color(LEDColor(leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, leds.color.w) OPTARG(NEOPIXEL_LED, n10ct)));
else
// Switch off leds
leds.set_off();
#else
// Use CaseLight color (CASE_LIGHT_DEFAULT_COLOR) and new brightness level
leds.set_color(LEDColor(color.r, color.g, color.b OPTARG(HAS_WHITE_LED, color.w) OPTARG(NEOPIXEL_LED, n10ct)));
#endif
#else // !CASE_LIGHT_IS_COLOR_LED
#if CASELIGHT_USES_BRIGHTNESS

View file

@ -27,10 +27,6 @@
#include "leds/leds.h" // for LEDColor
#endif
#if NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL)
#define CASELIGHT_USES_BRIGHTNESS 1
#endif
class CaseLight {
public:
static bool on;

View file

@ -42,7 +42,7 @@
#include "pca9533.h"
#endif
#if ENABLED(CASE_LIGHT_USE_RGB_LED)
#if EITHER(CASE_LIGHT_USE_RGB_LED, CASE_LIGHT_USE_NEOPIXEL)
#include "../../feature/caselight.h"
#endif
@ -95,6 +95,10 @@ void LEDLights::set_color(const LEDColor &incol
#endif
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update brightness only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_brightness(incol.i);
#if ENABLED(NEOPIXEL_IS_SEQUENTIAL)
@ -106,6 +110,10 @@ void LEDLights::set_color(const LEDColor &incol
}
#endif
#if BOTH(CASE_LIGHT_MENU, CASE_LIGHT_USE_NEOPIXEL)
// Update color only if caselight is ON or switching leds off
if (caselight.on || incol.is_off())
#endif
neo.set_color(neocolor);
#endif
@ -150,7 +158,7 @@ void LEDLights::set_color(const LEDColor &incol
void LEDLights::toggle() { if (lights_on) set_off(); else update(); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
millis_t LEDLights::led_off_time; // = 0

View file

@ -157,12 +157,12 @@ public:
static void update() { set_color(color); }
#endif
#ifdef LED_BACKLIGHT_TIMEOUT
#if LED_POWEROFF_TIMEOUT > 0
private:
static millis_t led_off_time;
public:
static void reset_timeout(const millis_t &ms) {
led_off_time = ms + LED_BACKLIGHT_TIMEOUT;
led_off_time = ms + LED_POWEROFF_TIMEOUT;
if (!lights_on) update();
}
static void update_timeout(const bool power_on);

View file

@ -25,8 +25,6 @@
* NeoPixel support
*/
#define MAX_NEOPIXELS 127
#ifndef _NEOPIXEL_INCLUDE_
#error "Always include 'leds.h' and not 'neopixel.h' directly."
#endif
@ -68,7 +66,7 @@
// Types
// ------------------------
typedef IF<(MAX_NEOPIXELS > 127), int16_t, int8_t>::type pixel_index_t;
typedef IF<(TERN0(NEOPIXEL_LED, NEOPIXEL_PIXELS > 127)), int16_t, int8_t>::type pixel_index_t;
// ------------------------
// Classes

View file

@ -78,8 +78,8 @@
// This helps to implement HAS_ADC_BUTTONS menus
#define REVERSE_MENU_DIRECTION
#define ENCODER_PULSES_PER_STEP 1
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define STD_ENCODER_PULSES_PER_STEP 1
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#define ENCODER_FEEDRATE_DEADZONE 2
#elif ENABLED(ZONESTAR_12864LCD)
@ -97,7 +97,7 @@
#elif ENABLED(RADDS_DISPLAY)
#define IS_ULTIPANEL 1
#define ENCODER_PULSES_PER_STEP 2
#define STD_ENCODER_PULSES_PER_STEP 2
#elif ANY(miniVIKI, VIKI2, WYH_L12864, ELB_FULL_GRAPHIC_CONTROLLER, AZSMZ_12864)
@ -158,44 +158,19 @@
#define IS_RRD_SC 1
#define U8GLIB_SH1106
#define LED_CONTROL_MENU
#define NEOPIXEL_LED
#undef NEOPIXEL_TYPE
#define NEOPIXEL_TYPE NEO_RGB
#if NEOPIXEL_PIXELS < 3
#undef NEOPIXELS_PIXELS
#define NEOPIXEL_PIXELS 3
#endif
#ifndef NEOPIXEL_BRIGHTNESS
#define NEOPIXEL_BRIGHTNESS 127
#endif
#if ENABLED(PSU_CONTROL)
#define LED_BACKLIGHT_TIMEOUT 10000
#endif
#elif ANY(FYSETC_MINI_12864_X_X, FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_GENERIC_12864_1_1)
#define FYSETC_MINI_12864
#define DOGLCD
#define IS_ULTIPANEL 1
#define LED_COLORS_REDUCE_GREEN
#if ENABLED(PSU_CONTROL) && EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1)
#define LED_BACKLIGHT_TIMEOUT 10000
#endif
// Require LED backlighting enabled
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
#define RGB_LED
#elif ENABLED(FYSETC_MINI_12864_2_1)
#define LED_CONTROL_MENU
#define NEOPIXEL_LED
#undef NEOPIXEL_TYPE
#define NEOPIXEL_TYPE NEO_RGB
#if NEOPIXEL_PIXELS < 3
#undef NEOPIXELS_PIXELS
#define NEOPIXEL_PIXELS 3
#endif
#if ENABLED(FYSETC_MINI_12864_2_1)
#ifndef NEOPIXEL_BRIGHTNESS
#define NEOPIXEL_BRIGHTNESS 127
#endif
@ -207,8 +182,8 @@
#define IS_ULTIPANEL 1
#define U8GLIB_SSD1309
#define LCD_RESET_PIN LCD_PINS_D6 // This controller need a reset pin
#define ENCODER_PULSES_PER_STEP 4
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define STD_ENCODER_PULSES_PER_STEP 4
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#ifndef PCA9632
#define PCA9632
#endif
@ -305,8 +280,8 @@
#define PCA9632_BUZZER
#define PCA9632_BUZZER_DATA { 0x09, 0x02 }
#define ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons
#define ENCODER_STEPS_PER_MENU_ITEM 1
#define STD_ENCODER_PULSES_PER_STEP 1 // Overlord uses buttons
#define STD_ENCODER_STEPS_PER_MENU_ITEM 1
#endif
// 128x64 I2C OLED LCDs - SSD1306/SSD1309/SH1106

View file

@ -618,6 +618,8 @@
#if ANY(BLINKM, RGB_LED, RGBW_LED, PCA9632, PCA9533, NEOPIXEL_LED)
#define HAS_COLOR_LEDS 1
#else
#undef LED_POWEROFF_TIMEOUT
#endif
#if ALL(HAS_RESUME_CONTINUE, PRINTER_EVENT_LEDS, SDSUPPORT)
#define HAS_LEDS_OFF_FLAG 1
@ -738,9 +740,6 @@
#endif
#if EITHER(FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864)
#define LED_CONTROL_MENU
#define LED_USER_PRESET_STARTUP
#define LED_COLOR_PRESETS
#ifndef LED_USER_PRESET_GREEN
#define LED_USER_PRESET_GREEN 128
#endif
@ -981,6 +980,11 @@
#endif
#endif
// Flags for Case Light having a brightness property
#if ENABLED(CASE_LIGHT_ENABLE) && (NONE(CASE_LIGHT_NO_BRIGHTNESS, CASE_LIGHT_IS_COLOR_LED) || ENABLED(CASE_LIGHT_USE_NEOPIXEL))
#define CASELIGHT_USES_BRIGHTNESS 1
#endif
// Flag whether least_squares_fit.cpp is used
#if ANY(AUTO_BED_LEVELING_UBL, AUTO_BED_LEVELING_LINEAR, Z_STEPPER_ALIGN_KNOWN_STEPPER_POSITIONS)
#define NEED_LSF 1

View file

@ -2330,17 +2330,31 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
/**
* LED Control Menu
* FYSETC LCD Requirements
*/
#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS
#error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED."
#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1)
#ifndef NEO_RGB
#define NEO_RGB 123
#define FAUX_RGB 1
#endif
#if defined(NEOPIXEL_TYPE) && NEOPIXEL_TYPE != NEO_RGB
#error "Your FYSETC Mini Panel requires NEOPIXEL_TYPE to be NEO_RGB."
#elif defined(NEOPIXEL_PIXELS) && NEOPIXEL_PIXELS < 3
#error "Your FYSETC Mini Panel requires NEOPIXEL_PIXELS >= 3."
#endif
#if FAUX_RGB
#undef NEO_RGB
#undef FAUX_RGB
#endif
#elif EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && !DISABLED(RGB_LED)
#error "Your FYSETC Mini Panel requires RGB_LED."
#endif
/**
* LED Backlight Timeout
* LED Control Menu requirements
*/
#if defined(LED_BACKLIGHT_TIMEOUT) && !(ENABLED(PSU_CONTROL) && ANY(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1, FYSETC_242_OLED_12864))
#error "LED_BACKLIGHT_TIMEOUT requires a FYSETC Mini Panel and a Power Switch."
#if ENABLED(LED_CONTROL_MENU) && !HAS_COLOR_LEDS
#error "LED_CONTROL_MENU requires BLINKM, RGB_LED, RGBW_LED, PCA9533, PCA9632, or NEOPIXEL_LED."
#endif
/**
@ -2883,15 +2897,6 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#endif
#endif
/**
* FYSETC Mini 12864 RGB backlighting required
*/
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED)
#error "RGB_LED is required for FYSETC_MINI_12864 1.2 and 2.0."
#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP)
#error "LED_USER_PRESET_STARTUP is required for FYSETC_MINI_12864 2.x displays."
#endif
/**
* Check existing CS pins against enabled TMC SPI drivers.
*/
@ -3411,8 +3416,8 @@ static_assert(_PLUS_TEST(4), "HOMING_FEEDRATE_MM_M values must be positive.");
#error "A very large BLOCK_BUFFER_SIZE is not needed and takes longer to drain the buffer on pause / cancel."
#endif
#if ENABLED(LED_CONTROL_MENU) && !IS_ULTIPANEL
#error "LED_CONTROL_MENU requires an LCD controller."
#if ENABLED(LED_CONTROL_MENU) && NONE(HAS_MARLINUI_MENU, DWIN_CREALITY_LCD_ENHANCED)
#error "LED_CONTROL_MENU requires an LCD controller that implements the menu."
#endif
#if ENABLED(CASE_LIGHT_USE_NEOPIXEL) && DISABLED(NEOPIXEL_LED)

View file

@ -574,6 +574,23 @@
#warning "Contrast cannot be changed when LCD_CONTRAST_MIN >= LCD_CONTRAST_MAX."
#endif
/**
* FYSETC backlighting
*/
#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864_2_1) && !ALL(NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, LED_COLOR_PRESETS)
#warning "Your FYSETC Mini Panel works best with NEOPIXEL_LED, LED_CONTROL_MENU, LED_USER_PRESET_STARTUP, and LED_COLOR_PRESETS."
#endif
#if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0) && DISABLED(RGB_LED)
#warning "Your FYSETC Mini Panel works best with RGB_LED."
#elif EITHER(FYSETC_MINI_12864_2_0, FYSETC_MINI_12864_2_1) && DISABLED(LED_USER_PRESET_STARTUP)
#warning "Your FYSETC Mini Panel works best with LED_USER_PRESET_STARTUP."
#endif
#if EITHER(FYSETC_242_OLED_12864, FYSETC_MINI_12864) && BOTH(PSU_CONTROL, HAS_COLOR_LEDS) && !LED_POWEROFF_TIMEOUT
#warning "Your FYSETC display with PSU_CONTROL works best with LED_POWEROFF_TIMEOUT."
#endif
/**
* Maple environment
*/

View file

@ -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);

View file

@ -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)

View file

@ -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,6 +56,13 @@
#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
uint16_t Background_Color = Def_Background_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;

View file

@ -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

View file

@ -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");

View file

@ -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
}

View file

@ -17,7 +17,7 @@ opt_enable S_CURVE_ACCELERATION EEPROM_SETTINGS GCODE_MACROS \
FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING \
ASSISTED_TRAMMING REPORT_TRAMMING_MM ASSISTED_TRAMMING_WAIT_POSITION \
EEPROM_SETTINGS SDSUPPORT BINARY_FILE_TRANSFER \
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN \
NEOPIXEL_LED NEOPIXEL_PIN CASE_LIGHT_ENABLE CASE_LIGHT_USE_NEOPIXEL CASE_LIGHT_USE_RGB_LED CASE_LIGHT_MENU \
NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE FILAMENT_RUNOUT_DISTANCE_MM FILAMENT_RUNOUT_SENSOR \
AUTO_BED_LEVELING_BILINEAR Z_MIN_PROBE_REPEATABILITY_TEST DEBUG_LEVELING_FEATURE \

View file

@ -15,7 +15,7 @@ set -e
restore_configs
opt_set MOTHERBOARD BOARD_RAMPS_14_RE_ARM_EFB SERIAL_PORT_3 3 \
NEOPIXEL_TYPE NEO_GRB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24
NEOPIXEL_TYPE NEO_RGB RGB_LED_R_PIN P2_12 RGB_LED_G_PIN P1_23 RGB_LED_B_PIN P1_22 RGB_LED_W_PIN P1_24
opt_enable FYSETC_MINI_12864_2_1 SDSUPPORT SDCARD_READONLY SERIAL_PORT_2 RGBW_LED E_DUAL_STEPPER_DRIVERS \
NEOPIXEL_LED NEOPIXEL_IS_SEQUENTIAL NEOPIXEL_STARTUP_TEST NEOPIXEL_BKGD_INDEX_FIRST NEOPIXEL_BKGD_INDEX_LAST NEOPIXEL_BKGD_COLOR NEOPIXEL_BKGD_ALWAYS_ON
exec_test $1 $2 "ReARM EFB VIKI2, SDSUPPORT, 2 Serial ports (USB CDC + UART0), NeoPixel" "$3"