From 82ff7c65425ec468e241291ddde0eeb133c703f4 Mon Sep 17 00:00:00 2001 From: KangDroid Date: Wed, 6 Jun 2018 11:57:25 +0900 Subject: [PATCH] Add a mesh edit menu for MBL / ABL-Bilinear --- Marlin/Configuration.h | 5 ++-- Marlin/src/config/default/Configuration.h | 5 ++-- Marlin/src/inc/SanityCheck.h | 2 ++ Marlin/src/lcd/language/language_en.h | 9 ++++++++ Marlin/src/lcd/menu/menu_bed_leveling.cpp | 27 ++++++++++++++++++++-- buildroot/share/tests/megaatmega2560_tests | 4 ++-- 6 files changed, 44 insertions(+), 8 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index bd1833ac9..d50562f04 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1173,8 +1173,9 @@ //#define LCD_BED_LEVELING #if ENABLED(LCD_BED_LEVELING) - #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. - #define LCD_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment + #define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis. + #define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment + //#define MESH_EDIT_MENU // Add a menu to edit mesh points #endif // Add a menu item to move between bed corners for manual bed adjustment diff --git a/Marlin/src/config/default/Configuration.h b/Marlin/src/config/default/Configuration.h index bd1833ac9..d50562f04 100644 --- a/Marlin/src/config/default/Configuration.h +++ b/Marlin/src/config/default/Configuration.h @@ -1173,8 +1173,9 @@ //#define LCD_BED_LEVELING #if ENABLED(LCD_BED_LEVELING) - #define MBL_Z_STEP 0.025 // Step size while manually probing Z axis. - #define LCD_PROBE_Z_RANGE 4 // Z Range centered on Z_MIN_POS for LCD Z adjustment + #define MESH_EDIT_Z_STEP 0.025 // (mm) Step size while manually probing Z axis. + #define LCD_PROBE_Z_RANGE 4 // (mm) Z Range centered on Z_MIN_POS for LCD Z adjustment + //#define MESH_EDIT_MENU // Add a menu to edit mesh points #endif // Add a menu item to move between bed corners for manual bed adjustment diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index b0c7fbab6..29a417e17 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -319,6 +319,8 @@ #error "SWITCHING_TOOLHEAD_SECURITY_RAISE is now TOOLCHANGE_ZRAISE. Please update your configuration." #elif defined(G0_FEEDRATE) && G0_FEEDRATE == 0 #error "G0_FEEDRATE is now used to set the G0 feedrate. Please update your configuration." +#elif defined(MBL_Z_STEP) + #error "MBL_Z_STEP is now MESH_EDIT_Z_STEP. Please update your configuration." #endif #define BOARD_MKS_13 -47 diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index 6f6a6e1b2..6566ecc8c 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -192,6 +192,15 @@ #ifndef MSG_EDITING_STOPPED #define MSG_EDITING_STOPPED _UxGT("Mesh Editing Stopped") #endif +#ifndef MSG_MESH_X + #define MSG_MESH_X _UxGT("Index X") +#endif +#ifndef MSG_MESH_Y + #define MSG_MESH_Y _UxGT("Index Y") +#endif +#ifndef MSG_MESH_EDIT_Z + #define MSG_MESH_EDIT_Z _UxGT("Z Value") +#endif #ifndef MSG_USER_MENU #define MSG_USER_MENU _UxGT("Custom Commands") #endif diff --git a/Marlin/src/lcd/menu/menu_bed_leveling.cpp b/Marlin/src/lcd/menu/menu_bed_leveling.cpp index 98b1063ea..b95aa5148 100644 --- a/Marlin/src/lcd/menu/menu_bed_leveling.cpp +++ b/Marlin/src/lcd/menu/menu_bed_leveling.cpp @@ -120,7 +120,7 @@ // Encoder knob or keypad buttons adjust the Z position // if (encoderPosition) { - const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MBL_Z_STEP); + const float z = current_position[Z_AXIS] + float((int32_t)encoderPosition) * (MESH_EDIT_Z_STEP); line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f)); lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; encoderPosition = 0; @@ -199,6 +199,25 @@ #endif // PROBE_MANUALLY || MESH_BED_LEVELING +#if ENABLED(MESH_EDIT_MENU) + + inline void refresh_planner() { + set_current_from_steppers_for_axis(ALL_AXES); + sync_plan_position(); + } + + void menu_mbl_edit_mesh() { + static uint8_t xind, yind; // =0 + START_MENU(); + MENU_BACK(MSG_BED_LEVELING); + MENU_ITEM_EDIT(int8, MSG_MESH_X, &xind, 0, GRID_MAX_POINTS_X - 1); + MENU_ITEM_EDIT(int8, MSG_MESH_Y, &yind, 0, GRID_MAX_POINTS_Y - 1); + MENU_ITEM_EDIT_CALLBACK(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner); + END_MENU(); + } + +#endif // MESH_EDIT_MENU + /** * Step 1: Bed Level entry-point * @@ -233,6 +252,10 @@ void menu_bed_leveling() { MENU_ITEM(gcode, MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29")); #endif + #if ENABLED(MESH_EDIT_MENU) + MENU_ITEM(submenu, MSG_EDIT_MESH, menu_mbl_edit_mesh); + #endif + // Homed and leveling is valid? Then leveling can be toggled. if (is_homed && leveling_is_valid()) { bool new_level_state = planner.leveling_active; @@ -245,7 +268,7 @@ void menu_bed_leveling() { #endif // - // MBL Z Offset + // Mesh Bed Leveling Z-Offset // #if ENABLED(MESH_BED_LEVELING) MENU_ITEM_EDIT(float43, MSG_BED_Z, &mbl.z_offset, -1, 1); diff --git a/buildroot/share/tests/megaatmega2560_tests b/buildroot/share/tests/megaatmega2560_tests index 87e38a235..b4a91611c 100755 --- a/buildroot/share/tests/megaatmega2560_tests +++ b/buildroot/share/tests/megaatmega2560_tests @@ -84,7 +84,7 @@ exec_test $1 $2 "RAMPS with Servo Probe, 3-Point ABL, DEBUG_LEVELING_FEATURE, EE # Test MESH_BED_LEVELING feature, with LCD # restore_configs -opt_enable MESH_BED_LEVELING G26_MESH_EDITING MESH_G28_REST_ORIGIN LCD_BED_LEVELING ULTIMAKERCONTROLLER +opt_enable MESH_BED_LEVELING G26_MESH_EDITING MESH_G28_REST_ORIGIN LCD_BED_LEVELING MESH_EDIT_MENU ULTIMAKERCONTROLLER exec_test $1 $2 "MESH_BED_LEVELING feature, with LCD" # @@ -92,7 +92,7 @@ exec_test $1 $2 "MESH_BED_LEVELING feature, with LCD" # restore_configs opt_set MOTHERBOARD BOARD_MINIRAMBO -opt_enable PROBE_MANUALLY AUTO_BED_LEVELING_BILINEAR G26_MESH_EDITING LCD_BED_LEVELING \ +opt_enable PROBE_MANUALLY AUTO_BED_LEVELING_BILINEAR G26_MESH_EDITING LCD_BED_LEVELING MESH_EDIT_MENU \ EEPROM_SETTINGS EEPROM_CHITCHAT \ M100_FREE_MEMORY_WATCHER M100_FREE_MEMORY_DUMPER M100_FREE_MEMORY_CORRUPTOR \ INCH_MODE_SUPPORT TEMPERATURE_UNITS_SUPPORT \