From b2cf253a13ba36baa681032e4e02639d23ff3774 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 23 Feb 2018 12:41:00 -0600 Subject: [PATCH] Add RESTORE_LEVELING_AFTER_G28 option --- .travis.yml | 4 ++-- Marlin/Configuration.h | 6 ++++++ Marlin/src/config/default/Configuration.h | 6 ++++++ Marlin/src/gcode/calibrate/G28.cpp | 8 ++++---- Marlin/src/inc/SanityCheck.h | 2 ++ 5 files changed, 20 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2048b649f1..a6348d9e4f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,7 +83,7 @@ script: - opt_set TEMP_SENSOR_3 20 - opt_set TEMP_SENSOR_4 999 - opt_set TEMP_SENSOR_BED 1 - - opt_enable AUTO_BED_LEVELING_UBL DEBUG_LEVELING_FEATURE G26_MESH_EDITING ENABLE_LEVELING_FADE_HEIGHT EEPROM_SETTINGS EEPROM_CHITCHAT G3D_PANEL SKEW_CORRECTION + - opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 DEBUG_LEVELING_FEATURE G26_MESH_EDITING ENABLE_LEVELING_FADE_HEIGHT EEPROM_SETTINGS EEPROM_CHITCHAT G3D_PANEL SKEW_CORRECTION - opt_enable_adv CUSTOM_USER_MENUS I2C_POSITION_ENCODERS BABYSTEPPING BABYSTEP_XY LIN_ADVANCE NANODLP_Z_SYNC QUICK_HOME - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM} # @@ -299,7 +299,7 @@ script: # - use_example_configs delta/generic - opt_disable DISABLE_MIN_ENDSTOPS - - opt_enable AUTO_BED_LEVELING_UBL Z_PROBE_ALLEN_KEY EEPROM_SETTINGS EEPROM_CHITCHAT OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY + - opt_enable AUTO_BED_LEVELING_UBL RESTORE_LEVELING_AFTER_G28 Z_PROBE_ALLEN_KEY EEPROM_SETTINGS EEPROM_CHITCHAT OLED_PANEL_TINYBOY2 MESH_EDIT_GFX_OVERLAY - build_marlin_pio ${TRAVIS_BUILD_DIR} ${TEST_PLATFORM} # # Delta Config (FLSUN AC because it's complex) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index f6db659878..02f2adb7b4 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -912,6 +912,12 @@ //#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING +/** + * Normally G28 leaves leveling disabled on completion. Enable + * this option to have G28 restore the prior leveling state. + */ +//#define RESTORE_LEVELING_AFTER_G28 + /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. diff --git a/Marlin/src/config/default/Configuration.h b/Marlin/src/config/default/Configuration.h index a845122512..50b13189e8 100644 --- a/Marlin/src/config/default/Configuration.h +++ b/Marlin/src/config/default/Configuration.h @@ -912,6 +912,12 @@ //#define AUTO_BED_LEVELING_UBL //#define MESH_BED_LEVELING +/** + * Normally G28 leaves leveling disabled on completion. Enable + * this option to have G28 restore the prior leveling state. + */ +//#define RESTORE_LEVELING_AFTER_G28 + /** * Enable detailed logging of G28, G29, M48, etc. * Turn on with the command 'M111 S32'. diff --git a/Marlin/src/gcode/calibrate/G28.cpp b/Marlin/src/gcode/calibrate/G28.cpp index 5bc414b4ec..3ab978dc84 100644 --- a/Marlin/src/gcode/calibrate/G28.cpp +++ b/Marlin/src/gcode/calibrate/G28.cpp @@ -183,8 +183,8 @@ void GcodeSuite::G28(const bool always_home_all) { // Disable the leveling matrix before homing #if HAS_LEVELING - #if ENABLED(AUTO_BED_LEVELING_UBL) - const bool ubl_state_at_entry = planner.leveling_active; + #if ENABLED(RESTORE_LEVELING_AFTER_G28) + const bool leveling_state_at_entry = planner.leveling_active; #endif set_bed_leveling_enabled(false); #endif @@ -319,8 +319,8 @@ void GcodeSuite::G28(const bool always_home_all) { do_blocking_move_to_z(delta_clip_start_height); #endif - #if ENABLED(AUTO_BED_LEVELING_UBL) - set_bed_leveling_enabled(ubl_state_at_entry); + #if ENABLED(RESTORE_LEVELING_AFTER_G28) + set_bed_leveling_enabled(leveling_state_at_entry); #endif clean_up_after_endstop_or_probe_move(); diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index e0f7effff5..85d4d16158 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -834,6 +834,8 @@ static_assert(1 >= 0 #error "AUTO_BED_LEVELING_UBL requires EEPROM_SETTINGS. Please update your configuration." #elif !WITHIN(GRID_MAX_POINTS_X, 3, 15) || !WITHIN(GRID_MAX_POINTS_Y, 3, 15) #error "GRID_MAX_POINTS_[XY] must be a whole number between 3 and 15." + #elif DISABLED(RESTORE_LEVELING_AFTER_G28) + #error "AUTO_BED_LEVELING_UBL (<=1.1.8) always has RESTORE_LEVELING_AFTER_G28 enabled. To keep this behavior, #define RESTORE_LEVELING_AFTER_G28. To keep it disabled comment out this line in SanityCheck.h." #else static_assert(WITHIN(UBL_PROBE_PT_1_X, MIN_PROBE_X, MAX_PROBE_X), "UBL_PROBE_PT_1_X can't be reached by the Z probe."); static_assert(WITHIN(UBL_PROBE_PT_2_X, MIN_PROBE_X, MAX_PROBE_X), "UBL_PROBE_PT_2_X can't be reached by the Z probe.");