Starting work on an automatic z offset validator

This commit is contained in:
Lars Brubaker 2021-11-02 15:24:03 -07:00
parent c628d06e90
commit fe31aaca05
14 changed files with 514 additions and 172 deletions

View file

@ -307,7 +307,29 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
babySteppingValue[i] = 0;
}
yield return new CalibrateProbeLastPageInstructions(this, this.Title + " " + "Wizard".Localize());
var pageTitle = this.Title + " " + "Wizard".Localize();
if (hotendCount == 1 // this could be improved for dual extrusion calibration in the future. But for now it is single extrusion.
&& probeBeingUsed
&& printer.Settings.GetValue<bool>(SettingsKey.validate_probe_offset))
{
// let the user know we are done with the manual part
yield return new CalibrateProbeRemovePaperInstructions(this, pageTitle, false);
// tell them about the automatic part and any settings that should be changed
yield return new ZProbePrintCalibrationPartPage(
this,
printer,
"Validating Z Offset".Localize(),
"We will now improve accuracy by measure the probe offset from the top of a printed calibration object.".Localize());
// measure the top of the part we just printed
yield return new ZProbeCalibrateRetrieveTopProbeData(this, pageTitle);
// tell the user we are done and everything should be working
yield return new ZCalibrationValidateComplete(this, pageTitle);
}
else
{
yield return new CalibrateProbeRemovePaperInstructions(this, pageTitle);
}
}
private void SetExtruderOffset(List<PrintLevelingWizard.ProbePosition> autoProbePositions, List<List<PrintLevelingWizard.ProbePosition>> manualProbePositions, bool probeBeingUsed, int extruderIndex)

View file

@ -34,20 +34,23 @@ using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class CalibrateProbeLastPageInstructions : WizardPage
public class CalibrateProbeRemovePaperInstructions : WizardPage
{
public CalibrateProbeLastPageInstructions(ISetupWizard setupWizard, string headerText)
public CalibrateProbeRemovePaperInstructions(ISetupWizard setupWizard, string headerText, bool lastPage = true)
: base(setupWizard, headerText, "")
{
contentRow.AddChild(
this.CreateTextField(
"Z Calibration complete.".Localize() +
"Manual Z Calibration complete.".Localize() +
"\n • " +
"Remove the paper".Localize()));
contentRow.BackgroundColor = theme.MinimalShade;
this.ShowWizardFinished();
if (lastPage)
{
this.ShowWizardFinished();
}
}
public override void OnLoad(EventArgs args)

View file

@ -32,6 +32,8 @@ using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.CustomWidgets;
using MatterHackers.MatterControl.PartPreviewWindow;
using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl
{
@ -77,6 +79,39 @@ namespace MatterHackers.MatterControl
this.NextButton = nextButton;
}
public static void AddSettingsRow(GuiWidget contentRow, PrinterConfig printer, string warning, string key, ThemeConfig theme, ref int tabIndex)
{
var settingsContext = new SettingsContext(printer, null, NamedSettingsLayers.All);
contentRow.AddChild(
new TextWidget(
"Recommended Settings Changes".Localize() + ":",
textColor: theme.TextColor,
pointSize: theme.DefaultFontSize)
{
Margin = new BorderDouble(10, 0, 0, 20)
});
contentRow.AddChild(
new WrappedTextWidget(
warning,
textColor: theme.TextColor,
pointSize: theme.DefaultFontSize)
{
Margin = new BorderDouble(0, 10, 0, 20)
});
var settingsData = PrinterSettings.SettingsData[key];
var row = SliceSettingsTabView.CreateItemRow(settingsData, settingsContext, printer, theme, ref tabIndex);
if (row is SliceSettingsRow settingsRow)
{
settingsRow.ArrowDirection = ArrowDirection.Left;
}
contentRow.AddChild(row);
}
protected void MoveToNextPage()
{
OnAdvance();

View file

@ -0,0 +1,53 @@
/*
Copyright (c) 2019, Lars Brubaker, John Lewin
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.
*/
using MatterHackers.Localizations;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class ZCalibrationValidateComplete : WizardPage
{
public ZCalibrationValidateComplete(ISetupWizard setupWizard, string headerText, bool lastPage = true)
: base(setupWizard, headerText, "")
{
contentRow.AddChild(
this.CreateTextField(
"Precise probe calibration complete.".Localize() +
"\n • " +
"Your probe is now finely calibrated and should produce excellent first layer results".Localize()));
contentRow.BackgroundColor = theme.MinimalShade;
if (lastPage)
{
this.ShowWizardFinished();
}
}
}
}

View file

@ -0,0 +1,67 @@
/*
Copyright (c) 2019, Lars Brubaker, John Lewin
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.
*/
using System;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.PrinterCommunication;
using MatterHackers.MatterControl.SlicerConfiguration;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class ZProbeCalibrateRetrieveTopProbeData : WizardPage
{
public ZProbeCalibrateRetrieveTopProbeData(ISetupWizard setupWizard, string headerText)
: base(setupWizard, headerText, "")
{
contentRow.AddChild(this.CreateTextField("We will now sample the top of the part.".Localize()));
contentRow.BackgroundColor = theme.MinimalShade;
}
public override void OnLoad(EventArgs args)
{
this.NextButton.Enabled = false;
printer.Connection.QueueLine("T0");
printer.Connection.MoveRelative(PrinterConnection.Axis.X, .1, printer.Settings.Helpers.ManualMovementSpeeds().X);
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
{
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
}
else if (!printer.Settings.GetValue<bool>(SettingsKey.has_z_probe))
{
// Lift the hotend off the bed - at the conclusion of the wizard, make sure we lift the heated nozzle off the bed
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z);
}
base.OnLoad(args);
}
}
}

