From bc76fec428cb48a9ae116cb85f8cf3e6a16a585c Mon Sep 17 00:00:00 2001 From: LarsBrubaker Date: Wed, 22 May 2019 07:58:06 -0700 Subject: [PATCH] Making z-calibration work without a probe also making it calibrate as many extruders as there are --- .../SetupWizards/ZCalibrationWizard.cs | 75 ++++++++++++------- .../CalibrateProbeLastPageInstructions.cs | 4 +- Submodules/agg-sharp | 2 +- 3 files changed, 52 insertions(+), 29 deletions(-) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/ZCalibrationWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/ZCalibrationWizard.cs index 840841809..048c7f508 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/ZCalibrationWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/ZCalibrationWizard.cs @@ -52,8 +52,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling { get { - return printer.Settings.GetValue(SettingsKey.has_z_probe) - && printer.Settings.GetValue(SettingsKey.use_z_probe); + return (printer.Settings.GetValue(SettingsKey.has_z_probe) + && printer.Settings.GetValue(SettingsKey.use_z_probe)) + || printer.Settings.GetValue(SettingsKey.extruder_count) > 1; } } @@ -97,13 +98,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling protected override IEnumerator GetPages() { var levelingStrings = new LevelingStrings(); - var autoProbePositions = new List(3); - var manualProbePositions = new List(3); + var autoProbePositions = new List(1); + int hotendCount = Math.Min(2, printer.Settings.Helpers.HotendCount()); + var manualProbePositions = new List>(hotendCount); + for (int i = 0; i < hotendCount; i++) + { + manualProbePositions.Add(new List()); + manualProbePositions[i] = new List(1) + { + new PrintLevelingWizard.ProbePosition() + }; + } autoProbePositions.Add(new PrintLevelingWizard.ProbePosition()); - manualProbePositions.Add(new PrintLevelingWizard.ProbePosition()); - int hotendCount = Math.Min(2, printer.Settings.Helpers.HotendCount()); int totalSteps = 3 * hotendCount; // show what steps will be taken @@ -186,14 +194,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling printer.Connection.QueueLine($"T0"); } - // do the automatic probing of the center position - yield return new AutoProbeFeedback( - this, - probeStartPosition, - "Probe at bed center".Localize(), - "Sample the bed center position to determine the probe distance to the bed".Localize(), - autoProbePositions, - 0); + bool probeBeingUsed = printer.Settings.GetValue(SettingsKey.has_z_probe) + && printer.Settings.GetValue(SettingsKey.use_z_probe); + + if (probeBeingUsed) + { + // do the automatic probing of the center position + yield return new AutoProbeFeedback( + this, + probeStartPosition, + "Probe at bed center".Localize(), + "Sample the bed center position to determine the probe distance to the bed".Localize(), + autoProbePositions, + 0); + } // show what steps will be taken yield return new WizardPage( @@ -205,7 +219,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling "We will use this paper to measure the distance between the nozzle and the bed.".Localize(), "Click 'Next' to continue.".Localize())); - // we currently only support calibrating 2 extruders for (int extruderIndex = 0; extruderIndex < hotendCount; extruderIndex++) { if (extruderCount > 1) @@ -224,7 +237,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling "Position".Localize(), 1, "Low Precision".Localize()), - manualProbePositions, + manualProbePositions[extruderIndex], 0, levelingStrings); @@ -236,7 +249,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling "Position".Localize(), 1, "Medium Precision".Localize()), - manualProbePositions, + manualProbePositions[extruderIndex], 0, levelingStrings); @@ -248,30 +261,40 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling "Position".Localize(), 1, "High Precision".Localize()), - manualProbePositions, + manualProbePositions[extruderIndex], 0, levelingStrings); - if (extruderIndex == 0) + if (probeBeingUsed && extruderIndex == 0) { // set the probe z offset - double newProbeOffset = autoProbePositions[0].Position.Z - manualProbePositions[0].Position.Z; + double newProbeOffset = autoProbePositions[0].Position.Z - manualProbePositions[0][0].Position.Z; var probe_offset = printer.Settings.GetValue(SettingsKey.probe_offset); probe_offset.Z = -newProbeOffset; printer.Settings.SetValue(SettingsKey.probe_offset, $"{probe_offset.X},{probe_offset.Y},{probe_offset.Z}"); + + printer.Settings.SetValue(SettingsKey.probe_has_been_calibrated, "1"); } - else if (extruderIndex == 1) + else if (extruderIndex > 0) { // store the offset into the extruder offset z position - double newProbeOffset = autoProbePositions[0].Position.Z - manualProbePositions[0].Position.Z; - var hotend0Offset = printer.Settings.GetValue(SettingsKey.probe_offset); - var newZOffset = newProbeOffset + hotend0Offset.Z; + double newZOffset; + + if (probeBeingUsed) + { + var extruderOffset = autoProbePositions[0].Position.Z - manualProbePositions[extruderIndex][0].Position.Z; + var hotend0Offset = printer.Settings.GetValue(SettingsKey.probe_offset); + newZOffset = extruderOffset + hotend0Offset.Z; + } + else + { + newZOffset = manualProbePositions[0][0].Position.Z - manualProbePositions[extruderIndex][0].Position.Z; + } + printer.Settings.Helpers.SetExtruderZOffset(1, newZOffset); } } - printer.Settings.SetValue(SettingsKey.probe_has_been_calibrated, "1"); - if (extruderCount > 1) { // reset the extruder that was active diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs index ef0f5433e..a3f6ab319 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/WizardPages/CalibrateProbeLastPageInstructions.cs @@ -43,10 +43,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling public CalibrateProbeLastPageInstructions(ISetupWizard setupWizard, string headerText) : base(setupWizard, headerText, "") { - var calibrated = "Your Probe is now calibrated.".Localize() + "\n" + var calibrated = "Z Calibration complete.".Localize() + "\n" + " • " + "Remove the paper".Localize() + "\n" + "\n" - + "If you wish to re-calibrate your probe in the future:".Localize() + "\n" + + "If you wish to re-run Z Calibration in the future:".Localize() + "\n" + " 1. Select the 'Controls' tab on the right".Localize() + "\n" + " 2. Look for the calibration section (pictured below)".Localize() + "\n"; contentRow.AddChild(this.CreateTextField(calibrated)); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 8f1275eed..b1426faf3 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 8f1275eed17ecec5bfac03ef049dbd65fdb7fb7c +Subproject commit b1426faf3ca035df3269a353b5332a1a14656470