2018-03-09 18:22:38 -08:00
|
|
|
|
/*
|
2018-05-23 08:57:16 -07:00
|
|
|
|
Copyright (c) 2018, Lars Brubaker, John Lewin
|
2018-03-09 18:22:38 -08:00
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
|
|
|
|
|
|
|
|
1. Redistributions of source code must retain the above copyright notice, this
|
|
|
|
|
|
list of conditions and the following disclaimer.
|
|
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
|
|
|
|
this list of conditions and the following disclaimer in the documentation
|
|
|
|
|
|
and/or other materials provided with the distribution.
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
of the authors and should not be interpreted as representing official policies,
|
|
|
|
|
|
either expressed or implied, of the FreeBSD Project.
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
using System;
|
2018-05-23 08:57:16 -07:00
|
|
|
|
using System.Collections.Generic;
|
2018-03-09 18:22:38 -08:00
|
|
|
|
using MatterHackers.Localizations;
|
|
|
|
|
|
using MatterHackers.MatterControl.SlicerConfiguration;
|
|
|
|
|
|
using MatterHackers.VectorMath;
|
|
|
|
|
|
|
|
|
|
|
|
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|
|
|
|
|
{
|
2018-05-23 19:12:46 -07:00
|
|
|
|
public class ProbeCalibrationWizard : LevelingWizard
|
2018-04-10 17:59:15 -07:00
|
|
|
|
{
|
2018-05-23 17:54:31 -07:00
|
|
|
|
public ProbeCalibrationWizard(PrinterConfig printer)
|
2018-05-23 18:01:09 -07:00
|
|
|
|
: base(printer)
|
2018-03-09 18:22:38 -08:00
|
|
|
|
{
|
2018-04-06 14:58:25 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-24 09:10:41 -07:00
|
|
|
|
public static bool UsingZProbe(PrinterConfig printer)
|
|
|
|
|
|
{
|
|
|
|
|
|
// we have a probe that we are using and we have not done leveling yet
|
|
|
|
|
|
return printer.Settings.GetValue<bool>(SettingsKey.has_z_probe)
|
|
|
|
|
|
&& printer.Settings.GetValue<bool>(SettingsKey.use_z_probe);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static bool NeedsToBeRun(PrinterConfig printer)
|
|
|
|
|
|
{
|
|
|
|
|
|
// we have a probe that we are using and we have not done leveling yet
|
|
|
|
|
|
return UsingZProbe(printer) && !printer.Settings.GetValue<bool>(SettingsKey.probe_has_been_calibrated);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
protected override IEnumerator<LevelingWizardPage> GetWizardSteps()
|
2018-03-09 18:22:38 -08:00
|
|
|
|
{
|
2018-05-23 18:23:38 -07:00
|
|
|
|
var levelingStrings = new LevelingStrings(printer.Settings);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
var autoProbePositions = new List<ProbePosition>(3);
|
|
|
|
|
|
var manualProbePositions = new List<ProbePosition>(3);
|
2018-03-09 18:22:38 -08:00
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
autoProbePositions.Add(new ProbePosition());
|
|
|
|
|
|
manualProbePositions.Add(new ProbePosition());
|
2018-03-09 18:22:38 -08:00
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
int totalSteps = 3;
|
2018-03-09 18:22:38 -08:00
|
|
|
|
|
2018-05-23 17:54:31 -07:00
|
|
|
|
// make a welcome page if this is the first time calibrating the probe
|
2018-05-23 18:23:38 -07:00
|
|
|
|
if (!printer.Settings.GetValue<bool>(SettingsKey.probe_has_been_calibrated))
|
2018-03-09 18:22:38 -08:00
|
|
|
|
{
|
2018-05-23 17:54:31 -07:00
|
|
|
|
yield return new LevelingWizardPage(
|
|
|
|
|
|
this,
|
2018-05-24 09:34:23 -07:00
|
|
|
|
levelingStrings.InitialPrinterSetupStepText,
|
2018-05-23 17:54:31 -07:00
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0}\n\n{1}",
|
|
|
|
|
|
"Congratulations on connecting to your printer. Before starting your first print we need to run a simple calibration procedure.".Localize(),
|
|
|
|
|
|
"The next few screens will walk your through calibrating your printer.".Localize()));
|
2018-03-09 18:22:38 -08:00
|
|
|
|
}
|
2018-05-23 17:54:31 -07:00
|
|
|
|
|
|
|
|
|
|
// show what steps will be taken
|
|
|
|
|
|
yield return new LevelingWizardPage(
|
|
|
|
|
|
this,
|
|
|
|
|
|
"Probe Calibration Overview".Localize(),
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0}\n\n\t• {1}\n\t• {2}\n\t• {3}\n\n{4}\n\n{5}",
|
|
|
|
|
|
"Welcome to the probe calibration wizard. Here is a quick overview on what we are going to do.".Localize(),
|
|
|
|
|
|
"Home the printer".Localize(),
|
|
|
|
|
|
"Probe the bed at the center".Localize(),
|
|
|
|
|
|
"Manually measure the extruder at the center".Localize(),
|
2018-05-24 18:39:03 -07:00
|
|
|
|
"We should be done in less than five minutes.".Localize(),
|
2018-05-23 17:54:31 -07:00
|
|
|
|
levelingStrings.ClickNext));
|
|
|
|
|
|
|
|
|
|
|
|
// add in the material select page
|
|
|
|
|
|
yield return new SelectMaterialPage(
|
|
|
|
|
|
this,
|
|
|
|
|
|
"Select Material".Localize(),
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0}\n\n{1}",
|
|
|
|
|
|
"The hot end needs to be heated to ensure it is clean.".Localize(),
|
|
|
|
|
|
"Please select the material you will be printing, so we can heat the printer before calibrating.".Localize()));
|
|
|
|
|
|
|
|
|
|
|
|
// add in the homing printer page
|
|
|
|
|
|
yield return new HomePrinterPage(
|
|
|
|
|
|
this,
|
2018-05-23 19:26:04 -07:00
|
|
|
|
"Homing The Printer".Localize(),
|
2018-05-23 17:54:31 -07:00
|
|
|
|
levelingStrings.HomingPageInstructions(true, false),
|
|
|
|
|
|
false);
|
|
|
|
|
|
|
|
|
|
|
|
double targetHotendTemp = 0;
|
|
|
|
|
|
|
2018-05-23 18:23:38 -07:00
|
|
|
|
targetHotendTemp = printer.Settings.Helpers.ExtruderTemperature(0);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
|
|
|
|
|
|
yield return new WaitForTempPage(
|
|
|
|
|
|
this,
|
2018-05-24 09:10:41 -07:00
|
|
|
|
"Waiting For Printer To Heat".Localize(),
|
2018-06-08 14:04:34 -07:00
|
|
|
|
"Waiting for the hotend to heat to ".Localize() + targetHotendTemp + ".\n"
|
2018-05-23 17:54:31 -07:00
|
|
|
|
+ "This will ensure no filament is stuck to the tip.".Localize() + "\n"
|
|
|
|
|
|
+ "\n"
|
|
|
|
|
|
+ "Warning! The tip of the nozzle will be HOT!".Localize() + "\n"
|
|
|
|
|
|
+ "Avoid contact with your skin.".Localize(),
|
|
|
|
|
|
0,
|
|
|
|
|
|
targetHotendTemp);
|
|
|
|
|
|
|
2018-05-23 18:23:38 -07:00
|
|
|
|
double startProbeHeight = printer.Settings.GetValue<double>(SettingsKey.print_leveling_probe_start);
|
2018-09-02 11:16:20 -07:00
|
|
|
|
Vector2 probePosition = LevelingPlan.ProbeOffsetSamplePosition(printer);
|
2018-05-23 17:54:31 -07:00
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
// do the automatic probing of the center position
|
|
|
|
|
|
yield return new AutoProbeFeedback(
|
|
|
|
|
|
this,
|
|
|
|
|
|
new Vector3(probePosition, startProbeHeight),
|
|
|
|
|
|
$"{"Step".Localize()} {i + 1} {"of".Localize()} 3: {"Position".Localize()} {i + 1} - {"Auto Calibrate".Localize()}",
|
|
|
|
|
|
autoProbePositions,
|
|
|
|
|
|
i);
|
|
|
|
|
|
|
|
|
|
|
|
// do the manual prob of the same position
|
|
|
|
|
|
yield return new GetCoarseBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
new Vector3(probePosition, startProbeHeight),
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
|
|
|
|
|
levelingStrings.GetStepString(totalSteps),
|
|
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"Low Precision".Localize()),
|
|
|
|
|
|
manualProbePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
|
|
|
|
|
|
|
|
|
|
|
yield return new GetFineBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
|
|
|
|
|
levelingStrings.GetStepString(totalSteps),
|
|
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"Medium Precision".Localize()),
|
|
|
|
|
|
manualProbePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
|
|
|
|
|
|
|
|
|
|
|
yield return new GetUltraFineBedHeight(
|
|
|
|
|
|
this,
|
|
|
|
|
|
string.Format(
|
|
|
|
|
|
"{0} {1} {2} - {3}",
|
|
|
|
|
|
levelingStrings.GetStepString(totalSteps),
|
|
|
|
|
|
"Position".Localize(),
|
|
|
|
|
|
i + 1,
|
|
|
|
|
|
"High Precision".Localize()),
|
|
|
|
|
|
manualProbePositions,
|
|
|
|
|
|
i,
|
|
|
|
|
|
levelingStrings);
|
|
|
|
|
|
|
|
|
|
|
|
yield return new CalibrateProbeLastPagelInstructions(
|
|
|
|
|
|
this,
|
|
|
|
|
|
"Done".Localize(),
|
|
|
|
|
|
"Your Probe is now calibrated.".Localize() + "\n\n\t• " + "Remove the paper".Localize() + "\n\n" + "Click 'Done' to close this window.".Localize(),
|
|
|
|
|
|
autoProbePositions,
|
|
|
|
|
|
manualProbePositions);
|
2018-03-09 18:22:38 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-05-24 18:39:03 -07:00
|
|
|
|
}
|