Sync and report changed position

This commit is contained in:
Scott Lahteine
2017-12-10 21:17:07 -06:00
parent 11f9c253e0
commit 03ba79f144
6 changed files with 24 additions and 4 deletions

View File

@ -128,13 +128,17 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
// so compensation will give the right stepper counts.
planner.unapply_leveling(current_position);
SYNC_PLAN_POSITION_KINEMATIC();
#endif // OLDSCHOOL_ABL
}
}
#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;
@ -145,6 +149,10 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
planner.set_z_fade_height(zfh);
if (level_active) {
const float oldpos[XYZE] = {
current_position[X_AXIS], current_position[Y_AXIS],
current_position[Z_AXIS], current_position[E_AXIS]
};
#if ENABLED(AUTO_BED_LEVELING_UBL)
set_bed_leveling_enabled(true); // turn back on after changing fade height
#else
@ -155,7 +163,10 @@ void set_bed_leveling_enabled(const bool enable/*=true*/) {
Z_AXIS
#endif
);
SYNC_PLAN_POSITION_KINEMATIC();
#endif
if (do_report && memcmp(oldpos, current_position, sizeof(oldpos)))
report_current_position();
}
}

View File

@ -47,7 +47,7 @@ void set_bed_leveling_enabled(const bool enable=true);
void reset_bed_level();
#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(AUTO_BED_LEVELING_BILINEAR) || ENABLED(MESH_BED_LEVELING)

View File

@ -71,17 +71,19 @@
volatile int unified_bed_leveling::encoder_diff;
unified_bed_leveling::unified_bed_leveling() {
ubl_cnt++; // Debug counter to insure we only have one UBL object present in memory. We can eliminate this (and all references to ubl_cnt) very soon.
ubl_cnt++; // Debug counter to ensure we only have one UBL object present in memory. We can eliminate this (and all references to ubl_cnt) very soon.
reset();
}
void unified_bed_leveling::reset() {
const bool was_enabled = planner.leveling_active;
set_bed_leveling_enabled(false);
storage_slot = -1;
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
planner.set_z_fade_height(10.0);
#endif
ZERO(z_values);
if (was_enabled) report_current_position();
}
void unified_bed_leveling::invalidate() {