Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh Inset workaround fix #143 #147

Merged
merged 5 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 24 additions & 14 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,16 @@ void DWIN_Print_Aborted() {
}
#endif

#if ALL(PROUI_MESH_EDIT, HAS_MESH)
void SetMeshArea() {
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x = ui.mesh_min_x;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x = ui.mesh_max_x;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y = ui.mesh_min_y;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y = ui.mesh_max_y;
ApplyMeshInset();
}
#endif

void DWIN_SetDataDefaults() {
DEBUG_ECHOLNPGM("DWIN_SetDataDefaults");
DWIN_SetColorDefaults();
Expand Down Expand Up @@ -4297,13 +4307,13 @@ void Draw_MaxAccel_Menu() {

// Mesh Inset
void ApplyMeshInset() { set_bed_leveling_enabled(false); reset_bed_level(); ReDrawItem(); }
void SetXMeshInset() { SetPFloatOnClick(0, X_BED_SIZE, UNITFDIGITS, ApplyMeshInset); }
void SetYMeshInset() { SetPFloatOnClick(0, Y_BED_SIZE, UNITFDIGITS, ApplyMeshInset); }
void SetXMeshInset() { SetPFloatOnClick(0, X_BED_SIZE, UNITFDIGITS, SetMeshArea, ApplyMeshInset); }
void SetYMeshInset() { SetPFloatOnClick(0, Y_BED_SIZE, UNITFDIGITS, SetMeshArea, ApplyMeshInset); }
void MaxMeshArea() {
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x = 0;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x = X_BED_SIZE;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y = 0;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y = Y_BED_SIZE;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x = ui.mesh_min_x = 0;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x = ui.mesh_max_x = X_BED_SIZE;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y = ui.mesh_min_y = 0;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y = ui.mesh_max_y = Y_BED_SIZE;
set_bed_leveling_enabled(false);
reset_bed_level();
ReDrawMenu();
Expand All @@ -4313,10 +4323,10 @@ void Draw_MaxAccel_Menu() {
if (max < X_BED_SIZE - MESH_MAX_X) { max = X_BED_SIZE - MESH_MAX_X; }
if (max < MESH_MIN_Y) { max = MESH_MIN_Y; }
if (max < Y_BED_SIZE - MESH_MAX_Y) { max = Y_BED_SIZE - MESH_MAX_Y; }
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x = max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x = X_BED_SIZE - max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y = max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y = Y_BED_SIZE - max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x = ui.mesh_min_x = max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x = ui.mesh_max_x = X_BED_SIZE - max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y = ui.mesh_min_y = max;
TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y = ui.mesh_max_y = Y_BED_SIZE - max;
set_bed_leveling_enabled(false);
reset_bed_level();
ReDrawMenu();
Expand All @@ -4326,10 +4336,10 @@ void Draw_MaxAccel_Menu() {
checkkey = Menu;
if (SET_MENU(MeshInsetMenu, MSG_MESH_INSET, 7)) {
BACK_ITEM(Draw_MeshSet_Menu);
EDIT_ITEM(ICON_Box, MSG_MESH_MIN_X, onDrawPFloatMenu, SetXMeshInset, TERN(PROUI_EX, &PRO_data, &HMI_data).mesh_min_x);
EDIT_ITEM(ICON_ProbeMargin, MSG_MESH_MAX_X, onDrawPFloatMenu, SetXMeshInset, TERN(PROUI_EX, &PRO_data, &HMI_data).mesh_max_x);
EDIT_ITEM(ICON_Box, MSG_MESH_MIN_Y, onDrawPFloatMenu, SetYMeshInset, TERN(PROUI_EX, &PRO_data, &HMI_data).mesh_min_y);
EDIT_ITEM(ICON_ProbeMargin, MSG_MESH_MAX_Y, onDrawPFloatMenu, SetYMeshInset, TERN(PROUI_EX, &PRO_data, &HMI_data).mesh_max_y);
EDIT_ITEM(ICON_Box, MSG_MESH_MIN_X, onDrawPFloatMenu, SetXMeshInset, &ui.mesh_min_x);
EDIT_ITEM(ICON_ProbeMargin, MSG_MESH_MAX_X, onDrawPFloatMenu, SetXMeshInset, &ui.mesh_max_x);
EDIT_ITEM(ICON_Box, MSG_MESH_MIN_Y, onDrawPFloatMenu, SetYMeshInset, &ui.mesh_min_y);
EDIT_ITEM(ICON_ProbeMargin, MSG_MESH_MAX_Y, onDrawPFloatMenu, SetYMeshInset, &ui.mesh_max_y);
MENU_ITEM(ICON_AxisC, MSG_MESH_AMAX, onDrawMenuItem, MaxMeshArea);
MENU_ITEM(ICON_SetHome, MSG_MESH_CENTER, onDrawMenuItem, CenterMeshArea);
}
Expand Down
1 change: 1 addition & 0 deletions Marlin/src/lcd/e3v2/proui/dwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ void Draw_MaxAccel_Menu();
void Draw_MeshInset_Menu();
#if ENABLED(PROUI_MESH_EDIT)
void Draw_EditMesh_Menu();
void ApplyMeshInset();
#endif
#endif
#if HAS_TRINAMIC_CONFIG
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/e3v2/proui/dwin_defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
#if HAS_TOOLBAR
constexpr uint8_t TBMaxOpt = 5; // Amount of shortcuts on screen
#if HAS_BED_PROBE
#define DEF_TBOPT {1, 7, 6, 2, 4} // Default shorcuts for ALB/UBL
#define DEF_TBOPT {1, 7, 6, 2, 4} // Default shorcuts for ABL/UBL
#else
#define DEF_TBOPT {1, 5, 4, 2, 3}; // Default shortcuts for MM
#endif
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/marlinui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ MarlinUI ui;

constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;

#if ALL(PROUI_MESH_EDIT, HAS_MESH)
float MarlinUI::mesh_min_x = TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x;
float MarlinUI::mesh_max_x = TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x;
float MarlinUI::mesh_min_y = TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y;
float MarlinUI::mesh_max_y = TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y;
#endif

#ifdef BED_SCREW_INSET
float MarlinUI::screw_pos = BED_SCREW_INSET;
#endif
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/lcd/marlinui.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,13 @@ class MarlinUI {
TERN_(HAS_MARLINUI_MENU, currentScreen = status_screen);
}

#if ALL(PROUI_MESH_EDIT, HAS_MESH)
static float mesh_min_x;
static float mesh_max_x;
static float mesh_min_y;
static float mesh_max_y;
#endif

#ifdef BED_SCREW_INSET
static float screw_pos; // bed corner screw inset
#endif
Expand Down
44 changes: 44 additions & 0 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,16 @@ typedef struct SettingsDataStruct {
bool tick_on; //encoder beep
#endif

//
// MESH_INSET workaround
//
#if ALL(PROUI_MESH_EDIT, HAS_MESH)
float ui_mesh_min_x;
float ui_mesh_max_x;
float ui_mesh_min_y;
float ui_mesh_max_y;
#endif

//
// Bed corner screw position
//
Expand Down Expand Up @@ -1757,6 +1767,16 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(ui.tick_on);
#endif

//
// MESH_INSET workaround
//
#if ALL(PROUI_MESH_EDIT, HAS_MESH)
EEPROM_WRITE(ui.mesh_min_x);
EEPROM_WRITE(ui.mesh_max_x);
EEPROM_WRITE(ui.mesh_min_y);
EEPROM_WRITE(ui.mesh_max_y);
#endif

//
// BED_SCREW_INSET
//
Expand Down Expand Up @@ -2895,6 +2915,20 @@ void MarlinSettings::postprocess() {
EEPROM_READ(ui.tick_on);
#endif

//
// MESH_INSET workaround
//
#if ALL(PROUI_MESH_EDIT, HAS_MESH)
_FIELD_TEST(ui_mesh_min_x);
EEPROM_READ(ui.mesh_min_x);
_FIELD_TEST(ui_mesh_max_x);
EEPROM_READ(ui.mesh_max_x);
_FIELD_TEST(ui_mesh_min_y);
EEPROM_READ(ui.mesh_min_y);
_FIELD_TEST(ui_mesh_max_y);
EEPROM_READ(ui.mesh_max_y);
#endif

//
// BED_SCREW_INSET
//
Expand Down Expand Up @@ -3463,6 +3497,16 @@ void MarlinSettings::reset() {
ui.tick_on = ENABLED(TICK_ON_DEFAULT); //added encoder beep bool
#endif

//
// MESH_INSET workaround
//
#if ALL(PROUI_MESH_EDIT, HAS_MESH)
ui.mesh_min_x = TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_x;
ui.mesh_max_x = TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_x;
ui.mesh_min_y = TERN(PROUI_EX, PRO_data, HMI_data).mesh_min_y;
ui.mesh_max_y = TERN(PROUI_EX, PRO_data, HMI_data).mesh_max_y;
#endif

//
// BED_SCREW_INSET
//
Expand Down
Loading