From cc8f7c83dabdff51a0980d8fa066833aeaa3d97d Mon Sep 17 00:00:00 2001 From: Andrew <18502096+classicrocker883@users.noreply.github.com> Date: Tue, 21 Nov 2023 04:57:31 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=B8=20Fix,=20clean=20up=20ProUI=20(#26?= =?UTF-8?q?434)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Scott Lahteine --- Marlin/src/inc/Conditionals_post.h | 8 +-- Marlin/src/inc/SanityCheck.h | 16 +---- Marlin/src/lcd/e3v2/jyersui/dwin.cpp | 2 +- Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp | 4 +- Marlin/src/lcd/e3v2/proui/bedlevel_tools.h | 3 - Marlin/src/lcd/e3v2/proui/dwin.cpp | 69 +++++++++----------- Marlin/src/lcd/e3v2/proui/dwin.h | 38 ++++++++--- Marlin/src/lcd/e3v2/proui/dwin_defines.h | 33 ++++++++++ Marlin/src/lcd/e3v2/proui/dwin_popup.cpp | 6 +- Marlin/src/lcd/e3v2/proui/dwinui.h | 21 +++--- Marlin/src/lcd/e3v2/proui/endstop_diag.cpp | 11 ++-- Marlin/src/lcd/e3v2/proui/gcode_preview.cpp | 10 ++- Marlin/src/lcd/e3v2/proui/lockscreen.cpp | 9 ++- Marlin/src/lcd/e3v2/proui/plot.cpp | 10 ++- 14 files changed, 141 insertions(+), 99 deletions(-) diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 002e5621d472..b98ca4d371f8 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -2491,15 +2491,9 @@ // PID heating #if ANY(PIDTEMP, PIDTEMPBED, PIDTEMPCHAMBER) #define HAS_PID_HEATING 1 -#endif - -#if ENABLED(DWIN_LCD_PROUI) - #if ANY(PIDTEMP, PIDTEMPBED) + #if ENABLED(DWIN_LCD_PROUI) && ANY(PIDTEMP, PIDTEMPBED) #define PROUI_PID_TUNE 1 #endif - #if ANY(PROUI_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH) - #define PROUI_TUNING_GRAPH 1 - #endif #endif // Thermal protection diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index 8796ea224fdc..3b08e6635f33 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1533,7 +1533,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L * Allow only one bed leveling option to be defined */ #if MANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR, AUTO_BED_LEVELING_UBL, MESH_BED_LEVELING) - #error "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." + #error "Select only one of: MESH_BED_LEVELING, AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL." #endif /** @@ -1541,7 +1541,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L */ #if IS_SCARA && ANY(AUTO_BED_LEVELING_LINEAR, AUTO_BED_LEVELING_3POINT, AUTO_BED_LEVELING_UBL) - #error "SCARA machines can only use AUTO_BED_LEVELING_BILINEAR or MESH_BED_LEVELING leveling." + #error "SCARA machines can only use AUTO_BED_LEVELING_BILINEAR or MESH_BED_LEVELING." #elif ENABLED(AUTO_BED_LEVELING_LINEAR) && !(WITHIN(GRID_MAX_POINTS_X, 2, 255) && WITHIN(GRID_MAX_POINTS_Y, 2, 255)) #error "GRID_MAX_POINTS_[XY] must be between 2 and 255 with AUTO_BED_LEVELING_LINEAR." #elif ENABLED(AUTO_BED_LEVELING_BILINEAR) && !(WITHIN(GRID_MAX_POINTS_X, 3, 255) && WITHIN(GRID_MAX_POINTS_Y, 3, 255)) @@ -1610,7 +1610,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #elif !(ENABLED(MESH_BED_LEVELING) || HAS_ABL_NOT_UBL) #error "LCD_BED_LEVELING requires MESH_BED_LEVELING or AUTO_BED_LEVELING." #elif ENABLED(MESH_EDIT_MENU) && !HAS_MESH - #error "MESH_EDIT_MENU requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR or AUTO_BED_LEVELING_UBL." + #error "MESH_EDIT_MENU requires MESH_BED_LEVELING, AUTO_BED_LEVELING_BILINEAR, or AUTO_BED_LEVELING_UBL." #endif #endif @@ -2746,16 +2746,6 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L #error "DWIN_LCD_PROUI requires SDSUPPORT to be enabled." #elif ALL(LCD_BED_LEVELING, PROBE_MANUALLY) #error "DWIN_LCD_PROUI does not support LCD_BED_LEVELING with PROBE_MANUALLY." - #elif ENABLED(MEDIASORT_MENU_ITEM) && DISABLED(SDCARD_SORT_ALPHA) - #error "MEDIASORT_MENU_ITEM requires SDCARD_SORT_ALPHA." - #elif ENABLED(RUNOUT_TUNE_ITEM) && DISABLED(HAS_FILAMENT_SENSOR) - #error "RUNOUT_TUNE_ITEM requires HAS_FILAMENT_SENSOR." - #elif ENABLED(PLR_TUNE_ITEM) && DISABLED(POWER_LOSS_RECOVERY) - #error "PLR_TUNE_ITEM requires POWER_LOSS_RECOVERY." - #elif ENABLED(JD_TUNE_ITEM) && DISABLED(HAS_JUNCTION_DEVIATION) - #error "JD_TUNE_ITEM requires HAS_JUNCTION_DEVIATION." - #elif ENABLED(ADVK_TUNE_ITEM) && DISABLED(LIN_ADVANCE) - #error "ADVK_TUNE_ITEM requires LIN_ADVANCE." #endif #endif diff --git a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp index 0222f1e1d045..cf78bdd7c6a5 100644 --- a/Marlin/src/lcd/e3v2/jyersui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/jyersui/dwin.cpp @@ -389,7 +389,7 @@ class TextScroller { // Draw value text on if (viewer_print_value) { - xy_int8_t offset { 0, cell_height_px / 2 - 6 }; + xy_int_t offset { 0, cell_height_px / 2 - 6 }; if (isnan(bedlevel.z_values[x][y])) { // undefined dwinDrawString(false, font6x12, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset.y, F("X")); } diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp index 87930a18799e..eea4ac97f0cc 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp @@ -200,7 +200,7 @@ float BedLevelTools::getMinValue() { bool BedLevelTools::meshValidate() { GRID_LOOP(x, y) { const float v = bedlevel.z_values[x][y]; - if (isnan(v) || !WITHIN(v, UBL_Z_OFFSET_MIN, UBL_Z_OFFSET_MAX)) return false; + if (isnan(v) || !WITHIN(v, Z_OFFSET_MIN, Z_OFFSET_MAX)) return false; } return true; } @@ -247,7 +247,7 @@ bool BedLevelTools::meshValidate() { // Draw value text on const uint8_t fs = DWINUI::fontWidth(meshfont); if (viewer_print_value) { - xy_int8_t offset { 0, cell_height_px / 2 - fs }; + xy_int_t offset { 0, cell_height_px / 2 - fs }; if (isnan(bedlevel.z_values[x][y])) { // undefined dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset.y, F("X")); } diff --git a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h index 7bd236760ae9..6e568e32b51e 100644 --- a/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h +++ b/Marlin/src/lcd/e3v2/proui/bedlevel_tools.h @@ -47,9 +47,6 @@ #include "../../../inc/MarlinConfigPre.h" -#define UBL_Z_OFFSET_MIN -3.0 -#define UBL_Z_OFFSET_MAX 3.0 - class BedLevelTools { public: #if ENABLED(USE_GRID_MESHVIEWER) diff --git a/Marlin/src/lcd/e3v2/proui/dwin.cpp b/Marlin/src/lcd/e3v2/proui/dwin.cpp index 843009c27461..a6cc1613ef09 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin.cpp @@ -31,6 +31,10 @@ #if ENABLED(DWIN_LCD_PROUI) +#include "dwin.h" +#include "menus.h" +#include "dwin_popup.h" + #include "../../utf8.h" #include "../../marlinui.h" #include "../../../MarlinCore.h" @@ -105,10 +109,6 @@ #include "../../../feature/tmc_util.h" #endif -#include "dwin.h" -#include "menus.h" -#include "dwin_popup.h" - #if HAS_GCODE_PREVIEW #include "gcode_preview.h" #endif @@ -268,7 +268,7 @@ Menu *stepsMenu = nullptr; #endif #if HAS_MESH Menu *meshMenu = nullptr; - #if ENABLED(MESH_EDIT_MENU) + #if ENABLED(PROUI_MESH_EDIT) Menu *editMeshMenu = nullptr; #endif #endif @@ -847,7 +847,7 @@ void updateVariable() { bool DWIN_lcd_sd_status = false; -#if ENABLED(MEDIASORT_MENU_ITEM) +#if ENABLED(PROUI_MEDIASORT) void setMediaSort() { toggleCheckboxLine(hmiData.mediaSort); card.setSortOn(hmiData.mediaSort ? TERN(SDSORT_REVERSE, AS_REV, AS_FWD) : AS_OFF); @@ -985,9 +985,8 @@ void drawPrintFileMenu() { if (card.isMounted()) { if (SET_MENU(fileMenu, MSG_MEDIA_MENU, nr_sd_menu_items() + 1)) { BACK_ITEM(gotoMainMenu); - for (uint8_t i = 0; i < nr_sd_menu_items(); ++i) { + for (uint8_t i = 0; i < nr_sd_menu_items(); ++i) menuItemAdd(onDrawFileName, onClickSDItem); - } } updateMenu(fileMenu); TERN_(DASH_REDRAW, dwinRedrawDash()); @@ -1022,7 +1021,6 @@ void hmiSDCardUpdate() { */ void dwinDrawDashboard() { - dwinDrawRectangle(1, hmiData.colorBackground, 0, STATUS_Y + 21, DWIN_WIDTH, DWIN_HEIGHT - 1); dwinDrawRectangle(1, hmiData.colorSplitLine, 0, 449, DWIN_WIDTH, 451); @@ -1067,7 +1065,7 @@ void dwinDrawDashboard() { void drawInfoMenu() { DWINUI::clearMainArea(); if (hmiIsChinese()) - title.frameCopy(30, 17, 28, 13); // "Info" + title.frameCopy(30, 17, 28, 13); // "Info" else title.showCaption(GET_TEXT_F(MSG_INFO_SCREEN)); drawMenuLine(0, ICON_Back, GET_TEXT_F(MSG_BACK), false, true); @@ -1124,7 +1122,7 @@ void hmiMainMenu() { if (hmiData.mediaAutoMount) { card.mount(); safe_delay(800); - }; + } drawPrintFileMenu(); break; case PAGE_PREPARE: drawPrepareMenu(); break; @@ -1759,7 +1757,7 @@ void dwinSetDataDefaults() { #if ALL(LCD_BED_TRAMMING, HAS_BED_PROBE) hmiData.fullManualTramming = DISABLED(BED_TRAMMING_USE_PROBE); #endif - #if ENABLED(MEDIASORT_MENU_ITEM) + #if ENABLED(PROUI_MEDIASORT) hmiData.mediaSort = true; card.setSortOn(TERN(SDSORT_REVERSE, AS_REV, AS_FWD)); #endif @@ -2710,7 +2708,7 @@ void onDrawGetColorItem(MenuItem* menuitem, int8_t line) { dwinDrawRectangle(0, hmiData.colorHighlight, ICOX + 1, MBASE(line) - 1 + 1, ICOX + 18, MBASE(line) - 1 + 18); dwinDrawRectangle(1, color, ICOX + 2, MBASE(line) - 1 + 2, ICOX + 17, MBASE(line) - 1 + 17); DWINUI::drawString(LBLX, MBASE(line) - 1, menuitem->caption); - drawMenuIntValue(hmiData.colorBackground, line, 4, hmiValue.Color[i]); + drawMenuIntValue(hmiData.colorBackground, line, 4, hmiValue.color[i]); dwinDrawHLine(hmiData.colorSplitLine, 16, MYPOS(line + 1), 240); } @@ -2976,10 +2974,6 @@ void onDrawAcc(MenuItem* menuitem, int8_t line) { #endif -#if HAS_ONESTEP_LEVELING - void onDrawManualTramming(MenuItem* menuitem, int8_t line) { onDrawChkbMenu(menuitem, line, hmiData.fullManualTramming); } -#endif - // Menu Creation and Drawing functions ====================================================== frame_rect_t selrect(frame_rect_t) { @@ -3130,7 +3124,7 @@ void drawAdvancedSettingsMenu() { #if HAS_GCODE_PREVIEW EDIT_ITEM(ICON_File, MSG_HAS_PREVIEW, onDrawChkbMenu, setPreview, &hmiData.enablePreview); #endif - #if ENABLED(MEDIASORT_MENU_ITEM) + #if ENABLED(PROUI_MEDIASORT) EDIT_ITEM(ICON_File, MSG_MEDIA_SORT, onDrawChkbMenu, setMediaSort, &hmiData.mediaSort); #endif EDIT_ITEM(ICON_File, MSG_MEDIA_UPDATE, onDrawChkbMenu, setMediaAutoMount, &hmiData.mediaAutoMount); @@ -3323,16 +3317,16 @@ void drawTuneMenu() { #if HAS_FILAMENT_SENSOR EDIT_ITEM(ICON_Runout, MSG_RUNOUT_ENABLE, onDrawChkbMenu, setRunoutEnable, &runout.enabled); #endif - #if ENABLED(PLR_TUNE_ITEM) + #if ENABLED(PROUI_ITEM_PLR) EDIT_ITEM(ICON_Pwrlossr, MSG_OUTAGE_RECOVERY, onDrawChkbMenu, setPwrLossr, &recovery.enabled); #endif #if ENABLED(FWRETRACT) MENU_ITEM(ICON_FWRetract, MSG_FWRETRACT, onDrawSubMenu, drawFWRetractMenu); #endif - #if ENABLED(JD_TUNE_ITEM) + #if ENABLED(PROUI_ITEM_JD) EDIT_ITEM(ICON_JDmm, MSG_JUNCTION_DEVIATION, onDrawPFloat3Menu, setJDmm, &planner.junction_deviation_mm); #endif - #if ENABLED(ADVK_TUNE_ITEM) + #if ENABLED(PROUI_ITEM_ADVK) EDIT_ITEM(ICON_MaxAccelerated, MSG_ADVANCE_K, onDrawPFloat3Menu, setLA_K, &planner.extruder_advance_K[0]); #endif #if HAS_LOCKSCREEN @@ -3669,24 +3663,24 @@ void drawStepsMenu() { void selColor() { menuData.intPtr = (int16_t*)static_cast(currentMenu->selectedItem())->value; - hmiValue.Color[0] = GetRColor(*menuData.intPtr); // Red - hmiValue.Color[1] = GetGColor(*menuData.intPtr); // Green - hmiValue.Color[2] = GetBColor(*menuData.intPtr); // Blue + hmiValue.color.r = GetRColor(*menuData.intPtr); // Red + hmiValue.color.g = GetGColor(*menuData.intPtr); // Green + hmiValue.color.b = GetBColor(*menuData.intPtr); // Blue drawGetColorMenu(); } void liveRGBColor() { - hmiValue.Color[currentMenu->line() - 2] = menuData.value; - uint16_t color = RGB(hmiValue.Color[0], hmiValue.Color[1], hmiValue.Color[2]); + hmiValue.color[currentMenu->line() - 2] = menuData.value; + const uint16_t color = RGB(hmiValue.color.r, hmiValue.color.g, hmiValue.color.b); dwinDrawRectangle(1, color, 20, 315, DWIN_WIDTH - 20, 335); } void setRGBColor() { const uint8_t color = static_cast(currentMenu->selectedItem())->icon; - setIntOnClick(0, (color == 1) ? 63 : 31, hmiValue.Color[color], nullptr, liveRGBColor); + setIntOnClick(0, (color == 1) ? 63 : 31, hmiValue.color[color], nullptr, liveRGBColor); } void dwinApplyColor() { - *menuData.intPtr = RGB(hmiValue.Color[0], hmiValue.Color[1], hmiValue.Color[2]); + *menuData.intPtr = RGB(hmiValue.color.r, hmiValue.color.g, hmiValue.color.b); DWINUI::setColors(hmiData.colorText, hmiData.colorBackground, hmiData.colorStatusBg); drawSelectColorsMenu(); hash_changed = true; @@ -3952,16 +3946,13 @@ void drawStepsMenu() { void setBedLevT() { setPIntOnClick(MIN_BEDTEMP, MAX_BEDTEMP); } #endif - #if ENABLED(MESH_EDIT_MENU) - #define Z_OFFSET_MIN -3 - #define Z_OFFSET_MAX 3 - - void LiveEditMesh() { ((MenuItemPtr*)editZValueItem)->value = &bedlevel.z_values[hmiValue.select ? bedLevelTools.mesh_x : menuData.value][hmiValue.select ? menuData.value : bedLevelTools.mesh_y]; editZValueItem->redraw(); } + #if ENABLED(PROUI_MESH_EDIT) + void liveEditMesh() { ((MenuItemPtr*)editZValueItem)->value = &bedlevel.z_values[hmiValue.select ? bedLevelTools.mesh_x : menuData.value][hmiValue.select ? menuData.value : bedLevelTools.mesh_y]; editZValueItem->redraw(); } void applyEditMeshX() { bedLevelTools.mesh_x = menuData.value; } void applyEditMeshY() { bedLevelTools.mesh_y = menuData.value; } - void ResetMesh() { bedLevelTools.meshReset(); LCD_MESSAGE(MSG_MESH_RESET); } - void setEditMeshX() { hmiValue.select = 0; setIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, applyEditMeshX, LiveEditMesh); } - void setEditMeshY() { hmiValue.select = 1; setIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, applyEditMeshY, LiveEditMesh); } + void resetMesh() { bedLevelTools.meshReset(); LCD_MESSAGE(MSG_MESH_RESET); } + void setEditMeshX() { hmiValue.select = 0; setIntOnClick(0, GRID_MAX_POINTS_X - 1, bedLevelTools.mesh_x, applyEditMeshX, liveEditMesh); } + void setEditMeshY() { hmiValue.select = 1; setIntOnClick(0, GRID_MAX_POINTS_Y - 1, bedLevelTools.mesh_y, applyEditMeshY, liveEditMesh); } void setEditZValue() { setPFloatOnClick(Z_OFFSET_MIN, Z_OFFSET_MAX, 3); } #endif @@ -4029,8 +4020,8 @@ void drawStepsMenu() { MENU_ITEM(ICON_UBLTiltGrid, MSG_UBL_TILT_MESH, onDrawMenuItem, ublMeshTilt); MENU_ITEM(ICON_UBLSmartFill, MSG_UBL_SMART_FILLIN, onDrawMenuItem, ublSmartFillMesh); #endif - #if ENABLED(MESH_EDIT_MENU) - MENU_ITEM(ICON_MeshReset, MSG_MESH_RESET, onDrawMenuItem, ResetMesh); + #if ENABLED(PROUI_MESH_EDIT) + MENU_ITEM(ICON_MeshReset, MSG_MESH_RESET, onDrawMenuItem, resetMesh); MENU_ITEM(ICON_MeshEdit, MSG_EDIT_MESH, onDrawSubMenu, drawEditMeshMenu); #endif MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, dwinMeshViewer); @@ -4038,7 +4029,7 @@ void drawStepsMenu() { updateMenu(meshMenu); } - #if ENABLED(MESH_EDIT_MENU) + #if ENABLED(PROUI_MESH_EDIT) void drawEditMeshMenu() { if (!leveling_is_valid()) { LCD_MESSAGE(MSG_UBL_MESH_INVALID); return; } set_bed_leveling_enabled(false); diff --git a/Marlin/src/lcd/e3v2/proui/dwin.h b/Marlin/src/lcd/e3v2/proui/dwin.h index a7e2cbccc6ea..cf4f9e264353 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin.h +++ b/Marlin/src/lcd/e3v2/proui/dwin.h @@ -134,9 +134,12 @@ typedef struct { #if ENABLED(BAUD_RATE_GCODE) bool baud115K = false; #endif - - bool fullManualTramming = false; - bool mediaSort = true; + #if ALL(LCD_BED_TRAMMING, HAS_BED_PROBE) + bool fullManualTramming = false; + #endif + #if ENABLED(PROUI_MEDIASORT) + bool mediaSort = true; + #endif bool mediaAutoMount = ENABLED(HAS_SD_EXTENDER); #if ALL(INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) uint8_t zAfterHoming = DEF_Z_AFTER_HOMING; @@ -144,20 +147,37 @@ typedef struct { #if ALL(LED_CONTROL_MENU, HAS_COLOR_LEDS) LEDColor ledColor = defColorLeds; #endif - bool adaptiveStepSmoothing = true; - bool enablePreview = true; + #if ENABLED(ADAPTIVE_STEP_SMOOTHING) + bool adaptiveStepSmoothing = true; + #endif + #if HAS_GCODE_PREVIEW + bool enablePreview = true; + #endif } hmi_data_t; extern hmi_data_t hmiData; static constexpr size_t eeprom_data_size = sizeof(hmi_data_t); typedef struct { - int8_t Color[3]; // Color components + int8_t r, g, b; + void set(int8_t _r, int8_t _g, int8_t _b) { r = _r; g = _g; b = _b; } + int8_t& operator[](const int i) { + switch (i) { + default: + case 0: return r; + case 1: return g; + case 2: return b; + } + } +} rgb_t; + +typedef struct { + rgb_t color; // Color #if ANY(PROUI_PID_TUNE, MPCTEMP) tempcontrol_t tempControl = AUTOTUNE_DONE; #endif - uint8_t select = 0; // Auxiliary selector variable - AxisEnum axis = X_AXIS; // Axis Select + uint8_t select = 0; // Auxiliary selector variable + AxisEnum axis = X_AXIS; // Axis Select } hmi_value_t; typedef struct { @@ -336,7 +356,7 @@ void drawStepsMenu(); #endif #if HAS_MESH void drawMeshSetMenu(); - #if ENABLED(MESH_EDIT_MENU) + #if ENABLED(PROUI_MESH_EDIT) void drawEditMeshMenu(); #endif #endif diff --git a/Marlin/src/lcd/e3v2/proui/dwin_defines.h b/Marlin/src/lcd/e3v2/proui/dwin_defines.h index e3526849a808..1b987906ae87 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_defines.h +++ b/Marlin/src/lcd/e3v2/proui/dwin_defines.h @@ -28,6 +28,16 @@ * Date: 2022/08/08 */ +#include "../../../inc/MarlinConfigPre.h" + +#if HAS_MESH + #define PROUI_MESH_EDIT // Add a menu to edit mesh points + #if ENABLED(PROUI_MESH_EDIT) + #define Z_OFFSET_MIN -3.0 // (mm) + #define Z_OFFSET_MAX 3.0 // (mm) + #endif +#endif + #if defined(__STM32F1__) || defined(STM32F1) #define DASH_REDRAW 1 #endif @@ -78,3 +88,26 @@ #define DEF_BEDPIDT TERN(PREHEAT_1_TEMP_BED, PREHEAT_1_TEMP_HOTEND, 60) #define DEF_PIDCYCLES 5 +/** + * ProUI internal feature flags + */ +#if ALL(SDCARD_SORT_ALPHA, SDSORT_GCODE) + #define PROUI_MEDIASORT // Enable option to sort G-code files +#endif +#if ENABLED(POWER_LOSS_RECOVERY) + #define PROUI_ITEM_PLR // Tune > Power-loss Recovery +#endif +#if ENABLED(HAS_JUNCTION_DEVIATION) + #define PROUI_ITEM_JD // Tune > Junction Deviation +#endif +#if ENABLED(LIN_ADVANCE) + #define PROUI_ITEM_ADVK // Tune > Linear Advance +#endif +#if ANY(PROUI_PID_TUNE, MPC_AUTOTUNE) && DISABLED(DISABLE_TUNING_GRAPH) + #define PROUI_TUNING_GRAPH 1 +#endif +#define HAS_GCODE_PREVIEW 1 // Preview G-code model thumbnail +#define HAS_CUSTOM_COLORS 1 // Change display colors +#define HAS_ESDIAG 1 // View End-stop/Runout switch continuity +#define HAS_LOCKSCREEN 1 // Simple lockscreen +#define HAS_SD_EXTENDER 1 // Enable to support SD card extender cables diff --git a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp index 91c3ee98e390..5756b770afbe 100644 --- a/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp +++ b/Marlin/src/lcd/e3v2/proui/dwin_popup.cpp @@ -41,10 +41,10 @@ popupDrawFunc_t popupDraw = nullptr; popupClickFunc_t popupClick = nullptr; popupChangeFunc_t popupChange = nullptr; -uint16_t HighlightYPos = 280; +uint16_t highlightY = 280; void drawSelectHighlight(const bool sel, const uint16_t ypos) { - HighlightYPos = ypos; + highlightY = ypos; hmiFlag.select_flag = sel; const uint16_t c1 = sel ? hmiData.colorHighlight : hmiData.colorPopupBg, c2 = sel ? hmiData.colorPopupBg : hmiData.colorHighlight; @@ -86,7 +86,7 @@ void hmiPopup() { EncoderState encoder_diffState = get_encoder_state(); if (encoder_diffState == ENCODER_DIFF_CW || encoder_diffState == ENCODER_DIFF_CCW) { const bool change = encoder_diffState != ENCODER_DIFF_CW; - if (popupChange) popupChange(change); else drawSelectHighlight(change, HighlightYPos); + if (popupChange) popupChange(change); else drawSelectHighlight(change, highlightY); dwinUpdateLCD(); } } diff --git a/Marlin/src/lcd/e3v2/proui/dwinui.h b/Marlin/src/lcd/e3v2/proui/dwinui.h index 35f07404ff87..015e66c8cb71 100644 --- a/Marlin/src/lcd/e3v2/proui/dwinui.h +++ b/Marlin/src/lcd/e3v2/proui/dwinui.h @@ -195,15 +195,18 @@ #define UNITFDIGITS 1 #define MINUNITMULT POW(10, UNITFDIGITS) -constexpr uint8_t TITLE_HEIGHT = 30, // Title bar height - MLINE = 53, // Menu line height - TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, // Total rows - MROWS = TROWS - 1, // Other-than-Back - ICOX = 26, // Menu item icon X position - LBLX = 55, // Menu item label X position - VALX = 210, // Menu item value X position - MENU_CHR_W = 8, MENU_CHR_H = 16, // Menu font 8x16 - STAT_CHR_W = 10; +/** + * @brief Menu Line Spacing + */ +constexpr uint8_t TITLE_HEIGHT = 30, //< Title bar height + MLINE = 53, //< Menu line height + TROWS = (STATUS_Y - TITLE_HEIGHT) / MLINE, //< Total rows + MROWS = TROWS - 1, //< Other-than-Back + ICOX = 26, //< Menu item icon X position + LBLX = 55, //< Menu item label X position + VALX = 210, //< Menu item value X position + MENU_CHR_W = 8, MENU_CHR_H = 16, //< Menu font 8x16 + STAT_CHR_W = 10; //< Menu Stats character width // Menuitem Y position #define MYPOS(L) (TITLE_HEIGHT + MLINE * (L)) diff --git a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp index d76c10dfdb2a..21c83dc8faa0 100644 --- a/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp +++ b/Marlin/src/lcd/e3v2/proui/endstop_diag.cpp @@ -29,11 +29,13 @@ #include "../../../inc/MarlinConfigPre.h" -#if ALL(DWIN_LCD_PROUI, HAS_ESDIAG) +#if ENABLED(DWIN_LCD_PROUI) -#include "endstop_diag.h" +#include "dwin_defines.h" + +#if HAS_ESDIAG -#include "../../../core/types.h" +#include "endstop_diag.h" #include "../../marlinui.h" #include "dwin.h" #include "dwin_popup.h" @@ -87,4 +89,5 @@ void ESDiag::update() { dwinUpdateLCD(); } -#endif // DWIN_LCD_PROUI && HAS_ESDIAG +#endif // HAS_ESDIAG +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp index e6e8384d9065..045615f3c2ae 100644 --- a/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp +++ b/Marlin/src/lcd/e3v2/proui/gcode_preview.cpp @@ -29,11 +29,14 @@ #include "../../../inc/MarlinConfigPre.h" -#if ALL(DWIN_LCD_PROUI, HAS_GCODE_PREVIEW) +#if ENABLED(DWIN_LCD_PROUI) + +#include "dwin_defines.h" + +#if HAS_GCODE_PREVIEW #include "gcode_preview.h" -#include "../../../core/types.h" #include "../../marlinui.h" #include "../../../sd/cardreader.h" #include "../../../MarlinCore.h" // for wait_for_user @@ -226,4 +229,5 @@ void Preview::show() { dwinIconShow(xpos, ypos, 0x00); } -#endif // DWIN_LCD_PROUI && HAS_GCODE_PREVIEW +#endif // HAS_GCODE_PREVIEW +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp index ebe3568c9879..cc18bdd214d6 100644 --- a/Marlin/src/lcd/e3v2/proui/lockscreen.cpp +++ b/Marlin/src/lcd/e3v2/proui/lockscreen.cpp @@ -29,10 +29,12 @@ #include "../../../inc/MarlinConfigPre.h" -#if ALL(DWIN_LCD_PROUI, HAS_LOCKSCREEN) +#if ENABLED(DWIN_LCD_PROUI) #include "dwin_defines.h" -#include "dwinui.h" + +#if HAS_LOCKSCREEN + #include "dwin.h" #include "lockscreen.h" @@ -72,4 +74,5 @@ void LockScreen::onEncoder(EncoderState encoder_diffState) { dwinUpdateLCD(); } -#endif // DWIN_LCD_PROUI && HAS_LOCKSCREEN +#endif // HAS_LOCKSCREEN +#endif // DWIN_LCD_PROUI diff --git a/Marlin/src/lcd/e3v2/proui/plot.cpp b/Marlin/src/lcd/e3v2/proui/plot.cpp index 3ea0d555fe62..92c6c947177b 100644 --- a/Marlin/src/lcd/e3v2/proui/plot.cpp +++ b/Marlin/src/lcd/e3v2/proui/plot.cpp @@ -29,10 +29,13 @@ #include "../../../inc/MarlinConfig.h" -#if ALL(DWIN_LCD_PROUI, PROUI_TUNING_GRAPH) +#if ENABLED(DWIN_LCD_PROUI) + +#include "dwin_defines.h" + +#if PROUI_TUNING_GRAPH #include "dwin.h" -#include "../../../core/types.h" #include "../../marlinui.h" #include "plot.h" @@ -75,4 +78,5 @@ void Plot::update(const_float_t value) { #endif } -#endif // DWIN_LCD_PROUI && PROUI_TUNING_GRAPH +#endif // PROUI_TUNING_GRAPH +#endif // DWIN_LCD_PROUI