Making hot end heat up before probing the bed with the tip
Refactoring - moving classes to individual files
This commit is contained in:
parent
b7918347d6
commit
4cb61563d3
24 changed files with 1363 additions and 807 deletions
|
|
@ -90,15 +90,41 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
"Print Leveling Overview".Localize(),
|
||||
levelingStrings.WelcomeText(ProbeCount, (int)Math.Round(secondsToCompleteWizard / 60.0)), theme));
|
||||
|
||||
if (!useZProbe)
|
||||
{
|
||||
printLevelWizard.AddPage(new CleanExtruderInstructionPage(printer, "Check Nozzle".Localize(), levelingStrings.CleanExtruder, theme));
|
||||
}
|
||||
|
||||
double targetBedTemp = 0;
|
||||
double targetHotendTemp = 0;
|
||||
if (hasHeatedBed)
|
||||
{
|
||||
string filamentSelectionPage = "{0}\n\n{1}".FormatWith(levelingStrings.materialPageInstructions1, levelingStrings.materialPageInstructions2);
|
||||
printLevelWizard.AddPage(new SelectMaterialPage(printer, levelingStrings.materialStepText, filamentSelectionPage, theme));
|
||||
targetBedTemp = printer.Settings.GetValue<double>(SettingsKey.bed_temperature);
|
||||
}
|
||||
|
||||
if (!useZProbe)
|
||||
{
|
||||
targetHotendTemp = printer.Settings.Helpers.ExtruderTemperature(0);
|
||||
}
|
||||
|
||||
// If we need to heat the bed or the extruder, select the current material
|
||||
if (targetBedTemp > 0 || targetHotendTemp > 0)
|
||||
{
|
||||
var instruction1 = "";
|
||||
if (targetBedTemp > 0 && targetHotendTemp > 0)
|
||||
{
|
||||
// heating both the bed and the hotend
|
||||
instruction1 = "To ensure accurate calibration both the bed and the hotend need to be heated.".Localize();
|
||||
}
|
||||
else if (targetBedTemp > 0)
|
||||
{
|
||||
// only heating the bed
|
||||
instruction1 = "The temperature of the bed can have a significant effect on the quality of leveling.".Localize();
|
||||
}
|
||||
else // targetHotendTemp > 0
|
||||
{
|
||||
// only heating the hotend
|
||||
instruction1 += "The hot end needs to be heated to ensure it is clean.".Localize();
|
||||
}
|
||||
|
||||
var instruction2 = "Please select the material you will be printing, so we can heat the printer before calibrating.".Localize();
|
||||
|
||||
printLevelWizard.AddPage(new SelectMaterialPage(printer, "Select Material".Localize(), $"{instruction1}\n\n{instruction2}", theme));
|
||||
}
|
||||
|
||||
printLevelWizard.AddPage(new HomePrinterPage(printer, printLevelWizard,
|
||||
|
|
@ -106,9 +132,41 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
levelingStrings.HomingPageInstructions(useZProbe, hasHeatedBed),
|
||||
useZProbe, theme));
|
||||
|
||||
if (hasHeatedBed)
|
||||
if (targetBedTemp > 0 || targetHotendTemp > 0)
|
||||
{
|
||||
printLevelWizard.AddPage(new WaitForTempPage(printer, printLevelWizard, levelingStrings, theme));
|
||||
string heatingInstructions = "";
|
||||
if (targetBedTemp > 0 && targetHotendTemp > 0)
|
||||
{
|
||||
// heating both the bed and the hotend
|
||||
heatingInstructions = $"Waiting for the bed to heat to {targetBedTemp}".Localize() + "\n"
|
||||
+ $"and the hotend to heat to {targetHotendTemp}.".Localize() + "\n"
|
||||
+ "\n"
|
||||
+ "This will improve the accuracy of print leveling".Localize()
|
||||
+ "and ensure no filament is stuck to the tip of the extruder.".Localize() + "\n"
|
||||
+ "\n"
|
||||
+ "Warning! The tip of the extrude will be HOT!".Localize() + "\n"
|
||||
+ "Avoid contact with your skin.".Localize();
|
||||
}
|
||||
else if (targetBedTemp > 0)
|
||||
{
|
||||
// only heating the bed
|
||||
heatingInstructions = $"Waiting for the bed to heat to {targetBedTemp}.".Localize() + "\n"
|
||||
+ "This will improve the accuracy of print leveling.".Localize();
|
||||
}
|
||||
else // targetHotendTemp > 0
|
||||
{
|
||||
// only heating the hotend
|
||||
heatingInstructions += $"Waiting for the hotend to heat to {targetHotendTemp}.".Localize() + "\n"
|
||||
+ "This will ensure no filament is stuck to the tip.".Localize() + "\n"
|
||||
+ "\n"
|
||||
+ "Warning! The tip of the extrude will be HOT!".Localize() + "\n"
|
||||
+ "Avoid contact with your skin.".Localize();
|
||||
}
|
||||
|
||||
printLevelWizard.AddPage(new WaitForTempPage(printer, printLevelWizard,
|
||||
"Waiting For Printer To Heat".Localize(), heatingInstructions,
|
||||
targetBedTemp, targetHotendTemp,
|
||||
theme));
|
||||
}
|
||||
|
||||
string positionLabel = "Position".Localize();
|
||||
|
|
|
|||
|
|
@ -37,11 +37,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
public class LevelingStrings
|
||||
{
|
||||
public string HomingPageStepText = "Homing The Printer".Localize();
|
||||
public string WaitingForTempPageStepText = "Waiting For Bed To Heat".Localize();
|
||||
public string initialPrinterSetupStepText = "Initial Printer Setup".Localize();
|
||||
public string materialStepText = "Select Material".Localize();
|
||||
public string materialPageInstructions1 = "The temperature of the bed can have a significant effect on the quality of leveling.";
|
||||
public string materialPageInstructions2 = "Please select the material you will be printing, so we can adjust the temperature before calibrating.";
|
||||
private string doneLine1 = "Congratulations!";
|
||||
private string doneLine1b = "Auto Print Leveling is now configured and enabled.".Localize();
|
||||
private string doneLine2 = "Remove the paper".Localize();
|
||||
|
|
@ -78,24 +74,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public string WaitingForTempPageInstructions
|
||||
{
|
||||
get
|
||||
{
|
||||
if (printerSettings.Helpers.UseZProbe())
|
||||
{
|
||||
return "Waiting for the bed to heat up.".Localize() + "\n"
|
||||
+ "This will improve the accuracy of print leveling.".Localize();
|
||||
}
|
||||
else
|
||||
{
|
||||
return "Waiting for the bed to heat up.".Localize() + "\n"
|
||||
+ "This will improve the accuracy of print leveling.".Localize() + "\n" + "\n"
|
||||
+ "Click 'Next' when the bed reaches temp.";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string HomingPageInstructions(bool useZProbe, bool heatBed)
|
||||
{
|
||||
string line1 = "The printer should now be 'homing'.".Localize();
|
||||
|
|
|
|||
|
|
@ -1,762 +0,0 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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 MatterControl.Printing;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.Font;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class FirstPageInstructions : InstructionsPage
|
||||
{
|
||||
public FirstPageInstructions(PrinterConfig printer, string pageDescription, string instructionsText, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class CleanExtruderInstructionPage : InstructionsPage
|
||||
{
|
||||
public CleanExtruderInstructionPage(PrinterConfig printer, string title, string body, ThemeConfig theme)
|
||||
: base(printer, title, body, theme)
|
||||
{
|
||||
ImageBuffer imageBuffer = MacroProcessingStream.LoadImageAsset(printer.Settings.GetValue("clean_nozzle_image"));
|
||||
|
||||
var levelingStrings = new LevelingStrings(printer.Settings);
|
||||
|
||||
GuiWidget spacer = new GuiWidget(10, 10);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
||||
topToBottomControls.AddChild(new ImageWidget(imageBuffer)
|
||||
{
|
||||
HAnchor = HAnchor.Center
|
||||
});
|
||||
|
||||
AddTextField(levelingStrings.ClickNext, 10, theme);
|
||||
}
|
||||
}
|
||||
|
||||
public class SelectMaterialPage : InstructionsPage
|
||||
{
|
||||
public SelectMaterialPage(PrinterConfig printer, string pageDescription, string instructionsText, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
var materialSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material);
|
||||
materialSelector.BackgroundColor = Color.Transparent;
|
||||
materialSelector.Margin = new BorderDouble(0, 0, 0, 15);
|
||||
topToBottomControls.AddChild(materialSelector);
|
||||
}
|
||||
}
|
||||
|
||||
public class WaitForTempPage : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private ProgressBar progressBar;
|
||||
private TextWidget progressBarText;
|
||||
private TextWidget doneText;
|
||||
private double startingTemp;
|
||||
|
||||
public WaitForTempPage(PrinterConfig printer, WizardControl container, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, levelingStrings.WaitingForTempPageStepText, levelingStrings.WaitingForTempPageInstructions, theme)
|
||||
{
|
||||
this.container = container;
|
||||
var holder = new FlowLayoutWidget()
|
||||
{
|
||||
Margin = new BorderDouble(0, 5)
|
||||
};
|
||||
progressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
|
||||
{
|
||||
FillColor = ActiveTheme.Instance.PrimaryAccentColor,
|
||||
BorderColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
BackgroundColor = Color.White,
|
||||
Margin = new BorderDouble(3, 0, 0, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
progressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 0, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
holder.AddChild(progressBar);
|
||||
holder.AddChild(progressBarText);
|
||||
topToBottomControls.AddChild(holder);
|
||||
|
||||
doneText = new TextWidget("Done!", textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Visible = false,
|
||||
};
|
||||
topToBottomControls.AddChild(doneText);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
startingTemp = printer.Connection.ActualBedTemperature;
|
||||
|
||||
UiThread.SetInterval(ShowTempChangeProgress, 1, () => !HasBeenClosed);
|
||||
|
||||
// start heating the bed and show our progress
|
||||
printer.Connection.TargetBedTemperature = printer.Settings.GetValue<double>(SettingsKey.bed_temperature);
|
||||
|
||||
// hook our parent so we can turn off the bed when we are done with leveling
|
||||
Parent.Closed += (s, e) =>
|
||||
{
|
||||
// Make sure when the wizard closes we turn off the bed heating
|
||||
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
||||
};
|
||||
|
||||
if (printer.Settings.Helpers.UseZProbe())
|
||||
{
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
}
|
||||
|
||||
// if we are trying to go to a temp of 0 than just move on to next window
|
||||
if(printer.Settings.GetValue<double>(SettingsKey.bed_temperature) == 0)
|
||||
{
|
||||
// advance to the next page
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
|
||||
private void ShowTempChangeProgress()
|
||||
{
|
||||
progressBar.Visible = true;
|
||||
double targetTemp = printer.Connection.TargetBedTemperature;
|
||||
double actualTemp = printer.Connection.ActualBedTemperature;
|
||||
double totalDelta = targetTemp - startingTemp;
|
||||
double currentDelta = actualTemp - startingTemp;
|
||||
double ratioDone = totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
progressBar.RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
progressBarText.Text = $"Temperature: {actualTemp:0} / {targetTemp:0}";
|
||||
|
||||
// if we are within 1 degree of our target
|
||||
if (Math.Abs(targetTemp - actualTemp) < 2
|
||||
&& doneText.Visible == false)
|
||||
{
|
||||
doneText.Visible = true;
|
||||
container.backButton.Enabled = true;
|
||||
container.nextButton.Enabled = true;
|
||||
|
||||
if (printer.Settings.Helpers.UseZProbe())
|
||||
{
|
||||
// advance to the next page
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LastPagelInstructions : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private List<ProbePosition> probePositions;
|
||||
|
||||
public LastPagelInstructions(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText, List<ProbePosition> probePositions, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPositions.Clear();
|
||||
|
||||
for (int i = 0; i < probePositions.Count; i++)
|
||||
{
|
||||
levelingData.SampledPositions.Add(probePositions[i].position);
|
||||
}
|
||||
|
||||
levelingData.LevelingSystem = printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution);
|
||||
levelingData.CreationData = DateTime.Now;
|
||||
// record the temp the bed was when we measured it (or 0 if no heated bed)
|
||||
levelingData.BedTemperature = printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed) ?
|
||||
printer.Settings.GetValue<double>(SettingsKey.bed_temperature)
|
||||
: 0;
|
||||
|
||||
// Invoke setter forcing persistence of leveling data
|
||||
printer.Settings.Helpers.SetPrintLevelingData(levelingData, true);
|
||||
PrintLevelingStream.AllowLeveling = true;
|
||||
printer.Settings.Helpers.DoPrintLeveling(true);
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
|
||||
// Make sure when the wizard is done we turn off the bed heating
|
||||
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
|
||||
public class CalibrateProbeLastPagelInstructions : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private List<ProbePosition> autoProbePositions;
|
||||
private List<ProbePosition> manualProbePositions;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public CalibrateProbeLastPagelInstructions(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText,
|
||||
List<ProbePosition> autoProbePositions,
|
||||
List<ProbePosition> manualProbePositions, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
this.autoProbePositions = autoProbePositions;
|
||||
this.manualProbePositions = manualProbePositions;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// make sure we don't have leveling data
|
||||
double newProbeOffset = autoProbePositions[0].position.Z - manualProbePositions[0].position.Z;
|
||||
printer.Settings.SetValue(SettingsKey.z_probe_z_offset, newProbeOffset.ToString("0.###"));
|
||||
printer.Settings.SetValue(SettingsKey.probe_has_been_calibrated, "1");
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
// move from this wizard to the print leveling wizard if needed
|
||||
ApplicationController.Instance.RunAnyRequiredCalibration(printer, theme);
|
||||
};
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
|
||||
public class GettingThirdPointFor2PointCalibration : InstructionsPage
|
||||
{
|
||||
protected Vector3 probeStartPosition;
|
||||
private ProbePosition probePosition;
|
||||
protected WizardControl container;
|
||||
|
||||
public GettingThirdPointFor2PointCalibration(PrinterConfig printer, WizardControl container, string pageDescription, Vector3 probeStartPosition, string instructionsText,
|
||||
ProbePosition probePosition, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
this.probePosition = probePosition;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// first make sure there is no leftover FinishedProbe event
|
||||
printer.Connection.LineReceived.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, feedRates.X);
|
||||
printer.Connection.QueueLine("G30");
|
||||
printer.Connection.LineReceived.RegisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
container.nextButton.Enabled = false;
|
||||
container.backButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void FinishedProbe(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
if (currentEvent.Data.Contains("endstops hit"))
|
||||
{
|
||||
printer.Connection.LineReceived.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
int zStringPos = currentEvent.Data.LastIndexOf("Z:");
|
||||
string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
|
||||
probePosition.position = new Vector3(probeStartPosition.X, probeStartPosition.Y, double.Parse(zProbeHeight));
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class HomePrinterPage : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private EventHandler unregisterEvents;
|
||||
bool autoAdvance;
|
||||
|
||||
public HomePrinterPage(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText, bool autoAdvance, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.autoAdvance = autoAdvance;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// make sure we don't have anything left over
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent(CheckHomeFinished, ref unregisterEvents);
|
||||
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
|
||||
if (autoAdvance)
|
||||
{
|
||||
container.nextButton.Enabled = false;
|
||||
}
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
|
||||
private void CheckHomeFinished(object sender, EventArgs e)
|
||||
{
|
||||
if(printer.Connection.DetailedPrintingState != DetailedPrintingState.HomingAxis)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
if (printer.Settings.Helpers.UseZProbe())
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
|
||||
public class FindBedHeight : InstructionsPage
|
||||
{
|
||||
private Vector3 lastReportedPosition;
|
||||
private List<ProbePosition> probePositions;
|
||||
int probePositionsBeingEditedIndex;
|
||||
private double moveAmount;
|
||||
|
||||
protected JogControls.MoveButton zPlusControl;
|
||||
protected JogControls.MoveButton zMinusControl;
|
||||
protected WizardControl container;
|
||||
|
||||
public FindBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance,
|
||||
List<ProbePosition> probePositions, int probePositionsBeingEditedIndex, ThemeConfig theme)
|
||||
: base(printer, pageDescription, setZHeightCoarseInstruction1, theme)
|
||||
{
|
||||
this.container = container;
|
||||
this.probePositions = probePositions;
|
||||
this.moveAmount = moveDistance;
|
||||
this.lastReportedPosition = printer.Connection.LastReportedPosition;
|
||||
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
|
||||
|
||||
GuiWidget spacer = new GuiWidget(15, 15);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
||||
FlowLayoutWidget zButtonsAndInfo = new FlowLayoutWidget();
|
||||
zButtonsAndInfo.HAnchor |= Agg.UI.HAnchor.Center;
|
||||
FlowLayoutWidget zButtons = CreateZButtons();
|
||||
zButtonsAndInfo.AddChild(zButtons);
|
||||
|
||||
zButtonsAndInfo.AddChild(new GuiWidget(15, 10));
|
||||
|
||||
//textFields
|
||||
TextWidget zPosition = new TextWidget("Z: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(10, 0),
|
||||
};
|
||||
|
||||
UiThread.SetInterval(() =>
|
||||
{
|
||||
Vector3 destinationPosition = printer.Connection.CurrentDestination;
|
||||
zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.Z);
|
||||
}, .3, () => !HasBeenClosed);
|
||||
|
||||
zButtonsAndInfo.AddChild(zPosition);
|
||||
|
||||
topToBottomControls.AddChild(zButtonsAndInfo);
|
||||
|
||||
AddTextField(setZHeightCoarseInstruction2, 10, theme);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// always make sure we don't have print leveling turned on
|
||||
PrintLevelingStream.AllowLeveling = false;
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
this.Parents<SystemWindow>().First().KeyDown += TopWindowKeyDown;
|
||||
|
||||
container.nextButton.ToolTipText = "[Right Arrow]".Localize();
|
||||
container.backButton.ToolTipText = "[Left Arrow]".Localize();
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
this.Parents<SystemWindow>().First().KeyDown -= TopWindowKeyDown;
|
||||
probePositions[probePositionsBeingEditedIndex].position = printer.Connection.LastReportedPosition;
|
||||
base.PageIsBecomingInactive();
|
||||
|
||||
container.nextButton.ToolTipText = "";
|
||||
container.backButton.ToolTipText = "";
|
||||
}
|
||||
|
||||
private FlowLayoutWidget CreateZButtons()
|
||||
{
|
||||
FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, Color.White, 4, out zPlusControl, out zMinusControl, true);
|
||||
// set these to 0 so the button does not do any movements by default (we will handle the movement on our click callback)
|
||||
zPlusControl.MoveAmount = 0;
|
||||
zPlusControl.ToolTipText += " [Up Arrow]".Localize();
|
||||
zPlusControl.Click += zPlusControl_Click;
|
||||
|
||||
zMinusControl.MoveAmount = 0;
|
||||
zMinusControl.ToolTipText += " [Down Arrow]".Localize();
|
||||
zMinusControl.Click += zMinusControl_Click;
|
||||
return zButtons;
|
||||
}
|
||||
|
||||
public void TopWindowKeyDown(object s, KeyEventArgs keyEvent)
|
||||
{
|
||||
switch(keyEvent.KeyCode)
|
||||
{
|
||||
case Keys.Up:
|
||||
zPlusControl_Click(null, null);
|
||||
container.nextButton.Enabled = true;
|
||||
break;
|
||||
|
||||
case Keys.Down:
|
||||
zMinusControl_Click(null, null);
|
||||
container.nextButton.Enabled = true;
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
if (container.nextButton.Enabled)
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
if (container.backButton.Enabled)
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.backButton.OnClick(null));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
base.OnKeyDown(keyEvent);
|
||||
}
|
||||
|
||||
private void zMinusControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, -moveAmount, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
}
|
||||
|
||||
private void zPlusControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, moveAmount, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
}
|
||||
}
|
||||
|
||||
public class AutoProbeFeedback : InstructionsPage
|
||||
{
|
||||
private Vector3 lastReportedPosition;
|
||||
private List<ProbePosition> probePositions;
|
||||
int probePositionsBeingEditedIndex;
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
protected Vector3 probeStartPosition;
|
||||
protected WizardControl container;
|
||||
|
||||
public AutoProbeFeedback(PrinterConfig printer, WizardControl container, Vector3 probeStartPosition, string pageDescription, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex, ThemeConfig theme)
|
||||
: base(printer, pageDescription, pageDescription, theme)
|
||||
{
|
||||
this.container = container;
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
|
||||
this.probePositions = probePositions;
|
||||
|
||||
this.lastReportedPosition = printer.Connection.LastReportedPosition;
|
||||
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
|
||||
|
||||
GuiWidget spacer = new GuiWidget(15, 15);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
||||
FlowLayoutWidget textFields = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
}
|
||||
|
||||
private void GetZProbeHeight(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
double sampleRead = double.MinValue;
|
||||
if (currentEvent.Data.StartsWith("Bed")) // marlin G30 return code (looks like: 'Bed Position X:20 Y:32 Z:.01')
|
||||
{
|
||||
probePositions[probePositionsBeingEditedIndex].position.X = probeStartPosition.X;
|
||||
probePositions[probePositionsBeingEditedIndex].position.Y = probeStartPosition.Y;
|
||||
GCodeFile.GetFirstNumberAfter("Z:", currentEvent.Data, ref sampleRead);
|
||||
}
|
||||
else if (currentEvent.Data.StartsWith("Z:")) // smoothie G30 return code (looks like: 'Z:10.01')
|
||||
{
|
||||
probePositions[probePositionsBeingEditedIndex].position.X = probeStartPosition.X;
|
||||
probePositions[probePositionsBeingEditedIndex].position.Y = probeStartPosition.Y;
|
||||
// smoothie returns the position relative to the start position
|
||||
double reportedProbeZ = 0;
|
||||
GCodeFile.GetFirstNumberAfter("Z:", currentEvent.Data, ref reportedProbeZ);
|
||||
sampleRead = probeStartPosition.Z - reportedProbeZ;
|
||||
}
|
||||
|
||||
if (sampleRead != double.MinValue)
|
||||
{
|
||||
samples.Add(sampleRead);
|
||||
|
||||
int numberOfSamples = printer.Settings.GetValue<int>(SettingsKey.z_probe_samples);
|
||||
if (samples.Count == numberOfSamples)
|
||||
{
|
||||
samples.Sort();
|
||||
if (samples.Count > 3)
|
||||
{
|
||||
// drop the high and low values
|
||||
samples.RemoveAt(0);
|
||||
samples.RemoveAt(samples.Count - 1);
|
||||
}
|
||||
|
||||
probePositions[probePositionsBeingEditedIndex].position.Z = Math.Round(samples.Average(), 2);
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
List<double> samples = new List<double>();
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// always make sure we don't have print leveling turned on
|
||||
PrintLevelingStream.AllowLeveling = false;
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
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))
|
||||
{
|
||||
// make sure the servo is deployed
|
||||
var servoDeploy = printer.Settings.GetValue<double>(SettingsKey.z_servo_depolyed_angle);
|
||||
printer.Connection.QueueLine($"M280 P0 S{servoDeploy}");
|
||||
}
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
var adjustedProbePosition = probeStartPosition;
|
||||
// subtract out the probe offset
|
||||
var probeOffset = printer.Settings.GetValue<Vector2>(SettingsKey.z_probe_xy_offset);
|
||||
adjustedProbePosition -= new Vector3(probeOffset);
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(adjustedProbePosition, feedRates.X);
|
||||
|
||||
int numberOfSamples = printer.Settings.GetValue<int>(SettingsKey.z_probe_samples);
|
||||
for (int i = 0; i < numberOfSamples; i++)
|
||||
{
|
||||
// probe the current position
|
||||
printer.Connection.QueueLine("G30");
|
||||
// raise the probe after each sample
|
||||
printer.Connection.MoveAbsolute(adjustedProbePosition, feedRates.X);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
if (printer.Connection.IsConnected
|
||||
&& !(printer.Connection.PrinterIsPrinting
|
||||
|| printer.Connection.PrinterIsPaused))
|
||||
{
|
||||
printer.Connection.LineReceived.RegisterEvent(GetZProbeHeight, ref unregisterEvents);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
printer.Connection.LineReceived.UnregisterEvent(GetZProbeHeight, ref unregisterEvents);
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
|
||||
public class GetCoarseBedHeight : FindBedHeight
|
||||
{
|
||||
protected Vector3 probeStartPosition;
|
||||
|
||||
public GetCoarseBedHeight(PrinterConfig printer, WizardControl container, Vector3 probeStartPosition, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, "Using the [Z] controls on this screen, we will now take a coarse measurement of the extruder height at this position.".Localize(),
|
||||
levelingStrings.CoarseInstruction2, 1, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
// make sure the probe is not deployed
|
||||
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))
|
||||
{
|
||||
// make sure the servo is retracted
|
||||
var servoRetract = printer.Settings.GetValue<double>(SettingsKey.z_servo_retracted_angle);
|
||||
printer.Connection.QueueLine($"M280 P0 S{servoRetract}");
|
||||
}
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, feedRates.X);
|
||||
printer.Connection.ReadPosition();
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
zPlusControl.Click += zControl_Click;
|
||||
zMinusControl.Click += zControl_Click;
|
||||
}
|
||||
|
||||
protected void zControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
container.nextButton.Enabled = true;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
container.backButton.Enabled = true;
|
||||
container.nextButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
|
||||
public class GetFineBedHeight : FindBedHeight
|
||||
{
|
||||
public GetFineBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, levelingStrings.FineInstruction1, levelingStrings.FineInstruction2, .1, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class GetUltraFineBedHeight : FindBedHeight
|
||||
{
|
||||
public GetUltraFineBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, levelingStrings.UltraFineInstruction1, levelingStrings.FineInstruction2, .02, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
}
|
||||
|
||||
private bool haveDrawn = false;
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
haveDrawn = true;
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
if (haveDrawn)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
}
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -67,7 +67,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
printLevelWizard = new WizardControl();
|
||||
AddChild(printLevelWizard);
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.probe_has_been_calibrated))
|
||||
// make a welocme page if this is the first time calibrating the probe
|
||||
if (!printer.Settings.GetValue<bool>(SettingsKey.probe_has_been_calibrated))
|
||||
{
|
||||
string part1 = "Congratulations on connecting to your printer. Before starting your first print we need to run a simple calibration procedure.".Localize();
|
||||
string part2 = "The next few screens will walk your through calibrating your printer.".Localize();
|
||||
|
|
@ -75,6 +76,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
printLevelWizard.AddPage(new FirstPageInstructions(printer, levelingStrings.initialPrinterSetupStepText, requiredPageInstructions, theme));
|
||||
}
|
||||
|
||||
// show what steps will be taken
|
||||
var CalibrateProbeWelcomText = "{0}\n\n\t• {1}\n\t• {2}\n\t• {3}\n\n{4}\n\n{5}".FormatWith(
|
||||
"Welcome to the probe calibration wizard. Here is a quick overview on what we are going to do.".Localize(),
|
||||
"Home the printer".Localize(),
|
||||
|
|
@ -86,14 +88,32 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
printLevelWizard.AddPage(new FirstPageInstructions(printer,
|
||||
"Probe Calibration Overview".Localize(), CalibrateProbeWelcomText, theme));
|
||||
|
||||
printLevelWizard.AddPage(new CleanExtruderInstructionPage(printer, "Check Nozzle".Localize(), levelingStrings.CleanExtruder, theme));
|
||||
// add in the material select page
|
||||
var instruction1 = "The hot end needs to be heated to ensure it is clean.".Localize();
|
||||
var instruction2 = "Please select the material you will be printing, so we can heat the printer before calibrating.".Localize();
|
||||
printLevelWizard.AddPage(new SelectMaterialPage(printer, "Select Material".Localize(), $"{instruction1}\n\n{instruction2}", theme));
|
||||
|
||||
bool useZProbe = printer.Settings.Helpers.UseZProbe();
|
||||
// add in the homing printer page
|
||||
printLevelWizard.AddPage(new HomePrinterPage(printer, printLevelWizard,
|
||||
levelingStrings.HomingPageStepText,
|
||||
levelingStrings.HomingPageInstructions(useZProbe, false),
|
||||
levelingStrings.HomingPageInstructions(true, false),
|
||||
false, theme));
|
||||
|
||||
string heatingInstructions = "";
|
||||
double targetHotendTemp = 0;
|
||||
|
||||
targetHotendTemp = printer.Settings.Helpers.ExtruderTemperature(0);
|
||||
heatingInstructions += $"Waiting for the hotend to heat to {targetHotendTemp}.".Localize() + "\n"
|
||||
+ "This will ensure no filament is stuck to the tip.".Localize() + "\n"
|
||||
+ "\n"
|
||||
+ "Warning! The tip of the extrude will be HOT!".Localize() + "\n"
|
||||
+ "Avoid contact with your skin.".Localize();
|
||||
|
||||
printLevelWizard.AddPage(new WaitForTempPage(printer, printLevelWizard,
|
||||
"Waiting For Printer To Heat".Localize(), heatingInstructions,
|
||||
0, targetHotendTemp,
|
||||
theme));
|
||||
|
||||
string lowPrecisionLabel = "Low Precision".Localize();
|
||||
string medPrecisionLabel = "Medium Precision".Localize();
|
||||
string highPrecisionLabel = "High Precision".Localize();
|
||||
|
|
|
|||
174
ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs
Normal file
174
ConfigurationPage/PrintLeveling/WizardPages/AutoProbeFeedback.cs
Normal file
|
|
@ -0,0 +1,174 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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 MatterControl.Printing;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class AutoProbeFeedback : InstructionsPage
|
||||
{
|
||||
private Vector3 lastReportedPosition;
|
||||
private List<ProbePosition> probePositions;
|
||||
int probePositionsBeingEditedIndex;
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
protected Vector3 probeStartPosition;
|
||||
protected WizardControl container;
|
||||
|
||||
public AutoProbeFeedback(PrinterConfig printer, WizardControl container, Vector3 probeStartPosition, string pageDescription, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex, ThemeConfig theme)
|
||||
: base(printer, pageDescription, pageDescription, theme)
|
||||
{
|
||||
this.container = container;
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
|
||||
this.probePositions = probePositions;
|
||||
|
||||
this.lastReportedPosition = printer.Connection.LastReportedPosition;
|
||||
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
|
||||
|
||||
GuiWidget spacer = new GuiWidget(15, 15);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
||||
FlowLayoutWidget textFields = new FlowLayoutWidget(FlowDirection.TopToBottom);
|
||||
}
|
||||
|
||||
private void GetZProbeHeight(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
double sampleRead = double.MinValue;
|
||||
if (currentEvent.Data.StartsWith("Bed")) // marlin G30 return code (looks like: 'Bed Position X:20 Y:32 Z:.01')
|
||||
{
|
||||
probePositions[probePositionsBeingEditedIndex].position.X = probeStartPosition.X;
|
||||
probePositions[probePositionsBeingEditedIndex].position.Y = probeStartPosition.Y;
|
||||
GCodeFile.GetFirstNumberAfter("Z:", currentEvent.Data, ref sampleRead);
|
||||
}
|
||||
else if (currentEvent.Data.StartsWith("Z:")) // smoothie G30 return code (looks like: 'Z:10.01')
|
||||
{
|
||||
probePositions[probePositionsBeingEditedIndex].position.X = probeStartPosition.X;
|
||||
probePositions[probePositionsBeingEditedIndex].position.Y = probeStartPosition.Y;
|
||||
// smoothie returns the position relative to the start position
|
||||
double reportedProbeZ = 0;
|
||||
GCodeFile.GetFirstNumberAfter("Z:", currentEvent.Data, ref reportedProbeZ);
|
||||
sampleRead = probeStartPosition.Z - reportedProbeZ;
|
||||
}
|
||||
|
||||
if (sampleRead != double.MinValue)
|
||||
{
|
||||
samples.Add(sampleRead);
|
||||
|
||||
int numberOfSamples = printer.Settings.GetValue<int>(SettingsKey.z_probe_samples);
|
||||
if (samples.Count == numberOfSamples)
|
||||
{
|
||||
samples.Sort();
|
||||
if (samples.Count > 3)
|
||||
{
|
||||
// drop the high and low values
|
||||
samples.RemoveAt(0);
|
||||
samples.RemoveAt(samples.Count - 1);
|
||||
}
|
||||
|
||||
probePositions[probePositionsBeingEditedIndex].position.Z = Math.Round(samples.Average(), 2);
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
List<double> samples = new List<double>();
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// always make sure we don't have print leveling turned on
|
||||
PrintLevelingStream.AllowLeveling = false;
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
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))
|
||||
{
|
||||
// make sure the servo is deployed
|
||||
var servoDeploy = printer.Settings.GetValue<double>(SettingsKey.z_servo_depolyed_angle);
|
||||
printer.Connection.QueueLine($"M280 P0 S{servoDeploy}");
|
||||
}
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
var adjustedProbePosition = probeStartPosition;
|
||||
// subtract out the probe offset
|
||||
var probeOffset = printer.Settings.GetValue<Vector2>(SettingsKey.z_probe_xy_offset);
|
||||
adjustedProbePosition -= new Vector3(probeOffset);
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(adjustedProbePosition, feedRates.X);
|
||||
|
||||
int numberOfSamples = printer.Settings.GetValue<int>(SettingsKey.z_probe_samples);
|
||||
for (int i = 0; i < numberOfSamples; i++)
|
||||
{
|
||||
// probe the current position
|
||||
printer.Connection.QueueLine("G30");
|
||||
// raise the probe after each sample
|
||||
printer.Connection.MoveAbsolute(adjustedProbePosition, feedRates.X);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
if (printer.Connection.IsConnected
|
||||
&& !(printer.Connection.PrinterIsPrinting
|
||||
|| printer.Connection.PrinterIsPaused))
|
||||
{
|
||||
printer.Connection.LineReceived.RegisterEvent(GetZProbeHeight, ref unregisterEvents);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
printer.Connection.LineReceived.UnregisterEvent(GetZProbeHeight, ref unregisterEvents);
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class CalibrateProbeLastPagelInstructions : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private List<ProbePosition> autoProbePositions;
|
||||
private List<ProbePosition> manualProbePositions;
|
||||
private ThemeConfig theme;
|
||||
|
||||
public CalibrateProbeLastPagelInstructions(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText,
|
||||
List<ProbePosition> autoProbePositions,
|
||||
List<ProbePosition> manualProbePositions, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.theme = theme;
|
||||
this.autoProbePositions = autoProbePositions;
|
||||
this.manualProbePositions = manualProbePositions;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// make sure we don't have leveling data
|
||||
double newProbeOffset = autoProbePositions[0].position.Z - manualProbePositions[0].position.Z;
|
||||
printer.Settings.SetValue(SettingsKey.z_probe_z_offset, newProbeOffset.ToString("0.###"));
|
||||
printer.Settings.SetValue(SettingsKey.probe_has_been_calibrated, "1");
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
|
||||
Closed += (s, e) =>
|
||||
{
|
||||
// move from this wizard to the print leveling wizard if needed
|
||||
ApplicationController.Instance.RunAnyRequiredCalibration(printer, theme);
|
||||
};
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
173
ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs
Normal file
173
ConfigurationPage/PrintLeveling/WizardPages/FindBedHeight.cs
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class FindBedHeight : InstructionsPage
|
||||
{
|
||||
private Vector3 lastReportedPosition;
|
||||
private List<ProbePosition> probePositions;
|
||||
int probePositionsBeingEditedIndex;
|
||||
private double moveAmount;
|
||||
|
||||
protected JogControls.MoveButton zPlusControl;
|
||||
protected JogControls.MoveButton zMinusControl;
|
||||
protected WizardControl container;
|
||||
|
||||
public FindBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance,
|
||||
List<ProbePosition> probePositions, int probePositionsBeingEditedIndex, ThemeConfig theme)
|
||||
: base(printer, pageDescription, setZHeightCoarseInstruction1, theme)
|
||||
{
|
||||
this.container = container;
|
||||
this.probePositions = probePositions;
|
||||
this.moveAmount = moveDistance;
|
||||
this.lastReportedPosition = printer.Connection.LastReportedPosition;
|
||||
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
|
||||
|
||||
GuiWidget spacer = new GuiWidget(15, 15);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
||||
FlowLayoutWidget zButtonsAndInfo = new FlowLayoutWidget();
|
||||
zButtonsAndInfo.HAnchor |= Agg.UI.HAnchor.Center;
|
||||
FlowLayoutWidget zButtons = CreateZButtons();
|
||||
zButtonsAndInfo.AddChild(zButtons);
|
||||
|
||||
zButtonsAndInfo.AddChild(new GuiWidget(15, 10));
|
||||
|
||||
//textFields
|
||||
TextWidget zPosition = new TextWidget("Z: 0.0 ", pointSize: 12, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
VAnchor = VAnchor.Center,
|
||||
Margin = new BorderDouble(10, 0),
|
||||
};
|
||||
|
||||
UiThread.SetInterval(() =>
|
||||
{
|
||||
Vector3 destinationPosition = printer.Connection.CurrentDestination;
|
||||
zPosition.Text = "Z: {0:0.00}".FormatWith(destinationPosition.Z);
|
||||
}, .3, () => !HasBeenClosed);
|
||||
|
||||
zButtonsAndInfo.AddChild(zPosition);
|
||||
|
||||
topToBottomControls.AddChild(zButtonsAndInfo);
|
||||
|
||||
AddTextField(setZHeightCoarseInstruction2, 10, theme);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// always make sure we don't have print leveling turned on
|
||||
PrintLevelingStream.AllowLeveling = false;
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
this.Parents<SystemWindow>().First().KeyDown += TopWindowKeyDown;
|
||||
|
||||
container.nextButton.ToolTipText = "[Right Arrow]".Localize();
|
||||
container.backButton.ToolTipText = "[Left Arrow]".Localize();
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
this.Parents<SystemWindow>().First().KeyDown -= TopWindowKeyDown;
|
||||
probePositions[probePositionsBeingEditedIndex].position = printer.Connection.LastReportedPosition;
|
||||
base.PageIsBecomingInactive();
|
||||
|
||||
container.nextButton.ToolTipText = "";
|
||||
container.backButton.ToolTipText = "";
|
||||
}
|
||||
|
||||
private FlowLayoutWidget CreateZButtons()
|
||||
{
|
||||
FlowLayoutWidget zButtons = JogControls.CreateZButtons(printer, Color.White, 4, out zPlusControl, out zMinusControl, true);
|
||||
// set these to 0 so the button does not do any movements by default (we will handle the movement on our click callback)
|
||||
zPlusControl.MoveAmount = 0;
|
||||
zPlusControl.ToolTipText += " [Up Arrow]".Localize();
|
||||
zPlusControl.Click += zPlusControl_Click;
|
||||
|
||||
zMinusControl.MoveAmount = 0;
|
||||
zMinusControl.ToolTipText += " [Down Arrow]".Localize();
|
||||
zMinusControl.Click += zMinusControl_Click;
|
||||
return zButtons;
|
||||
}
|
||||
|
||||
public void TopWindowKeyDown(object s, KeyEventArgs keyEvent)
|
||||
{
|
||||
switch(keyEvent.KeyCode)
|
||||
{
|
||||
case Keys.Up:
|
||||
zPlusControl_Click(null, null);
|
||||
container.nextButton.Enabled = true;
|
||||
break;
|
||||
|
||||
case Keys.Down:
|
||||
zMinusControl_Click(null, null);
|
||||
container.nextButton.Enabled = true;
|
||||
break;
|
||||
|
||||
case Keys.Right:
|
||||
if (container.nextButton.Enabled)
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
break;
|
||||
|
||||
case Keys.Left:
|
||||
if (container.backButton.Enabled)
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.backButton.OnClick(null));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
base.OnKeyDown(keyEvent);
|
||||
}
|
||||
|
||||
private void zMinusControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, -moveAmount, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
}
|
||||
|
||||
private void zPlusControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, moveAmount, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg.Font;
|
||||
using MatterHackers.Agg.Image;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using System.Linq;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class FirstPageInstructions : InstructionsPage
|
||||
{
|
||||
public FirstPageInstructions(PrinterConfig printer, string pageDescription, string instructionsText, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class GetCoarseBedHeight : FindBedHeight
|
||||
{
|
||||
protected Vector3 probeStartPosition;
|
||||
|
||||
public GetCoarseBedHeight(PrinterConfig printer, WizardControl container, Vector3 probeStartPosition, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, "Using the [Z] controls on this screen, we will now take a coarse measurement of the extruder height at this position.".Localize(),
|
||||
levelingStrings.CoarseInstruction2, 1, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
// make sure the probe is not deployed
|
||||
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))
|
||||
{
|
||||
// make sure the servo is retracted
|
||||
var servoRetract = printer.Settings.GetValue<double>(SettingsKey.z_servo_retracted_angle);
|
||||
printer.Connection.QueueLine($"M280 P0 S{servoRetract}");
|
||||
}
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, feedRates.X);
|
||||
printer.Connection.ReadPosition();
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
zPlusControl.Click += zControl_Click;
|
||||
zMinusControl.Click += zControl_Click;
|
||||
}
|
||||
|
||||
protected void zControl_Click(object sender, EventArgs mouseEvent)
|
||||
{
|
||||
container.nextButton.Enabled = true;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
container.backButton.Enabled = true;
|
||||
container.nextButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class GetFineBedHeight : FindBedHeight
|
||||
{
|
||||
public GetFineBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, levelingStrings.FineInstruction1, levelingStrings.FineInstruction2, .1, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class GetUltraFineBedHeight : FindBedHeight
|
||||
{
|
||||
public GetUltraFineBedHeight(PrinterConfig printer, WizardControl container, string pageDescription, List<ProbePosition> probePositions,
|
||||
int probePositionsBeingEditedIndex, LevelingStrings levelingStrings, ThemeConfig theme)
|
||||
: base(printer, container, pageDescription, levelingStrings.UltraFineInstruction1, levelingStrings.FineInstruction2, .02, probePositions, probePositionsBeingEditedIndex, theme)
|
||||
{
|
||||
}
|
||||
|
||||
private bool haveDrawn = false;
|
||||
|
||||
public override void OnDraw(Graphics2D graphics2D)
|
||||
{
|
||||
haveDrawn = true;
|
||||
base.OnDraw(graphics2D);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
if (haveDrawn)
|
||||
{
|
||||
printer.Connection.MoveRelative(PrinterConnection.Axis.Z, 2, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
}
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class GettingThirdPointFor2PointCalibration : InstructionsPage
|
||||
{
|
||||
protected Vector3 probeStartPosition;
|
||||
private ProbePosition probePosition;
|
||||
protected WizardControl container;
|
||||
|
||||
public GettingThirdPointFor2PointCalibration(PrinterConfig printer, WizardControl container, string pageDescription, Vector3 probeStartPosition, string instructionsText,
|
||||
ProbePosition probePosition, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
this.probePosition = probePosition;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
private EventHandler unregisterEvents;
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// first make sure there is no leftover FinishedProbe event
|
||||
printer.Connection.LineReceived.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
var feedRates = printer.Settings.Helpers.ManualMovementSpeeds();
|
||||
|
||||
printer.Connection.MoveAbsolute(PrinterConnection.Axis.Z, probeStartPosition.Z, feedRates.Z);
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, feedRates.X);
|
||||
printer.Connection.QueueLine("G30");
|
||||
printer.Connection.LineReceived.RegisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
container.nextButton.Enabled = false;
|
||||
container.backButton.Enabled = false;
|
||||
}
|
||||
|
||||
private void FinishedProbe(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
if (currentEvent.Data.Contains("endstops hit"))
|
||||
{
|
||||
printer.Connection.LineReceived.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
int zStringPos = currentEvent.Data.LastIndexOf("Z:");
|
||||
string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
|
||||
probePosition.position = new Vector3(probeStartPosition.X, probeStartPosition.Y, double.Parse(zProbeHeight));
|
||||
printer.Connection.MoveAbsolute(probeStartPosition, printer.Settings.Helpers.ManualMovementSpeeds().Z);
|
||||
printer.Connection.ReadPosition();
|
||||
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,96 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg.UI;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class HomePrinterPage : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private EventHandler unregisterEvents;
|
||||
bool autoAdvance;
|
||||
|
||||
public HomePrinterPage(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText, bool autoAdvance, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.autoAdvance = autoAdvance;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void OnClosed(ClosedEventArgs e)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
base.OnClosed(e);
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// make sure we don't have anything left over
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
|
||||
printer.Connection.CommunicationStateChanged.RegisterEvent(CheckHomeFinished, ref unregisterEvents);
|
||||
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
|
||||
if (autoAdvance)
|
||||
{
|
||||
container.nextButton.Enabled = false;
|
||||
}
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
|
||||
private void CheckHomeFinished(object sender, EventArgs e)
|
||||
{
|
||||
if(printer.Connection.DetailedPrintingState != DetailedPrintingState.HomingAxis)
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
if (printer.Settings.Helpers.UseZProbe())
|
||||
{
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
unregisterEvents?.Invoke(this, null);
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg.UI;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.PrinterCommunication.Io;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class LastPagelInstructions : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
private List<ProbePosition> probePositions;
|
||||
|
||||
public LastPagelInstructions(PrinterConfig printer, WizardControl container, string pageDescription, string instructionsText, List<ProbePosition> probePositions, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
this.container = container;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
PrintLevelingData levelingData = printer.Settings.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPositions.Clear();
|
||||
|
||||
for (int i = 0; i < probePositions.Count; i++)
|
||||
{
|
||||
levelingData.SampledPositions.Add(probePositions[i].position);
|
||||
}
|
||||
|
||||
levelingData.LevelingSystem = printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution);
|
||||
levelingData.CreationData = DateTime.Now;
|
||||
// record the temp the bed was when we measured it (or 0 if no heated bed)
|
||||
levelingData.BedTemperature = printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed) ?
|
||||
printer.Settings.GetValue<double>(SettingsKey.bed_temperature)
|
||||
: 0;
|
||||
|
||||
// Invoke setter forcing persistence of leveling data
|
||||
printer.Settings.Helpers.SetPrintLevelingData(levelingData, true);
|
||||
PrintLevelingStream.AllowLeveling = true;
|
||||
printer.Settings.Helpers.DoPrintLeveling(true);
|
||||
|
||||
if (printer.Settings.GetValue<bool>(SettingsKey.z_homes_to_max))
|
||||
{
|
||||
printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ);
|
||||
}
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
|
||||
// Make sure when the wizard is done we turn off the bed heating
|
||||
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class SelectMaterialPage : InstructionsPage
|
||||
{
|
||||
public SelectMaterialPage(PrinterConfig printer, string pageDescription, string instructionsText, ThemeConfig theme)
|
||||
: base(printer, pageDescription, instructionsText, theme)
|
||||
{
|
||||
var materialSelector = new PresetSelectorWidget(printer, "Material".Localize(), Color.Transparent, NamedSettingsLayers.Material);
|
||||
materialSelector.BackgroundColor = Color.Transparent;
|
||||
materialSelector.Margin = new BorderDouble(0, 0, 0, 15);
|
||||
topToBottomControls.AddChild(materialSelector);
|
||||
}
|
||||
}
|
||||
}
|
||||
259
ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs
Normal file
259
ConfigurationPage/PrintLeveling/WizardPages/WaitForTempPage.cs
Normal file
|
|
@ -0,0 +1,259 @@
|
|||
/*
|
||||
Copyright (c) 2014, Lars Brubaker
|
||||
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.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class WaitForTempPage : InstructionsPage
|
||||
{
|
||||
protected WizardControl container;
|
||||
|
||||
private ProgressBar bedProgressBar;
|
||||
private TextWidget bedProgressBarText;
|
||||
private double bedStartingTemp;
|
||||
private TextWidget bedDoneText;
|
||||
double bedTargetTemp;
|
||||
|
||||
private ProgressBar hotEndProgressBar;
|
||||
private TextWidget hotEndProgressBarText;
|
||||
private double hotEndStartingTemp;
|
||||
private TextWidget hotEndDoneText;
|
||||
double hotEndTargetTemp;
|
||||
|
||||
public WaitForTempPage(PrinterConfig printer, WizardControl container,
|
||||
string step, string instructions,
|
||||
double targetBedTemp, double targetHotendTemp,
|
||||
ThemeConfig theme)
|
||||
: base(printer, step, instructions, theme)
|
||||
{
|
||||
this.bedTargetTemp = targetBedTemp;
|
||||
this.hotEndTargetTemp = targetHotendTemp;
|
||||
this.container = container;
|
||||
|
||||
if (hotEndTargetTemp > 0)
|
||||
{
|
||||
var hotEndProgressHolder = new FlowLayoutWidget()
|
||||
{
|
||||
Margin = new BorderDouble(0, 5)
|
||||
};
|
||||
|
||||
// put in bar name
|
||||
var hoteEndText = new TextWidget("Hotend Temperature:".Localize(), pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 5, 5),
|
||||
};
|
||||
topToBottomControls.AddChild(hoteEndText);
|
||||
|
||||
// put in the progress bar
|
||||
hotEndProgressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
|
||||
{
|
||||
FillColor = ActiveTheme.Instance.PrimaryAccentColor,
|
||||
BorderColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
BackgroundColor = Color.White,
|
||||
Margin = new BorderDouble(3, 0, 0, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
hotEndProgressHolder.AddChild(hotEndProgressBar);
|
||||
|
||||
// put in the status
|
||||
hotEndProgressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 5, 5),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
hotEndProgressHolder.AddChild(hotEndProgressBarText);
|
||||
|
||||
// message to show when done
|
||||
hotEndDoneText = new TextWidget("Done!", textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Visible = false,
|
||||
};
|
||||
|
||||
hotEndProgressHolder.AddChild(hotEndDoneText);
|
||||
|
||||
topToBottomControls.AddChild(hotEndProgressHolder);
|
||||
}
|
||||
|
||||
if (bedTargetTemp > 0)
|
||||
{
|
||||
var bedProgressHolder = new FlowLayoutWidget()
|
||||
{
|
||||
Margin = new BorderDouble(0, 5)
|
||||
};
|
||||
|
||||
// put in bar name
|
||||
var hoteEndText = new TextWidget("Bed Temperature:".Localize(), pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 5, 5),
|
||||
};
|
||||
topToBottomControls.AddChild(hoteEndText);
|
||||
|
||||
// put in progress bar
|
||||
bedProgressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
|
||||
{
|
||||
FillColor = ActiveTheme.Instance.PrimaryAccentColor,
|
||||
BorderColor = ActiveTheme.Instance.PrimaryTextColor,
|
||||
BackgroundColor = Color.White,
|
||||
Margin = new BorderDouble(3, 0, 0, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
bedProgressHolder.AddChild(bedProgressBar);
|
||||
|
||||
// put in status
|
||||
bedProgressBarText = new TextWidget("", pointSize: 10, textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 0, 0),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
bedProgressHolder.AddChild(bedProgressBarText);
|
||||
|
||||
// message to show when done
|
||||
bedDoneText = new TextWidget("Done!", textColor: ActiveTheme.Instance.PrimaryTextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Visible = false,
|
||||
};
|
||||
|
||||
bedProgressHolder.AddChild(bedDoneText);
|
||||
|
||||
topToBottomControls.AddChild(bedProgressHolder);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
bedStartingTemp = printer.Connection.ActualBedTemperature;
|
||||
|
||||
UiThread.SetInterval(ShowTempChangeProgress, 1, () => !HasBeenClosed);
|
||||
|
||||
if (bedTargetTemp > 0)
|
||||
{
|
||||
// start heating the bed and show our progress
|
||||
printer.Connection.TargetBedTemperature = bedTargetTemp;
|
||||
}
|
||||
|
||||
if (hotEndTargetTemp > 0)
|
||||
{
|
||||
// start heating the bed and show our progress
|
||||
printer.Connection.SetTargetHotendTemperature(0, hotEndTargetTemp);
|
||||
}
|
||||
|
||||
// hook our parent so we can turn off the bed when we are done with leveling
|
||||
Parent.Closed += (s, e) =>
|
||||
{
|
||||
// Make sure when the wizard closes we turn off the bed heating
|
||||
printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay);
|
||||
};
|
||||
|
||||
container.backButton.Enabled = false;
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
// if we are trying to go to a temp of 0 than just move on to next window
|
||||
if(bedTargetTemp == 0 && hotEndTargetTemp == 0)
|
||||
{
|
||||
// advance to the next page
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
container.nextButton.Enabled = true;
|
||||
container.backButton.Enabled = true;
|
||||
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
|
||||
private void ShowTempChangeProgress()
|
||||
{
|
||||
if (hotEndTargetTemp > 0)
|
||||
{
|
||||
hotEndProgressBar.Visible = true;
|
||||
double targetTemp = printer.Connection.GetTargetHotendTemperature(0);
|
||||
double actualTemp = printer.Connection.GetActualHotendTemperature(0);
|
||||
double totalDelta = targetTemp - hotEndStartingTemp;
|
||||
double currentDelta = actualTemp - hotEndStartingTemp;
|
||||
double ratioDone = hotEndDoneText.Visible ? 1 : totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
hotEndProgressBar.RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
hotEndProgressBarText.Text = $"{actualTemp:0} / {targetTemp:0}";
|
||||
|
||||
// if we are within 1 degree of our target
|
||||
if (Math.Abs(targetTemp - actualTemp) < 2
|
||||
&& hotEndDoneText.Visible == false)
|
||||
{
|
||||
hotEndDoneText.Visible = true;
|
||||
container.backButton.Enabled = true;
|
||||
container.nextButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (bedTargetTemp > 0)
|
||||
{
|
||||
bedProgressBar.Visible = true;
|
||||
double targetTemp = printer.Connection.TargetBedTemperature;
|
||||
double actualTemp = printer.Connection.ActualBedTemperature;
|
||||
double totalDelta = targetTemp - bedStartingTemp;
|
||||
double currentDelta = actualTemp - bedStartingTemp;
|
||||
double ratioDone = bedDoneText.Visible ? 1 : totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
bedProgressBar.RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
bedProgressBarText.Text = $"{actualTemp:0} / {targetTemp:0}";
|
||||
|
||||
// if we are within 1 degree of our target
|
||||
if (Math.Abs(targetTemp - actualTemp) < 2
|
||||
&& bedDoneText.Visible == false)
|
||||
{
|
||||
bedDoneText.Visible = true;
|
||||
container.backButton.Enabled = true;
|
||||
container.nextButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((bedTargetTemp == 0 || bedDoneText.Visible)
|
||||
&& (hotEndTargetTemp == 0 || hotEndDoneText.Visible)
|
||||
&& !HasBeenClosed)
|
||||
{
|
||||
// advance to the next page
|
||||
UiThread.RunOnIdle(() => container.nextButton.OnClick(null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue