From ccca1ade2d7257f6a8b3222f8ea3aceb6d8971b3 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 10 Dec 2017 20:24:13 -0600 Subject: [PATCH] Always report position on config load/reset --- Marlin/Marlin.h | 2 +- Marlin/Marlin_main.cpp | 5 ++++- Marlin/configuration_store.cpp | 27 +++++++++++---------------- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 7c31781926..7c0abe69db 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -373,7 +373,7 @@ void report_current_position(); #endif #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float zfh); + void set_z_fade_height(const float zfh, const bool do_report=true); #endif #if ENABLED(X_DUAL_ENDSTOPS) diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 1c3f5ddad8..c185247a91 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -2475,7 +2475,9 @@ static void clean_up_after_endstop_or_probe_move() { #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - void set_z_fade_height(const float zfh) { + void set_z_fade_height(const float zfh, const bool do_report/*=true*/) { + + if (planner.z_fade_height == zfh) return; // do nothing if no change const bool level_active = planner.leveling_active; @@ -2497,6 +2499,7 @@ static void clean_up_after_endstop_or_probe_move() { #endif ); #endif + if (do_report) report_current_position(); } } diff --git a/Marlin/configuration_store.cpp b/Marlin/configuration_store.cpp index 364f3532e9..53675c4877 100644 --- a/Marlin/configuration_store.cpp +++ b/Marlin/configuration_store.cpp @@ -215,14 +215,12 @@ MarlinSettings settings; float new_z_fade_height; #endif -#if ENABLED(CNC_COORDINATE_SYSTEMS) - bool position_changed; -#endif - /** * Post-process after Retrieve or Reset */ void MarlinSettings::postprocess() { + const float oldpos[] = { current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] }; + // steps per s2 needs to be updated to agree with units per s2 planner.reset_acceleration_rates(); @@ -232,10 +230,6 @@ void MarlinSettings::postprocess() { recalc_delta_settings(); #endif - // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm - // and init stepper.count[], planner.position[] with current_position - planner.refresh_positioning(); - #if ENABLED(PIDTEMP) thermalManager.updatePID(); #endif @@ -248,7 +242,7 @@ void MarlinSettings::postprocess() { #endif #if ENABLED(ENABLE_LEVELING_FADE_HEIGHT) - set_z_fade_height(new_z_fade_height); + set_z_fade_height(new_z_fade_height, false); // false = no report #endif #if ENABLED(AUTO_BED_LEVELING_BILINEAR) @@ -260,12 +254,13 @@ void MarlinSettings::postprocess() { stepper.refresh_motor_power(); #endif - #if ENABLED(CNC_COORDINATE_SYSTEMS) - if (position_changed) { - report_current_position(); - position_changed = false; - } - #endif + // Refresh steps_to_mm with the reciprocal of axis_steps_per_mm + // and init stepper.count[], planner.position[] with current_position + planner.refresh_positioning(); + + // Various factors can change the current position + if (memcmp(oldpos, current_position, sizeof(oldpos))) + report_current_position(); } #if ENABLED(EEPROM_SETTINGS) @@ -1121,7 +1116,7 @@ void MarlinSettings::postprocess() { // #if ENABLED(CNC_COORDINATE_SYSTEMS) - position_changed = select_coordinate_system(-1); // Go back to machine space + (void)select_coordinate_system(-1); // Go back to machine space EEPROM_READ(coordinate_system); // 27 floats #else for (uint8_t q = 27; q--;) EEPROM_READ(dummy);