Revise when baby stepping is cleared

- Restore original baby stepping value when cancelling wizard
- Issue MatterHackers/MCCentral#5091
Babystepping not cleared after running probe calibration wizard
This commit is contained in:
jlewin 2019-02-25 12:08:54 -08:00
parent 9fd6aec9c4
commit 5c908ed742
2 changed files with 39 additions and 3 deletions

View file

@ -40,6 +40,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class PrintLevelingWizard : PrinterSetupWizard
{
double[] babySteppingValues = new double[4];
private LevelingPlan levelingPlan;
public PrintLevelingWizard(PrinterConfig printer)
@ -49,6 +50,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
this.Initialize();
// remember the current baby stepping values
babySteppingValues[0] = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset);
babySteppingValues[1] = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset_1);
// clear them while we measure the offsets
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, "0");
printer.Settings.SetValue(SettingsKey.baby_step_z_offset_1, "0");
pages = this.GetPages();
pages.MoveNext();
}
@ -64,9 +73,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
LevelingSystem = printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution)
};
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, "0");
printer.Settings.SetValue(SettingsKey.baby_step_z_offset_1, "0");
printer.Connection.QueueLine("T0");
switch (levelingData.LevelingSystem)
@ -115,6 +121,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
// If leveling was on when we started, make sure it is on when we are done.
printer.Connection.AllowLeveling = true;
// set the baby stepping back to the last known good value
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, babySteppingValues[0].ToString());
printer.Settings.SetValue(SettingsKey.baby_step_z_offset_1, babySteppingValues[1].ToString());
this.WindowHasBeenClosed = true;
// make sure we raise the probe on close
@ -336,6 +346,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
}
}
// if we are not using a z-probe, reset the baby stepping at the successful conclusion of leveling
if (!printer.Settings.GetValue<bool>(SettingsKey.use_z_probe))
{
// clear the baby stepping so we don't save the old values
babySteppingValues[0] = 0;
babySteppingValues[1] = 0;
}
yield return new LastPageInstructions(
this,
"Print Leveling Wizard".Localize(),

View file

@ -38,6 +38,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class ProbeCalibrationWizard : PrinterSetupWizard
{
double[] babySteppingValues = new double[4];
public ProbeCalibrationWizard(PrinterConfig printer)
: base(printer)
{
@ -46,6 +48,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
// Initialize - turn off print leveling
printer.Connection.AllowLeveling = false;
// remember the current baby stepping values
babySteppingValues[0] = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset);
babySteppingValues[1] = printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset_1);
// clear them while we measure the offsets
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, "0");
printer.Settings.SetValue(SettingsKey.baby_step_z_offset_1, "0");
pages = this.GetPages();
pages.MoveNext();
}
@ -61,6 +71,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
// If leveling was on when we started, make sure it is on when we are done.
printer.Connection.AllowLeveling = true;
// set the baby stepping back to the last known good value
printer.Settings.SetValue(SettingsKey.baby_step_z_offset, babySteppingValues[0].ToString());
printer.Settings.SetValue(SettingsKey.baby_step_z_offset_1, babySteppingValues[1].ToString());
// make sure we raise the probe on close
if (printer.Settings.GetValue<bool>(SettingsKey.has_z_probe)
&& printer.Settings.GetValue<bool>(SettingsKey.use_z_probe)
@ -264,6 +278,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
printer.Connection.QueueLine($"T{extruderPriorToMeasure}");
}
// clear the baby stepping so we don't save the old values
babySteppingValues[0] = 0;
babySteppingValues[1] = 0;
yield return new CalibrateProbeLastPageInstructions(
this,
"Done".Localize());