View file

@ -0,0 +1,127 @@
/*
Copyright (c) 2019, Lars Brubaker, John Lewin
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.
*/
using System;
using MatterHackers.Agg;
using MatterHackers.Agg.UI;
using MatterHackers.DataConverters3D;
using MatterHackers.Localizations;
using MatterHackers.MatterControl.SlicerConfiguration;
using MatterHackers.PolygonMesh;
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
public class ZProbePrintCalibrationPartPage : WizardPage
{
public ZProbePrintCalibrationPartPage(ISetupWizard setupWizard, PrinterConfig printer, string headerText, string details)
: base(setupWizard, headerText, details)
{
var spacer = new GuiWidget(15, 15);
contentRow.AddChild(spacer);
int tabIndex = 0;
contentRow.AddChild(
new TextWidget(
"This wizard will close to print a calibration part and resume after the print completes.".Localize(),
textColor: theme.TextColor,
pointSize: theme.DefaultFontSize)
{
Margin = new BorderDouble(bottom: theme.DefaultContainerPadding)
});
if (printer.Settings.GetValue<double>(SettingsKey.layer_height) < printer.Settings.GetValue<double>(SettingsKey.nozzle_diameter) / 2)
{
// The layer height is very small and it will be hard to see features. Show a warning.
AddSettingsRow(contentRow, printer, "The calibration object will printer better if the layer hight is set to a larger value. It is recommended that your increase it.".Localize(), SettingsKey.layer_height, theme, ref tabIndex);
}
if (printer.Settings.GetValue<bool>(SettingsKey.create_raft))
{
// The layer height is very small and it will be hard to see features. Show a warning.
AddSettingsRow(contentRow, printer, "A raft is not needed for the calibration object. It is recommended that you turn it off.".Localize(), SettingsKey.create_raft, theme, ref tabIndex);
}
if (printer.Settings.GetValue<int>(SettingsKey.top_solid_layers) < 4)
{
// The layer height is very small and it will be hard to see features. Show a warning.
AddSettingsRow(contentRow, printer, "You should have at least 3 top layers for this calibration to measure off of.".Localize(), SettingsKey.top_solid_layers, theme, ref tabIndex);
}
this.NextButton.Visible = false;
var startCalibrationPrint = theme.CreateDialogButton("Start Print".Localize());
startCalibrationPrint.Name = "Start Calibration Print";
startCalibrationPrint.Click += async (s, e) =>
{
var preCalibrationPrintViewMode = printer.ViewState.ViewMode;
// create the calibration objects
var item = CreateCalibrationObject(printer);
var calibrationObjectPrinter = new CalibrationObjectPrinter(printer, item);
// hide this window
this.DialogWindow.Visible = false;
await calibrationObjectPrinter.PrintCalibrationPart();
// Restore the original DialogWindow
this.DialogWindow.Visible = true;
// Restore to original view mode
printer.ViewState.ViewMode = preCalibrationPrintViewMode;
this.MoveToNextPage();
};
this.AcceptButton = startCalibrationPrint;
this.AddPageAction(startCalibrationPrint);
}
public static double CalibrationObjectHeight(PrinterConfig printer)
{
var layerHeight = printer.Settings.GetValue<double>(SettingsKey.layer_height);
var firstLayerHeight = printer.Settings.GetValue<double>(SettingsKey.first_layer_height);
return firstLayerHeight + layerHeight * 4;
}
private static IObject3D CreateCalibrationObject(PrinterConfig printer)
{
var nozzleDiameter = printer.Settings.GetValue<double>(SettingsKey.nozzle_diameter);
var size = Math.Min(30, nozzleDiameter * 20);
return new Object3D()
{
Mesh = PlatonicSolids.CreateCube(size, size, CalibrationObjectHeight(printer))
};
}
}
}