From 25521cb9b2069db9bf2ab0b9576e6201c34d97e4 Mon Sep 17 00:00:00 2001 From: Miguel Risco-Castillo Date: Sat, 28 May 2022 17:34:36 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Fix,=20update=20ProUI=20(#24251,?= =?UTF-8?q?=20#24473,=20#24500)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/lcd/e3v2/proui/dwin.cpp | 167 ++++++++++++++++------- Marlin/src/lcd/e3v2/proui/dwin.h | 4 +- Marlin/src/lcd/e3v2/proui/dwin_defines.h | 12 +- 3 files changed, 122 insertions(+), 61 deletions(-) diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 7296e996bc..f51da4cf5a 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -31,6 +31,37 @@ #if ENABLED(DWIN_LCD_PROUI) +#if DISABLED(LIMITED_MAX_FR_EDITING) + #warning "LIMITED_MAX_FR_EDITING is recommended with ProUI." +#endif +#if DISABLED(LIMITED_MAX_ACCEL_EDITING) + #warning "LIMITED_MAX_ACCEL_EDITING is recommended with ProUI." +#endif +#if ENABLED(CLASSIC_JERK) && DISABLED(LIMITED_JERK_EDITING) + #warning "LIMITED_JERK_EDITING is recommended with ProUI." +#endif +#if DISABLED(INDIVIDUAL_AXIS_HOMING_SUBMENU) + #warning "INDIVIDUAL_AXIS_HOMING_SUBMENU is recommended with ProUI." +#endif +#if DISABLED(LCD_SET_PROGRESS_MANUALLY) + #warning "LCD_SET_PROGRESS_MANUALLY is recommended with ProUI." +#endif +#if DISABLED(STATUS_MESSAGE_SCROLLING) + #warning "STATUS_MESSAGE_SCROLLING is recommended with ProUI." +#endif +#if DISABLED(BAUD_RATE_GCODE) + #warning "BAUD_RATE_GCODE is recommended with ProUI." +#endif +#if DISABLED(SOUND_MENU_ITEM) + #warning "SOUND_MENU_ITEM is recommended with ProUI." +#endif +#if DISABLED(PRINTCOUNTER) + #warning "PRINTCOUNTER is recommended with ProUI." +#endif +#if HAS_MESH && DISABLED(MESH_EDIT_MENU) + #warning "MESH_EDIT_MENU is recommended with ProUI." +#endif + #include "dwin.h" #include "menus.h" #include "dwin_popup.h" @@ -68,7 +99,7 @@ #define HAS_ONESTEP_LEVELING 1 #endif -#if HAS_MESH || HAS_ONESTEP_LEVELING +#if HAS_MESH || (HAS_LEVELING && HAS_ZOFFSET_ITEM) #include "../../../feature/bedlevel/bedlevel.h" #include "bedlevel_tools.h" #endif @@ -165,7 +196,12 @@ #define DWIN_SCROLL_UPDATE_INTERVAL SEC_TO_MS(2) #define DWIN_REMAIN_TIME_UPDATE_INTERVAL SEC_TO_MS(20) -#define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) +#if HAS_MESH + #define BABY_Z_VAR TERN(HAS_BED_PROBE, probe.offset.z, HMI_data.ManualZOffset) +#else + float z_offset = 0; + #define BABY_Z_VAR z_offset +#endif // Structs HMI_value_t HMI_value; @@ -220,7 +256,13 @@ constexpr float max_acceleration_edit_values[] = ; #if HAS_CLASSIC_JERK - constexpr float max_jerk_edit_values[] = MAX_JERK_EDIT_VALUES; + constexpr float max_jerk_edit_values[] = + #ifdef MAX_JERK_EDIT_VALUES + MAX_JERK_EDIT_VALUES + #else + { DEFAULT_XJERK * 2, DEFAULT_YJERK * 2, DEFAULT_ZJERK * 2, DEFAULT_EJERK * 2 } + #endif + ; #endif static uint8_t _percent_done = 0; @@ -834,6 +876,8 @@ void update_variable() { else DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); } + #else + DWINUI::Draw_Icon(ICON_Zoffset, 187, 416); #endif _draw_xyz_position(false); @@ -1781,7 +1825,7 @@ void DWIN_SetDataDefaults() { #endif TERN_(BAUD_RATE_GCODE, SetBaud250K()); #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - leds.set_default(); + TERN_(LED_COLOR_PRESETS, leds.set_default()); ApplyLEDColor(); #endif } @@ -1799,10 +1843,10 @@ void DWIN_CopySettingsFrom(const char * const buff) { TERN_(BAUD_RATE_GCODE, HMI_SetBaudRate()); #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) leds.set_color( - (HMI_data.LED_Color >> 16) & 0xFF, - (HMI_data.LED_Color >> 8) & 0xFF, - (HMI_data.LED_Color >> 0) & 0xFF - OPTARG(HAS_WHITE_LED, (HMI_data.LED_Color >> 24) & 0xFF) + HMI_data.Led_Color.r, + HMI_data.Led_Color.g, + HMI_data.Led_Color.b + OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) ); leds.update(); #endif @@ -2094,7 +2138,7 @@ void HomeZ() { queue.inject(F("G28Z")); } ); gcode.process_subcommands_now(cmd); #else - set_bed_leveling_enabled(false); + TERN_(HAS_LEVELING, set_bed_leveling_enabled(false)); gcode.process_subcommands_now(F("G28O\nG0Z0F300\nM400")); #endif ui.reset_status(); @@ -2182,10 +2226,9 @@ void SetPID(celsius_t t, heater_id_t h) { #endif #if ENABLED(BAUD_RATE_GCODE) - void HMI_SetBaudRate() { - if (HMI_data.Baud115K) SetBaud115K(); else SetBaud250K(); - } + void HMI_SetBaudRate() { HMI_data.Baud115K ? SetBaud115K() : SetBaud250K(); } void SetBaudRate() { + HMI_data.Baud115K ^= true; HMI_SetBaudRate(); Draw_Chkb_Line(CurrentMenu->line(), HMI_data.Baud115K); DWIN_UpdateLCD(); @@ -2223,7 +2266,9 @@ void SetPID(celsius_t t, heater_id_t h) { } #endif #if HAS_COLOR_LEDS - void ApplyLEDColor() { HMI_data.LED_Color = TERN0(HAS_WHITE_LED, (leds.color.w << 24)) | (leds.color.r << 16) | (leds.color.g << 8) | leds.color.b; } + void ApplyLEDColor() { + HMI_data.Led_Color = LEDColor( {leds.color.r, leds.color.g, leds.color.b OPTARG(HAS_WHITE_LED, HMI_data.Led_Color.w) } ); + } void LiveLEDColor(uint8_t *color) { *color = MenuData.Value; leds.update(); } void LiveLEDColorR() { LiveLEDColor(&leds.color.r); } void LiveLEDColorG() { LiveLEDColor(&leds.color.g); } @@ -2377,48 +2422,45 @@ void ApplyFlow() { planner.refresh_e_factor(0); } void SetFlow() { SetPIntOnClick(MIN_PRINT_FLOW, MAX_PRINT_FLOW, ApplyFlow); } // Bed Tramming -TERN(HAS_BED_PROBE, float, void) Tram(uint8_t point) { - char cmd[100] = ""; - #if HAS_BED_PROBE + +void TramXY(const uint8_t point, const float &margin, float &x, float &y) { + switch (point) { + case 0: + LCD_MESSAGE(MSG_LEVBED_FL); + x = y = margin; + break; + case 1: + LCD_MESSAGE(MSG_LEVBED_FR); + x = X_BED_SIZE - margin; y = margin; + break; + case 2: + LCD_MESSAGE(MSG_LEVBED_BR); + x = X_BED_SIZE - margin; y = Y_BED_SIZE - margin; + break; + case 3: + LCD_MESSAGE(MSG_LEVBED_BL); + x = margin; y = Y_BED_SIZE - margin; + break; + case 4: + LCD_MESSAGE(MSG_LEVBED_C); + x = X_CENTER; y = Y_CENTER; + break; + } +} + +#if HAS_BED_PROBE + + float Tram(const uint8_t point) { + char cmd[100] = ""; static bool inLev = false; float xpos = 0, ypos = 0, zval = 0, margin = 0; char str_1[6] = "", str_2[6] = "", str_3[6] = ""; if (inLev) return NAN; margin = HMI_data.FullManualTramming ? 30 : PROBING_MARGIN; - #else - int16_t xpos = 0, ypos = 0; - int16_t margin = 30; - #endif - switch (point) { - case 0: - LCD_MESSAGE(MSG_LEVBED_FL); - xpos = ypos = margin; - break; - case 1: - LCD_MESSAGE(MSG_LEVBED_FR); - xpos = X_BED_SIZE - margin; ypos = margin; - break; - case 2: - LCD_MESSAGE(MSG_LEVBED_BR); - xpos = X_BED_SIZE - margin; ypos = Y_BED_SIZE - margin; - break; - case 3: - LCD_MESSAGE(MSG_LEVBED_BL); - xpos = margin; ypos = Y_BED_SIZE - margin; - break; - case 4: - LCD_MESSAGE(MSG_LEVBED_C); - xpos = X_BED_SIZE / 2; ypos = Y_BED_SIZE / 2; - break; - } - - planner.synchronize(); - - #if HAS_BED_PROBE + TramXY(point, margin, xpos, ypos); if (HMI_data.FullManualTramming) { - planner.synchronize(); sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), dtostrf(xpos, 1, 1, str_1), dtostrf(ypos, 1, 1, str_2) @@ -2426,6 +2468,20 @@ TERN(HAS_BED_PROBE, float, void) Tram(uint8_t point) { queue.inject(cmd); } else { + // AUTO_BED_LEVELING_BILINEAR does not define MESH_INSET + #ifndef MESH_MIN_X + #define MESH_MIN_X (_MAX(X_MIN_BED + PROBING_MARGIN, X_MIN_POS)) + #endif + #ifndef MESH_MIN_Y + #define MESH_MIN_Y (_MAX(Y_MIN_BED + PROBING_MARGIN, Y_MIN_POS)) + #endif + #ifndef MESH_MAX_X + #define MESH_MAX_X (_MIN(X_MAX_BED - (PROBING_MARGIN), X_MAX_POS)) + #endif + #ifndef MESH_MAX_Y + #define MESH_MAX_Y (_MIN(Y_MAX_BED - (PROBING_MARGIN), Y_MAX_POS)) + #endif + LIMIT(xpos, MESH_MIN_X, MESH_MAX_X); LIMIT(ypos, MESH_MIN_Y, MESH_MAX_Y); probe.stow(); @@ -2445,14 +2501,20 @@ TERN(HAS_BED_PROBE, float, void) Tram(uint8_t point) { inLev = false; } return zval; + } - #else // !HAS_BED_PROBE +#else - sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%iY%iF5000\nG0Z0F300"), xpos, ypos); + void Tram(const uint8_t point) { + float xpos = 0, ypos = 0, margin = 30; + TramXY(point, margin, xpos, ypos); + + char cmd[100] = "", str_1[6] = "", str_2[6] = ""; + sprintf_P(cmd, PSTR("M420S0\nG28O\nG90\nG0Z5F300\nG0X%sY%sF5000\nG0Z0F300"), dtostrf(xpos, 1, 1, str_1), dtostrf(ypos, 1, 1, str_2)); queue.inject(cmd); + } - #endif -} +#endif void TramFL() { Tram(0); } void TramFR() { Tram(1); } @@ -3350,7 +3412,7 @@ void Draw_GetColor_Menu() { EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_GREEN, onDrawPInt8Menu, SetLEDColorG, &leds.color.g); EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_BLUE, onDrawPInt8Menu, SetLEDColorB, &leds.color.b); #if ENABLED(HAS_WHITE_LED) - EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLedColorW, &leds.color.w); + EDIT_ITEM_F(ICON_LedControl, MSG_COLORS_WHITE, onDrawPInt8Menu, SetLEDColorW, &leds.color.w); #endif #endif #endif @@ -3763,6 +3825,7 @@ void Draw_Steps_Menu() { #endif // AUTO_BED_LEVELING_UBL #if HAS_MESH + void Draw_MeshSet_Menu() { checkkey = Menu; if (SetMenu(MeshMenu, GET_TEXT_F(MSG_MESH_LEVELING), 15)) { diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index 89ec25f928..6d36cca92a 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -239,9 +239,7 @@ void Draw_Tramming_Menu(); #if HAS_BED_PROBE void Draw_ProbeSet_Menu(); #endif -#if HAS_FILAMENT_SENSOR - void Draw_FilSet_Menu(); -#endif +void Draw_FilSet_Menu(); #if ENABLED(NOZZLE_PARK_FEATURE) void Draw_ParkPos_Menu(); #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index 9468149edf..dffc26478d 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -37,6 +37,9 @@ #include "../../../inc/MarlinConfigPre.h" #include "../common/dwin_color.h" +#if ENABLED(LED_CONTROL_MENU) + #include "../../../feature/leds/leds.h" +#endif #include #if defined(__STM32F1__) || defined(STM32F1) @@ -63,10 +66,7 @@ #define Def_Coordinate_Color Color_White #define Def_Button_Color RGB( 0, 23, 16) #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - #define Def_Leds_Color 0xFFFFFFFF -#endif -#if ENABLED(CASELIGHT_USES_BRIGHTNESS) - #define Def_CaseLight_Brightness 255 + #define Def_Leds_Color LEDColorWhite() #endif typedef struct { @@ -109,12 +109,12 @@ typedef struct { bool Baud115K = false; #endif bool FullManualTramming = false; - // Led #if ENABLED(MESH_BED_LEVELING) float ManualZOffset = 0; #endif + // Led #if BOTH(LED_CONTROL_MENU, HAS_COLOR_LEDS) - uint32_t LED_Color = Def_Leds_Color; + LEDColor Led_Color = Def_Leds_Color; #endif } HMI_data_t;