2014-06-05 11:45:40 -07:00
|
|
|
|
/*
|
2019-02-15 20:25:07 -08:00
|
|
|
|
Copyright (c) 2019, Lars Brubaker, John Lewin
|
2014-06-05 11:45:40 -07:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
2015-04-08 15:20:10 -07:00
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
2014-06-05 11:45:40 -07:00
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
2015-04-08 15:20:10 -07:00
|
|
|
|
list of conditions and the following disclaimer.
|
2014-06-05 11:45:40 -07:00
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
2015-04-08 15:20:10 -07:00
|
|
|
|
and/or other materials provided with the distribution.
|
2014-06-05 11:45:40 -07:00
|
|
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
|
|
|
|
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
|
|
|
|
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
|
|
|
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
|
|
|
|
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
|
|
|
|
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
|
|
|
|
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
|
|
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
|
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
|
|
|
|
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
|
|
|
|
The views and conclusions contained in the software and documentation are those
|
2015-04-08 15:20:10 -07:00
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
2014-06-05 11:45:40 -07:00
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2019-02-15 20:46:07 -08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2019-02-17 09:54:22 -08:00
|
|
|
|
using System.Linq;
|
2018-03-29 12:31:36 -07:00
|
|
|
|
using MatterHackers.Agg;
|
2014-06-05 11:45:40 -07:00
|
|
|
|
using MatterHackers.Localizations;
|
2019-01-15 16:31:12 -08:00
|
|
|
|
using MatterHackers.MatterControl.PrinterCommunication;
|
2014-06-05 11:45:40 -07:00
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
using MatterHackers.VectorMath;
|
2014-06-05 11:45:40 -07:00
|
|
|
|
|
2014-06-06 16:05:18 -07:00
|
|
|
|
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
2014-06-05 11:45:40 -07:00
|
|
|
|
{
|
2018-11-02 16:14:37 -07:00
|
|
|
|
public class PrintLevelingWizard : PrinterSetupWizard
|
2015-04-08 15:20:10 -07:00
|
|
|
|
{
|
2019-05-11 12:08:03 -07:00
|
|
|
|
// this class is so that it is not passed by value
|
|
|
|
|
|
public class ProbePosition
|
|
|
|
|
|
{
|
|
|
|
|
|
public Vector3 Position;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-08-11 11:06:56 -07:00
|
|
|
|
private readonly double[] babySteppingValue = new double[4];
|
2019-03-22 11:56:20 -07:00
|
|
|
|
private bool wizardExited;
|
2019-05-16 16:00:18 -07:00
|
|
|
|
private bool hasHardwareLeveling;
|
2015-04-08 15:20:10 -07:00
|
|
|
|
|
2019-02-16 13:55:27 -08:00
|
|
|
|
public PrintLevelingWizard(PrinterConfig printer)
|
2018-11-02 16:14:37 -07:00
|
|
|
|
: base(printer)
|
2018-05-23 17:54:31 -07:00
|
|
|
|
{
|
2019-03-19 18:14:03 -07:00
|
|
|
|
this.Title = "Print Leveling".Localize();
|
2019-05-16 16:00:18 -07:00
|
|
|
|
hasHardwareLeveling = printer.Settings.GetValue<bool>(SettingsKey.has_hardware_leveling);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
}
|
2018-03-29 12:31:36 -07:00
|
|
|
|
|
2019-04-24 21:21:50 -07:00
|
|
|
|
public LevelingPlan LevelingPlan { get; set; }
|
|
|
|
|
|
|
2020-11-16 16:28:11 -08:00
|
|
|
|
public override bool Visible => !hasHardwareLeveling;
|
2019-05-16 16:00:18 -07:00
|
|
|
|
|
|
|
|
|
|
public override string HelpText => hasHardwareLeveling ? "Unable due to hardware leveling".Localize() : null;
|
|
|
|
|
|
|
2020-11-13 17:24:15 -08:00
|
|
|
|
public override bool Enabled => !hasHardwareLeveling && Visible && printer.Connection.IsConnected && !printer.Connection.Printing && !printer.Connection.Paused;
|
2019-03-20 17:05:31 -07:00
|
|
|
|
|
2020-12-05 07:32:10 -08:00
|
|
|
|
public override bool Completed => !hasHardwareLeveling && !LevelingPlan.NeedsToBeRun(printer);
|
2019-03-20 17:05:31 -07:00
|
|
|
|
|
2020-12-05 07:32:10 -08:00
|
|
|
|
public override bool SetupRequired => LevelingPlan.NeedsToBeRun(printer);
|
2019-03-20 15:38:54 -07:00
|
|
|
|
|
2019-02-16 13:55:27 -08:00
|
|
|
|
private void Initialize()
|
2018-11-02 16:14:37 -07:00
|
|
|
|
{
|
2020-08-11 11:06:56 -07:00
|
|
|
|
printer.Settings.ForTools<double>(SettingsKey.baby_step_z_offset, (key, value, i) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
// remember the current baby stepping values
|
|
|
|
|
|
babySteppingValue[i] = value;
|
|
|
|
|
|
// clear them while we measure the offsets
|
|
|
|
|
|
printer.Settings.SetValue(key, "0");
|
|
|
|
|
|
});
|
2019-03-22 12:19:09 -07:00
|
|
|
|
|
2018-11-02 16:14:37 -07:00
|
|
|
|
// turn off print leveling
|
2018-12-22 08:30:29 -08:00
|
|
|
|
printer.Connection.AllowLeveling = false;
|
2018-11-02 16:14:37 -07:00
|
|
|
|
|
|
|
|
|
|
// clear any data that we are going to be acquiring (sampled positions, after z home offset)
|
|
|
|
|
|
var levelingData = new PrintLevelingData()
|
|
|
|
|
|
{
|
|
|
|
|
|
LevelingSystem = printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution)
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2019-02-11 13:57:00 -08:00
|
|
|
|
printer.Connection.QueueLine("T0");
|
2018-11-02 16:14:37 -07:00
|
|
|
|
|
|
|
|
|
|
switch (levelingData.LevelingSystem)
|
|
|
|
|
|
{
|
|
|
|
|
|
case LevelingSystem.Probe3Points:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizard3Point(printer);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe7PointRadial:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizard7PointRadial(printer);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe13PointRadial:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizard13PointRadial(printer);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe100PointRadial:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizard100PointRadial(printer);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe3x3Mesh:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizardMesh(printer, 3, 3);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe5x5Mesh:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizardMesh(printer, 5, 5);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.Probe10x10Mesh:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizardMesh(printer, 10, 10);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
case LevelingSystem.ProbeCustom:
|
2019-04-24 21:21:50 -07:00
|
|
|
|
LevelingPlan = new LevelWizardCustom(printer);
|
2018-11-02 16:14:37 -07:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
|
}
|
2019-02-16 09:11:20 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
// If leveling was on when we started, make sure it is on when we are done.
|
|
|
|
|
|
printer.Connection.AllowLeveling = true;
|
|
|
|
|
|
|
2019-02-25 12:08:54 -08:00
|
|
|
|
// set the baby stepping back to the last known good value
|
2020-08-11 11:06:56 -07:00
|
|
|
|
printer.Settings.ForTools<double>(SettingsKey.baby_step_z_offset, (key, value, i) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Settings.SetValue(key, babySteppingValue[i].ToString());
|
|
|
|
|
|
});
|
2019-02-25 12:08:54 -08:00
|
|
|
|
|
2019-03-22 11:56:20 -07:00
|
|
|
|
wizardExited = true;
|
2019-02-16 09:11:20 -08:00
|
|
|
|
|
|
|
|
|
|
// 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)
|
|
|
|
|
|
&& printer.Settings.GetValue<bool>(SettingsKey.has_z_servo))
|
2018-11-02 16:14:37 -07:00
|
|
|
|
{
|
2019-02-16 09:11:20 -08:00
|
|
|
|
// make sure the servo is retracted
|
|
|
|
|
|
var servoRetract = printer.Settings.GetValue<double>(SettingsKey.z_servo_retracted_angle);
|
|
|
|
|
|
printer.Connection.QueueLine($"M280 P0 S{servoRetract}");
|
|
|
|
|
|
}
|
2018-11-02 16:14:37 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-05 11:39:28 -07:00
|
|
|
|
public override bool ClosePage()
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
|
|
|
|
|
return base.ClosePage();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-03-20 13:19:55 -07:00
|
|
|
|
protected override IEnumerator<WizardPage> GetPages()
|
2018-05-23 17:54:31 -07:00
|
|
|
|
{
|
2019-02-15 08:56:45 -08:00
|
|
|
|
var levelingStrings = new LevelingStrings();
|
2018-04-10 17:59:15 -07:00
|
|
|
|
|
2019-02-15 20:46:07 -08:00
|
|
|
|
yield return new WizardPage(
|
2018-05-23 17:54:31 -07:00
|
|
|
|
this,
|
2019-05-20 17:13:07 -07:00
|
|
|
|
string.Format("{0} {1}", this.Title, "Overview".Localize()),
|
2019-05-07 13:48:30 -07:00
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0}\n\n{1}\n\n{2}\n\n",
|
|
|
|
|
|
"Print Leveling measures the plane of the bed.".Localize(),
|
|
|
|
|
|
"This data compensates for machine misalignment and bed distortion, and ensures good first layer adhesion.".Localize(),
|
|
|
|
|
|
"Click 'Next' to continue.".Localize()))
|
2019-05-09 14:34:55 -07:00
|
|
|
|
{
|
|
|
|
|
|
WindowTitle = Title,
|
|
|
|
|
|
};
|
2018-04-03 12:10:33 -07:00
|
|
|
|
|
2019-05-09 11:17:22 -07:00
|
|
|
|
// Switch to raw mode and construct leveling structures
|
|
|
|
|
|
this.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
// var probePositions = new List<ProbePosition>(Enumerable.Range(0, levelingPlan.ProbeCount).Select(p => new ProbePosition()));
|
|
|
|
|
|
var probePositions = new List<ProbePosition>(LevelingPlan.ProbeCount);
|
|
|
|
|
|
for (int j = 0; j < LevelingPlan.ProbeCount; j++)
|
|
|
|
|
|
{
|
|
|
|
|
|
probePositions.Add(new ProbePosition());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Require user confirmation after this point
|
|
|
|
|
|
this.RequireCancelConfirmation = true;
|
|
|
|
|
|
|
2020-10-25 08:48:43 -07:00
|
|
|
|
// start heating up now so it has more time to heat
|
2019-05-05 11:39:39 -07:00
|
|
|
|
var bedTemperature = printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed) ?
|
|
|
|
|
|
printer.Settings.GetValue<double>(SettingsKey.bed_temperature)
|
|
|
|
|
|
: 0;
|
|
|
|
|
|
if (bedTemperature > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Connection.TargetBedTemperature = bedTemperature;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
yield return new HomePrinterPage(
|
|
|
|
|
|
this,
|
2019-05-09 16:49:15 -07:00
|
|
|
|
levelingStrings.HomingPageInstructions(
|
2019-05-11 12:08:03 -07:00
|
|
|
|
printer.Settings.Helpers.UseZProbe(),
|
2019-05-09 16:49:15 -07:00
|
|
|
|
printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed)));
|
2018-05-23 17:54:31 -07:00
|
|
|
|
|
|
|
|
|
|
// figure out the heating requirements
|
|
|
|
|
|
double targetBedTemp = 0;
|
|
|
|
|
|
double targetHotendTemp = 0;
|
2019-05-07 13:48:30 -07:00
|
|
|
|
if (printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed))
|
2018-05-23 17:54:31 -07:00
|
|
|
|
{
|
2018-05-23 18:23:38 -07:00
|
|
|
|
targetBedTemp = printer.Settings.GetValue<double>(SettingsKey.bed_temperature);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-05-07 13:48:30 -07:00
|
|
|
|
if (!printer.Settings.Helpers.UseZProbe())
|
2018-05-23 17:54:31 -07:00
|
|
|
|
{
|
2019-02-05 11:22:22 -08:00
|
|
|
|
targetHotendTemp = printer.Settings.Helpers.ExtruderTargetTemperature(0);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (targetBedTemp > 0 || targetHotendTemp > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
string heatingInstructions = "";
|
|
|
|
|
|
if (targetBedTemp > 0 && targetHotendTemp > 0)
|
2018-04-10 14:40:19 -07:00
|
|
|
|
{
|
2018-05-23 17:54:31 -07:00
|
|
|
|
// heating both the bed and the hotend
|
2018-11-03 16:27:20 -07:00
|
|
|
|
heatingInstructions = "Waiting for the bed to heat to ".Localize() + targetBedTemp + "°C\n"
|
|
|
|
|
|
+ "and the hotend to heat to ".Localize() + targetHotendTemp + "°C.\n"
|
2018-05-23 17:54:31 -07:00
|
|
|
|
+ "\n"
|
2018-08-06 15:28:56 -07:00
|
|
|
|
+ "This will improve the accuracy of print leveling ".Localize()
|
2018-10-19 15:46:36 -07:00
|
|
|
|
+ "and ensure that no filament is stuck to your nozzle.".Localize() + "\n"
|
2018-05-23 17:54:31 -07:00
|
|
|
|
+ "\n"
|
|
|
|
|
|
+ "Warning! The tip of the nozzle will be HOT!".Localize() + "\n"
|
|
|
|
|
|
+ "Avoid contact with your skin.".Localize();
|
2018-04-10 14:40:19 -07:00
|
|
|
|
}
|
2018-05-23 17:54:31 -07:00
|
|
|
|
else if (targetBedTemp > 0)
|
2018-04-10 14:40:19 -07:00
|
|
|
|
{
|
2018-05-23 17:54:31 -07:00
|
|
|
|
// only heating the bed
|
2018-11-03 16:27:20 -07:00
|
|
|
|
heatingInstructions = "Waiting for the bed to heat to ".Localize() + targetBedTemp + "°C.\n"
|
2018-05-23 17:54:31 -07:00
|
|
|
|
+ "This will improve the accuracy of print leveling.".Localize();
|
2018-04-10 14:40:19 -07:00
|
|
|
|
}
|
2018-05-23 17:54:31 -07:00
|
|
|
|
else // targetHotendTemp > 0
|
2018-04-10 14:40:19 -07:00
|
|
|
|
{
|
2018-05-23 17:54:31 -07:00
|
|
|
|
// only heating the hotend
|
2018-11-03 16:27:20 -07:00
|
|
|
|
heatingInstructions += "Waiting for the hotend to heat to ".Localize() + targetHotendTemp + "°C.\n"
|
2018-10-19 15:46:36 -07:00
|
|
|
|
+ "This will ensure that no filament is stuck to your nozzle.".Localize() + "\n"
|
2018-05-23 17:54:31 -07:00
|
|
|
|
+ "\n"
|
|
|
|
|
|
+ "Warning! The tip of the nozzle will be HOT!".Localize() + "\n"
|
|
|
|
|
|
+ "Avoid contact with your skin.".Localize();
|
2018-04-10 14:40:19 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
yield return new WaitForTempPage(
|
|
|
|
|
|
this,
|
2019-05-07 13:48:30 -07:00
|
|
|
|
"Heating the printer".Localize(),
|
2018-05-23 17:54:31 -07:00
|
|
|
|
heatingInstructions,
|
2019-05-05 11:39:39 -07:00
|
|
|
|
targetBedTemp,
|
2019-02-15 20:46:07 -08:00
|
|
|
|
new double[] { targetHotendTemp });
|
2018-05-23 17:54:31 -07:00
|
|
|
|
}
|
2018-03-29 12:31:36 -07:00
|
|
|
|
|
2018-05-23 18:23:38 -07:00
|
|
|
|
double startProbeHeight = printer.Settings.GetValue<double>(SettingsKey.print_leveling_probe_start);
|
2018-07-29 16:49:15 -07:00
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
int i = 0;
|
2019-02-17 09:54:22 -08:00
|
|
|
|
|
2021-02-09 17:27:26 -08:00
|
|
|
|
var probePoints = LevelingPlan.GetPositionsToSample(printer.Connection.HomingPosition).ToList();
|
2019-02-17 09:54:22 -08:00
|
|
|
|
if (printer.Settings.Helpers.UseZProbe())
|
|
|
|
|
|
{
|
2019-05-05 11:39:39 -07:00
|
|
|
|
var autoProbePage = new AutoProbePage(this, printer, "Bed Detection", probePoints, probePositions);
|
2019-02-17 09:54:22 -08:00
|
|
|
|
yield return autoProbePage;
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2018-05-23 17:54:31 -07:00
|
|
|
|
{
|
2019-03-22 11:51:45 -07:00
|
|
|
|
foreach (var goalProbePoint in probePoints)
|
2019-01-15 16:31:12 -08:00
|
|
|
|
{
|
2019-03-22 11:51:45 -07:00
|
|
|
|
if (wizardExited)
|
2019-01-15 16:31:12 -08:00
|
|
|
|
{
|
2019-02-17 09:54:22 -08:00
|
|
|
|
// Make sure when the wizard is done we turn off the bed heating
|
|
|
|
|
|
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
2019-01-15 16:31:12 -08:00
|
|
|
|
|
2019-02-17 09:54:22 -08:00
|
|
|
|
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
|
|
|
|
|
{
|
|
|
|
|
|
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
|
|
|
|
|
}
|
2019-01-15 16:31:12 -08:00
|
|
|
|
|
2019-02-17 09:54:22 -08:00
|
|
|
|
yield break;
|
|
|
|
|
|
}
|
2018-04-11 17:35:34 -07:00
|
|
|
|
|
2019-03-22 11:51:45 -07:00
|
|
|
|
var validProbePosition = EnsureInPrintBounds(printer, goalProbePoint);
|
2019-02-11 13:57:00 -08:00
|
|
|
|
{
|
2019-02-17 09:54:22 -08:00
|
|
|
|
yield return new GetCoarseBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
new Vector3(validProbePosition, startProbeHeight),
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
2019-04-24 21:21:50 -07:00
|
|
|
|
levelingStrings.GetStepString(LevelingPlan.TotalSteps),
|
2019-02-17 09:54:22 -08:00
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"Low Precision".Localize()),
|
|
|
|
|
|
probePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
|
|
|
|
|
|
|
|
|
|
|
yield return new GetFineBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
2019-04-24 21:21:50 -07:00
|
|
|
|
levelingStrings.GetStepString(LevelingPlan.TotalSteps),
|
2019-02-17 09:54:22 -08:00
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"Medium Precision".Localize()),
|
|
|
|
|
|
probePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
|
|
|
|
|
|
|
|
|
|
|
yield return new GetUltraFineBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
2019-04-24 21:21:50 -07:00
|
|
|
|
levelingStrings.GetStepString(LevelingPlan.TotalSteps),
|
2019-02-17 09:54:22 -08:00
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"High Precision".Localize()),
|
|
|
|
|
|
probePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
2019-02-11 13:57:00 -08:00
|
|
|
|
}
|
2019-05-05 11:39:39 -07:00
|
|
|
|
|
2019-02-17 09:54:22 -08:00
|
|
|
|
i++;
|
2018-04-11 17:35:34 -07:00
|
|
|
|
}
|
2018-05-23 17:54:31 -07:00
|
|
|
|
}
|
2018-04-11 17:35:34 -07:00
|
|
|
|
|
2019-02-25 12:08:54 -08:00
|
|
|
|
// 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
|
2020-08-11 11:06:56 -07:00
|
|
|
|
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
|
|
|
|
|
for (i = 0; i < extruderCount; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
babySteppingValue[i] = 0;
|
|
|
|
|
|
}
|
2019-02-25 12:08:54 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-23 18:24:19 -07:00
|
|
|
|
yield return new LastPageInstructions(
|
2018-05-23 17:54:31 -07:00
|
|
|
|
this,
|
2018-05-30 15:55:07 -07:00
|
|
|
|
"Print Leveling Wizard".Localize(),
|
2019-05-07 13:48:30 -07:00
|
|
|
|
printer.Settings.Helpers.UseZProbe(),
|
2018-05-23 17:54:31 -07:00
|
|
|
|
probePositions);
|
2018-04-10 17:59:15 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2019-02-17 09:54:22 -08:00
|
|
|
|
public static Vector2 EnsureInPrintBounds(PrinterConfig printer, Vector2 probePosition)
|
2018-04-10 17:59:15 -07:00
|
|
|
|
{
|
2018-07-12 22:49:39 -07:00
|
|
|
|
// check that the position is within the printing area and if not move it back in
|
2019-02-17 09:54:22 -08:00
|
|
|
|
if (printer.Settings.Helpers.UseZProbe())
|
2018-03-29 12:31:36 -07:00
|
|
|
|
{
|
2019-04-02 13:40:38 -07:00
|
|
|
|
var probeOffset2D = new Vector2(printer.Settings.GetValue<Vector3>(SettingsKey.probe_offset));
|
|
|
|
|
|
var actualNozzlePosition = probePosition - probeOffset2D;
|
2018-03-29 12:31:36 -07:00
|
|
|
|
|
2018-04-10 17:59:15 -07:00
|
|
|
|
// clamp this to the bed bounds
|
2021-04-09 10:49:01 -07:00
|
|
|
|
var bedBounds = printer.Settings.BedBounds;
|
2020-11-13 17:17:25 -08:00
|
|
|
|
bedBounds.Inflate(-1);
|
2018-04-10 17:59:15 -07:00
|
|
|
|
Vector2 adjustedPosition = bedBounds.Clamp(actualNozzlePosition);
|
|
|
|
|
|
|
|
|
|
|
|
// and push it back into the probePosition
|
2019-04-02 13:40:38 -07:00
|
|
|
|
probePosition = adjustedPosition + probeOffset2D;
|
2017-05-19 14:39:57 -07:00
|
|
|
|
}
|
2018-03-29 12:31:36 -07:00
|
|
|
|
|
2018-04-10 17:59:15 -07:00
|
|
|
|
return probePosition;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2015-04-08 15:20:10 -07:00
|
|
|
|
}
|