Make it possible to have the print leveling go negative
Took out the 2 point leveling solution MatterHackers/MatterControl#804
This commit is contained in:
parent
426c0ede6a
commit
3bb439d198
16 changed files with 212 additions and 610 deletions
|
|
@ -1,262 +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 MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.GCodeVisualizer;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class LevelWizard2Point : LevelWizardBase
|
||||
{
|
||||
private static Vector2 probeFrontLeft = new Vector2(0, 0);
|
||||
private static Vector2 probeFrontRight = new Vector2(220, 0);
|
||||
private static Vector2 probeBackLeft = new Vector2(0, 210);
|
||||
private static double probeStartZHeight = 10;
|
||||
|
||||
private string pageOneStepText = "Print Leveling Overview".Localize();
|
||||
private string pageOneInstructionsTextOne = LocalizedString.Get("Welcome to the print leveling wizard. Here is a quick overview on what we are going to do.");
|
||||
private string pageOneInstructionsTextTwo = LocalizedString.Get("'Home' the printer");
|
||||
private string pageOneInstructionsTextThree = LocalizedString.Get("Sample the bed at two points");
|
||||
private string pageOneInstructionsTextFour = LocalizedString.Get("Turn auto leveling on");
|
||||
private string pageOneInstructionsText5 = LocalizedString.Get("You should be done in about 2 minutes.");
|
||||
private string pageOneInstructionsText6 = LocalizedString.Get("Note: Be sure the tip of the extrude is clean.");
|
||||
private string pageOneInstructionsText7 = LocalizedString.Get("Click 'Next' to continue.");
|
||||
|
||||
public LevelWizard2Point(LevelWizardBase.RuningState runningState)
|
||||
: base(500, 370, 6)
|
||||
{
|
||||
string printLevelWizardTitle = LocalizedString.Get("MatterControl");
|
||||
string printLevelWizardTitleFull = LocalizedString.Get("Print Leveling Wizard");
|
||||
Title = string.Format("{0} - {1}", printLevelWizardTitle, printLevelWizardTitleFull);
|
||||
ProbePosition[] probePositions = new ProbePosition[5];
|
||||
probePositions[0] = new ProbePosition();
|
||||
probePositions[1] = new ProbePosition();
|
||||
probePositions[2] = new ProbePosition();
|
||||
probePositions[3] = new ProbePosition();
|
||||
probePositions[4] = new ProbePosition();
|
||||
|
||||
printLevelWizard = new WizardControl();
|
||||
AddChild(printLevelWizard);
|
||||
|
||||
if (runningState == LevelWizardBase.RuningState.InitialStartupCalibration)
|
||||
{
|
||||
string requiredPageInstructions = "{0}\n\n{1}".FormatWith(requiredPageInstructions1, requiredPageInstructions2);
|
||||
printLevelWizard.AddPage(new FirstPageInstructions(initialPrinterSetupStepText, requiredPageInstructions));
|
||||
}
|
||||
|
||||
string pageOneInstructions = string.Format("{0}\n\n\t• {1}\n\t• {2}\n\t• {3}\n\n{4}\n\n{5}\n\n{6}", pageOneInstructionsTextOne, pageOneInstructionsTextTwo, pageOneInstructionsTextThree, pageOneInstructionsTextFour, pageOneInstructionsText5, pageOneInstructionsText6, pageOneInstructionsText7);
|
||||
printLevelWizard.AddPage(new FirstPageInstructions(pageOneStepText, pageOneInstructions));
|
||||
|
||||
string homingPageInstructions = string.Format("{0}:\n\n\t• {1}\n\n{2}", homingPageInstructionsTextOne, homingPageInstructionsTextTwo, homingPageInstructionsTextThree);
|
||||
printLevelWizard.AddPage(new HomePrinterPage(homingPageStepText, homingPageInstructions));
|
||||
|
||||
string positionLabelTwo = LocalizedString.Get("Position");
|
||||
string lowPrecisionTwoLabel = LocalizedString.Get("Low Precision");
|
||||
string medPrecisionTwoLabel = LocalizedString.Get("Medium Precision");
|
||||
string highPrecisionTwoLabel = LocalizedString.Get("High Precision");
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeightProbeFirst(printLevelWizard, new Vector3(probeFrontLeft, probeStartZHeight), string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabelTwo, lowPrecisionTwoLabel), probePositions[0], probePositions[1], true));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabelTwo, medPrecisionTwoLabel), probePositions[0]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabelTwo, highPrecisionTwoLabel), probePositions[0]));
|
||||
|
||||
string positionLabelThree = LocalizedString.Get("Position");
|
||||
string lowPrecisionLabelThree = LocalizedString.Get("Low Precision");
|
||||
string medPrecisionLabelThree = LocalizedString.Get("Medium Precision");
|
||||
string highPrecisionLabelThree = LocalizedString.Get("High Precision");
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeightProbeFirst(printLevelWizard, new Vector3(probeFrontRight, probeStartZHeight), string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabelThree, lowPrecisionLabelThree), probePositions[2], probePositions[3], true));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabelThree, medPrecisionLabelThree), probePositions[2]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabelThree, highPrecisionLabelThree), probePositions[2]));
|
||||
|
||||
string retrievingFinalPosition = "Getting the third point.";
|
||||
printLevelWizard.AddPage(new GettingThirdPointFor2PointCalibration(printLevelWizard, "Collecting Data", new Vector3(probeBackLeft, probeStartZHeight), retrievingFinalPosition, probePositions[4]));
|
||||
|
||||
string doneInstructions = string.Format("{0}\n\n\t• {1}\n\n{2}", doneInstructionsText, doneInstructionsTextTwo, doneInstructionsTextThree);
|
||||
printLevelWizard.AddPage(new LastPage2PointInstructions("Done".Localize(), doneInstructions, probePositions));
|
||||
}
|
||||
|
||||
private static event EventHandler unregisterEvents;
|
||||
|
||||
private static int probeIndex = 0;
|
||||
private static Vector3 probeRead0;
|
||||
private static Vector3 probeRead1;
|
||||
private static Vector3 probeRead2;
|
||||
|
||||
public static string ApplyLeveling(string lineBeingSent, Vector3 currentDestination, PrinterMachineInstruction.MovementTypes movementMode)
|
||||
{
|
||||
var settings = ActiveSliceSettings.Instance;
|
||||
if (settings?.GetValue<bool>(SettingsKey.print_leveling_enabled) == true
|
||||
&& (lineBeingSent.StartsWith("G0 ") || lineBeingSent.StartsWith("G1 ")))
|
||||
{
|
||||
lineBeingSent = PrintLevelingPlane.Instance.ApplyLeveling(currentDestination, movementMode, lineBeingSent);
|
||||
}
|
||||
|
||||
return lineBeingSent;
|
||||
}
|
||||
|
||||
public static List<string> ProcessCommand(string lineBeingSent)
|
||||
{
|
||||
int commentIndex = lineBeingSent.IndexOf(';');
|
||||
if (commentIndex > 0) // there is content in front of the ;
|
||||
{
|
||||
lineBeingSent = lineBeingSent.Substring(0, commentIndex).Trim();
|
||||
}
|
||||
List<string> lines = new List<string>();
|
||||
if (lineBeingSent == "G28")
|
||||
{
|
||||
lines.Add("G28 X0");
|
||||
lines.Add("G1 X1");
|
||||
lines.Add("G28 Y0");
|
||||
lines.Add("G1 Y1");
|
||||
lines.Add("G28 Z0");
|
||||
lines.Add("M114");
|
||||
}
|
||||
else if (lineBeingSent == "G29")
|
||||
{
|
||||
// first make sure we don't have any leftover reading.
|
||||
PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(null, null);
|
||||
}
|
||||
if (PrinterConnectionAndCommunication.Instance.CommunicationState == PrinterConnectionAndCommunication.CommunicationStates.Printing)
|
||||
{
|
||||
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(false);
|
||||
}
|
||||
|
||||
probeIndex = 0;
|
||||
PrinterConnectionAndCommunication.Instance.ReadLine.RegisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
StringBuilder commands = new StringBuilder();
|
||||
|
||||
var feedRates = ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds();
|
||||
|
||||
// make sure the probe offset is set to 0
|
||||
lines.Add("M565 Z0");
|
||||
|
||||
// probe position 0
|
||||
probeRead0 = new Vector3(probeFrontLeft, probeStartZHeight);
|
||||
// up in z
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.z));
|
||||
lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
|
||||
// move to xy
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.x));
|
||||
lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeFrontLeft.x, probeFrontLeft.y, probeStartZHeight));
|
||||
// probe
|
||||
lines.Add("G30");
|
||||
|
||||
// probe position 1
|
||||
probeRead1 = new Vector3(probeFrontRight, probeStartZHeight);
|
||||
// up in z
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.z));
|
||||
lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
|
||||
// move to xy
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.x));
|
||||
lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeFrontRight.x, probeFrontRight.y, probeStartZHeight));
|
||||
// probe
|
||||
lines.Add("G30");
|
||||
|
||||
// probe position 2
|
||||
probeRead2 = new Vector3(probeBackLeft, probeStartZHeight);
|
||||
// up in z
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.z));
|
||||
lines.Add("G1 {0}{1}".FormatWith("Z", probeStartZHeight));
|
||||
// move to xy
|
||||
lines.Add("G1 F{0}".FormatWith(feedRates.x));
|
||||
lines.Add("G1 X{0}Y{1}Z{2}".FormatWith(probeBackLeft.x, probeBackLeft.y, probeStartZHeight));
|
||||
// probe
|
||||
lines.Add("G30");
|
||||
lines.Add("M114");
|
||||
lines.Add("G1 Z1 F300");
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.Add(lineBeingSent);
|
||||
}
|
||||
|
||||
return lines;
|
||||
}
|
||||
|
||||
private static void FinishedProbe(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
if (currentEvent.Data.Contains("endstops hit"))
|
||||
{
|
||||
int zStringPos = currentEvent.Data.LastIndexOf("Z:");
|
||||
if (zStringPos != -1)
|
||||
{
|
||||
string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
|
||||
// store the position that the limit swich fires
|
||||
switch (probeIndex++)
|
||||
{
|
||||
case 0:
|
||||
probeRead0.z = double.Parse(zProbeHeight);
|
||||
break;
|
||||
|
||||
case 1:
|
||||
probeRead1.z = double.Parse(zProbeHeight);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
probeRead2.z = double.Parse(zProbeHeight);
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(null, null);
|
||||
}
|
||||
SetEquations();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetEquations()
|
||||
{
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
|
||||
// position 0 does not change as it is the distance from the switch trigger to the extruder tip.
|
||||
//levelingData.sampledPosition0 = levelingData.sampledPosition0;
|
||||
levelingData.SampledPosition1 = levelingData.SampledPosition0 + probeRead1;
|
||||
levelingData.SampledPosition2 = levelingData.SampledPosition0 + probeRead2;
|
||||
|
||||
ActiveSliceSettings.Instance.Helpers.SetPrintLevelingData(levelingData);
|
||||
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -54,10 +54,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
string printLevelWizardTitle = LocalizedString.Get("MatterControl");
|
||||
string printLevelWizardTitleFull = LocalizedString.Get("Print Leveling Wizard");
|
||||
Title = string.Format("{0} - {1}", printLevelWizardTitle, printLevelWizardTitleFull);
|
||||
ProbePosition[] probePositions = new ProbePosition[3];
|
||||
probePositions[0] = new ProbePosition();
|
||||
probePositions[1] = new ProbePosition();
|
||||
probePositions[2] = new ProbePosition();
|
||||
List<ProbePosition> probePositions = new List<ProbePosition>(3);
|
||||
probePositions.Add(new ProbePosition());
|
||||
probePositions.Add(new ProbePosition());
|
||||
probePositions.Add(new ProbePosition());
|
||||
|
||||
printLevelWizard = new WizardControl();
|
||||
AddChild(printLevelWizard);
|
||||
|
|
@ -80,19 +80,19 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
string highPrecisionLabel = LocalizedString.Get("High Precision");
|
||||
|
||||
Vector2 probeBackCenter = LevelWizardBase.GetPrintLevelPositionToSample(0);
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeBackCenter, 10), string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions[0]));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[0]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[0]));
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeBackCenter, 10), string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions, 0));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions, 0));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions, 0));
|
||||
|
||||
Vector2 probeFrontLeft = LevelWizardBase.GetPrintLevelPositionToSample(1);
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeFrontLeft, 10), string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions[1]));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[1]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[1]));
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeFrontLeft, 10), string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions,1));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions,1));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions,1));
|
||||
|
||||
Vector2 probeFrontRight = LevelWizardBase.GetPrintLevelPositionToSample(2);
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeFrontRight, 10), string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions[2]));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[2]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[2]));
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probeFrontRight, 10), string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, lowPrecisionLabel), probePositions,2));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions,2));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions,2));
|
||||
|
||||
string doneInstructions = string.Format("{0}\n\n\t• {1}\n\n{2}", doneInstructionsText, doneInstructionsTextTwo, doneInstructionsTextThree);
|
||||
printLevelWizard.AddPage(new LastPage3PointInstructions("Done".Localize(), doneInstructions, probePositions));
|
||||
|
|
|
|||
|
|
@ -185,10 +185,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
string printLevelWizardTitle = "MatterControl";
|
||||
string printLevelWizardTitleFull = "Print Leveling Wizard".Localize();
|
||||
Title = string.Format("{0} - {1}", printLevelWizardTitle, printLevelWizardTitleFull);
|
||||
ProbePosition[] probePositions = new ProbePosition[numberOfRadialSamples + 1];
|
||||
for (int i = 0; i < probePositions.Length; i++)
|
||||
List<ProbePosition> probePositions = new List<ProbePosition>(numberOfRadialSamples + 1);
|
||||
for (int i = 0; i < numberOfRadialSamples+1; i++)
|
||||
{
|
||||
probePositions[i] = new ProbePosition();
|
||||
probePositions.Add(new ProbePosition());
|
||||
}
|
||||
|
||||
printLevelWizard = new WizardControl();
|
||||
|
|
@ -217,9 +217,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
for (int i = 0; i < numberOfRadialSamples + 1; i++)
|
||||
{
|
||||
Vector2 probePosition = GetPrintLevelPositionToSample(i, bedRadius);
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probePosition, startProbeHeight), string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, lowPrecisionLabel), probePositions[i]));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, medPrecisionLabel), probePositions[i]));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, highPrecisionLabel), probePositions[i]));
|
||||
printLevelWizard.AddPage(new GetCoarseBedHeight(printLevelWizard, new Vector3(probePosition, startProbeHeight), string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, lowPrecisionLabel), probePositions, i));
|
||||
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, medPrecisionLabel), probePositions, i));
|
||||
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, highPrecisionLabel), probePositions, i));
|
||||
}
|
||||
|
||||
string doneInstructions = string.Format("{0}\n\n\t• {1}\n\n{2}", doneInstructionsText, doneInstructionsTextTwo, doneInstructionsTextThree);
|
||||
|
|
|
|||
|
|
@ -154,15 +154,17 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
private static LevelWizardBase CreateAndShowWizard(LevelWizardBase.RuningState runningState)
|
||||
{
|
||||
// turn off print leveling
|
||||
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling(false);
|
||||
// clear any data that we are going to be acquiring (sampled positions, after z home offset)
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPositions.Clear();
|
||||
ActiveSliceSettings.Instance.SetValue(SettingsKey.z_offset_after_home, 0.ToString());
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
|
||||
LevelWizardBase printLevelWizardWindow;
|
||||
switch (levelingData.CurrentPrinterLevelingSystem)
|
||||
{
|
||||
case PrintLevelingData.LevelingSystem.Probe2Points:
|
||||
printLevelWizardWindow = new LevelWizard2Point(runningState);
|
||||
break;
|
||||
|
||||
case PrintLevelingData.LevelingSystem.Probe3Points:
|
||||
printLevelWizardWindow = new LevelWizard3Point(runningState);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ using MatterHackers.MatterControl.PrinterCommunication;
|
|||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.VectorMath;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
|
|
@ -43,19 +44,16 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
: base(pageDescription, instructionsText)
|
||||
{
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling (false);
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
|
||||
public class LastPage3PointInstructions : InstructionsPage
|
||||
{
|
||||
private ProbePosition[] probePositions = new ProbePosition[3];
|
||||
private List<ProbePosition> probePositions = new List<ProbePosition>(3)
|
||||
{
|
||||
new ProbePosition(),new ProbePosition(),new ProbePosition()
|
||||
};
|
||||
|
||||
public LastPage3PointInstructions(string pageDescription, string instructionsText, ProbePosition[] probePositions)
|
||||
public LastPage3PointInstructions(string pageDescription, string instructionsText, List<ProbePosition> probePositions)
|
||||
: base(pageDescription, instructionsText)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
|
|
@ -66,9 +64,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
|
||||
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPosition0 = probePositions[0].position - paperWidth;
|
||||
levelingData.SampledPosition1 = probePositions[1].position - paperWidth;
|
||||
levelingData.SampledPosition2 = probePositions[2].position - paperWidth;
|
||||
levelingData.SampledPositions.Clear();
|
||||
levelingData.SampledPositions.Add(probePositions[0].position - paperWidth);
|
||||
levelingData.SampledPositions.Add(probePositions[1].position - paperWidth);
|
||||
levelingData.SampledPositions.Add(probePositions[2].position - paperWidth);
|
||||
|
||||
// Invoke setter forcing persistence of leveling data
|
||||
ActiveSliceSettings.Instance.Helpers.SetPrintLevelingData(levelingData);
|
||||
|
|
@ -81,9 +80,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public class LastPageRadialInstructions : InstructionsPage
|
||||
{
|
||||
private ProbePosition[] probePositions;
|
||||
private List<ProbePosition> probePositions;
|
||||
|
||||
public LastPageRadialInstructions(string pageDescription, string instructionsText, ProbePosition[] probePositions)
|
||||
public LastPageRadialInstructions(string pageDescription, string instructionsText, List<ProbePosition> probePositions)
|
||||
: base(pageDescription, instructionsText)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
|
|
@ -92,9 +91,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
public override void PageIsBecomingActive()
|
||||
{
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPositions.Clear();
|
||||
|
||||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
|
||||
for (int i = 0; i < probePositions.Length; i++)
|
||||
for (int i = 0; i < probePositions.Count; i++)
|
||||
{
|
||||
levelingData.SampledPositions.Add(probePositions[i].position - paperWidth);
|
||||
}
|
||||
|
|
@ -168,51 +167,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public class LastPage2PointInstructions : InstructionsPage
|
||||
{
|
||||
private ProbePosition[] probePositions = new ProbePosition[5];
|
||||
|
||||
public LastPage2PointInstructions(string pageDescription, string instructionsText, ProbePosition[] probePositions)
|
||||
: base(pageDescription, instructionsText)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// This data is currently the offset from the probe to the extruder tip. We need to translate them
|
||||
// into bed offsets and store them.
|
||||
|
||||
// The first point is the user assisted offset to the bed
|
||||
Vector3 userBedSample0 = probePositions[0].position;
|
||||
// The first point sample offset at the limit switch
|
||||
Vector3 probeOffset0 = probePositions[1].position; // this z should be 0
|
||||
|
||||
// right side of printer
|
||||
Vector3 userBedSample1 = probePositions[2].position;
|
||||
Vector3 probeOffset1 = probePositions[3].position;
|
||||
|
||||
// auto back probe
|
||||
Vector3 probeOffset2 = probePositions[4].position;
|
||||
|
||||
Vector3 paperWidth = new Vector3(0, 0, ActiveSliceSettings.Instance.GetValue<double>("manual_probe_paper_width"));
|
||||
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
levelingData.SampledPosition0 = userBedSample0 - paperWidth;
|
||||
levelingData.SampledPosition1 = userBedSample1 - paperWidth;
|
||||
levelingData.SampledPosition2 = probeOffset2 - probeOffset0 + userBedSample0 - paperWidth;
|
||||
|
||||
levelingData.ProbeOffset0 = probeOffset0 - paperWidth;
|
||||
levelingData.ProbeOffset1 = probeOffset1 - paperWidth;
|
||||
|
||||
// Invoke setter forcing persistence of leveling data
|
||||
ActiveSliceSettings.Instance.Helpers.SetPrintLevelingData(levelingData);
|
||||
|
||||
ActiveSliceSettings.Instance.Helpers.DoPrintLeveling ( true);
|
||||
base.PageIsBecomingActive();
|
||||
}
|
||||
}
|
||||
|
||||
public class HomePrinterPage : InstructionsPage
|
||||
{
|
||||
public HomePrinterPage(string pageDescription, string instructionsText)
|
||||
|
|
@ -230,18 +184,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
public class FindBedHeight : InstructionsPage
|
||||
{
|
||||
private Vector3 lastReportedPosition;
|
||||
private ProbePosition probePosition;
|
||||
private List<ProbePosition> probePositions;
|
||||
int probePositionsBeingEditedIndex;
|
||||
private double moveAmount;
|
||||
|
||||
protected JogControls.MoveButton zPlusControl;
|
||||
protected JogControls.MoveButton zMinusControl;
|
||||
|
||||
public FindBedHeight(string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance, ProbePosition whereToWriteProbePosition)
|
||||
public FindBedHeight(string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex)
|
||||
: base(pageDescription, setZHeightCoarseInstruction1)
|
||||
{
|
||||
this.probePositions = probePositions;
|
||||
this.moveAmount = moveDistance;
|
||||
this.lastReportedPosition = PrinterConnectionAndCommunication.Instance.LastReportedPosition;
|
||||
this.probePosition = whereToWriteProbePosition;
|
||||
this.probePositionsBeingEditedIndex = probePositionsBeingEditedIndex;
|
||||
|
||||
GuiWidget spacer = new GuiWidget(15, 15);
|
||||
topToBottomControls.AddChild(spacer);
|
||||
|
|
@ -283,7 +239,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public override void PageIsBecomingInactive()
|
||||
{
|
||||
probePosition.position = PrinterConnectionAndCommunication.Instance.LastReportedPosition;
|
||||
probePositions[probePositionsBeingEditedIndex].position = PrinterConnectionAndCommunication.Instance.LastReportedPosition;
|
||||
base.PageIsBecomingInactive();
|
||||
}
|
||||
|
||||
|
|
@ -304,10 +260,18 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
bool moveBelow0 = newPosition < 0;
|
||||
if (moveBelow0)
|
||||
{
|
||||
throw new NotImplementedException("If we are going to go below 0");
|
||||
// increment the z_offset_after_home
|
||||
double zOffset = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_offset_after_home);
|
||||
zOffset += 1;
|
||||
ActiveSliceSettings.Instance.SetValue(SettingsKey.z_offset_after_home, zOffset.ToString());
|
||||
// adjust all previously sampled points
|
||||
for(int i=0; i< probePositions.Count; i++)
|
||||
{
|
||||
probePositions[i].position = probePositions[i].position + new Vector3(0, 0, 1);
|
||||
}
|
||||
|
||||
// send a G92 z position to the printer to adjust the current z height
|
||||
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow($"G92 Z{PrinterConnectionAndCommunication.Instance.CurrentDestination.z + 1}");
|
||||
}
|
||||
|
||||
PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, -moveAmount, ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds().z);
|
||||
|
|
@ -335,8 +299,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
protected Vector3 probeStartPosition;
|
||||
protected WizardControl container;
|
||||
|
||||
public GetCoarseBedHeight(WizardControl container, Vector3 probeStartPosition, string pageDescription, ProbePosition whereToWriteProbePosition)
|
||||
: base(pageDescription, setZHeightCoarseInstruction1, setZHeightCoarseInstruction2, 1, whereToWriteProbePosition)
|
||||
public GetCoarseBedHeight(WizardControl container, Vector3 probeStartPosition, string pageDescription, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex)
|
||||
: base(pageDescription, setZHeightCoarseInstruction1, setZHeightCoarseInstruction2, 1, probePositions, probePositionsBeingEditedIndex)
|
||||
{
|
||||
this.container = container;
|
||||
this.probeStartPosition = probeStartPosition;
|
||||
|
|
@ -371,68 +335,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public class GetCoarseBedHeightProbeFirst : GetCoarseBedHeight
|
||||
{
|
||||
private event EventHandler unregisterEvents;
|
||||
|
||||
private ProbePosition whereToWriteSamplePosition;
|
||||
|
||||
public GetCoarseBedHeightProbeFirst(WizardControl container, Vector3 probeStartPosition, string pageDescription, ProbePosition whereToWriteProbePosition, ProbePosition whereToWriteSamplePosition, bool allowLessThan0)
|
||||
: base(container, probeStartPosition, pageDescription, whereToWriteProbePosition)
|
||||
{
|
||||
this.whereToWriteSamplePosition = whereToWriteSamplePosition;
|
||||
}
|
||||
|
||||
public override void PageIsBecomingActive()
|
||||
{
|
||||
// first make sure there is no leftover FinishedProbe event
|
||||
PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
var feedRates = ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds();
|
||||
|
||||
PrinterConnectionAndCommunication.Instance.MoveAbsolute(PrinterConnectionAndCommunication.Axis.Z, probeStartPosition.z, feedRates.z);
|
||||
PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, feedRates.x);
|
||||
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("G30");
|
||||
PrinterConnectionAndCommunication.Instance.ReadLine.RegisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
|
||||
base.PageIsBecomingActive();
|
||||
|
||||
container.nextButton.Enabled = false;
|
||||
|
||||
zPlusControl.Click += new EventHandler(zControl_Click);
|
||||
zMinusControl.Click += new EventHandler(zControl_Click);
|
||||
}
|
||||
|
||||
private void FinishedProbe(object sender, EventArgs e)
|
||||
{
|
||||
StringEventArgs currentEvent = e as StringEventArgs;
|
||||
if (currentEvent != null)
|
||||
{
|
||||
if (currentEvent.Data.Contains("endstops hit"))
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.ReadLine.UnregisterEvent(FinishedProbe, ref unregisterEvents);
|
||||
int zStringPos = currentEvent.Data.LastIndexOf("Z:");
|
||||
string zProbeHeight = currentEvent.Data.Substring(zStringPos + 2);
|
||||
// store the position that the limit swich fires
|
||||
whereToWriteSamplePosition.position = new Vector3(probeStartPosition.x, probeStartPosition.y, double.Parse(zProbeHeight));
|
||||
|
||||
// now move to the probe start position
|
||||
PrinterConnectionAndCommunication.Instance.MoveAbsolute(probeStartPosition, ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds().z);
|
||||
PrinterConnectionAndCommunication.Instance.ReadPosition();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
}
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
|
||||
public class GetFineBedHeight : FindBedHeight
|
||||
{
|
||||
private static string setZHeightFineInstruction1 = LocalizedString.Get("We will now refine our measurement of the extruder height at this position.");
|
||||
|
|
@ -441,8 +343,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
private static string setZHeightFineInstructionTextThree = LocalizedString.Get("Finally click 'Next' to continue.");
|
||||
private static string setZHeightFineInstruction2 = string.Format("\t• {0}\n\t• {1}\n\n{2}", setZHeightFineInstructionTextOne, setZHeightFineInstructionTextTwo, setZHeightFineInstructionTextThree);
|
||||
|
||||
public GetFineBedHeight(string pageDescription, ProbePosition whereToWriteProbePosition)
|
||||
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .1, whereToWriteProbePosition)
|
||||
public GetFineBedHeight(string pageDescription, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex)
|
||||
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .1, probePositions, probePositionsBeingEditedIndex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
@ -454,8 +356,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
private static string setHeightFineInstructionTextTwo = LocalizedString.Get("Finally click 'Next' to continue.");
|
||||
private static string setZHeightFineInstruction2 = string.Format("\t• {0}\n\n\n{1}", setHeightFineInstructionTextOne, setHeightFineInstructionTextTwo);
|
||||
|
||||
public GetUltraFineBedHeight(string pageDescription, ProbePosition whereToWriteProbePosition)
|
||||
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .02, whereToWriteProbePosition)
|
||||
public GetUltraFineBedHeight(string pageDescription, List<ProbePosition> probePositions, int probePositionsBeingEditedIndex)
|
||||
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .02, probePositions, probePositionsBeingEditedIndex)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,20 +12,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
private PrinterSettings printerProfile;
|
||||
|
||||
public List<Vector3> SampledPositions = new List<Vector3>();
|
||||
|
||||
private Vector3 probeOffset0Private;
|
||||
|
||||
private Vector3 probeOffset1Private;
|
||||
|
||||
private Vector3 sampledPosition0Private;
|
||||
|
||||
private Vector3 sampledPosition1Private;
|
||||
|
||||
private Vector3 sampledPosition2Private;
|
||||
public List<Vector3> SampledPositions = new List<Vector3>()
|
||||
{
|
||||
new Vector3(),new Vector3(),new Vector3()
|
||||
};
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum LevelingSystem { Probe3Points, Probe2Points, Probe7PointRadial, Probe13PointRadial }
|
||||
public enum LevelingSystem { Probe3Points, Probe7PointRadial, Probe13PointRadial }
|
||||
|
||||
public PrintLevelingData(PrinterSettings printerProfile)
|
||||
{
|
||||
|
|
@ -38,9 +31,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
switch (printerProfile.GetValue("print_leveling_solution"))
|
||||
{
|
||||
case "2 Point Plane":
|
||||
return LevelingSystem.Probe2Points;
|
||||
|
||||
case "7 Point Disk":
|
||||
return LevelingSystem.Probe7PointRadial;
|
||||
|
||||
|
|
@ -54,66 +44,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public Vector3 ProbeOffset0
|
||||
{
|
||||
get { return probeOffset0Private; }
|
||||
set
|
||||
{
|
||||
if (probeOffset0Private != value)
|
||||
{
|
||||
probeOffset0Private = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 ProbeOffset1
|
||||
{
|
||||
get { return probeOffset1Private; }
|
||||
set
|
||||
{
|
||||
if (probeOffset1Private != value)
|
||||
{
|
||||
probeOffset1Private = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 SampledPosition0
|
||||
{
|
||||
get { return sampledPosition0Private; }
|
||||
set
|
||||
{
|
||||
if (sampledPosition0Private != value)
|
||||
{
|
||||
sampledPosition0Private = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 SampledPosition1
|
||||
{
|
||||
get { return sampledPosition1Private; }
|
||||
set
|
||||
{
|
||||
if (sampledPosition1Private != value)
|
||||
{
|
||||
sampledPosition1Private = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Vector3 SampledPosition2
|
||||
{
|
||||
get { return sampledPosition2Private; }
|
||||
set
|
||||
{
|
||||
if (sampledPosition2Private != value)
|
||||
{
|
||||
sampledPosition2Private = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static PrintLevelingData Create(PrinterSettings printerProfile, string jsonData, string depricatedPositionsCsv3ByXYZ)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(jsonData))
|
||||
|
|
@ -146,6 +76,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
/// <returns></returns>
|
||||
private void ParseDepricatedPrintLevelingMeasuredPositions(string depricatedPositionsCsv3ByXYZ)
|
||||
{
|
||||
SampledPositions = new List<Vector3>(3);
|
||||
|
||||
if (depricatedPositionsCsv3ByXYZ != null)
|
||||
{
|
||||
string[] lines = depricatedPositionsCsv3ByXYZ.Split(',');
|
||||
|
|
@ -153,9 +85,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
sampledPosition0Private[i] = double.Parse(lines[0 * 3 + i]);
|
||||
sampledPosition1Private[i] = double.Parse(lines[1 * 3 + i]);
|
||||
sampledPosition2Private[i] = double.Parse(lines[2 * 3 + i]);
|
||||
Vector3 position = new Vector3();
|
||||
|
||||
position.x = double.Parse(lines[0 * 3 + i]);
|
||||
position.y = double.Parse(lines[1 * 3 + i]);
|
||||
position.z = double.Parse(lines[2 * 3 + i]);
|
||||
|
||||
SampledPositions.Add(position);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -170,11 +106,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
switch (CurrentPrinterLevelingSystem)
|
||||
{
|
||||
case PrintLevelingData.LevelingSystem.Probe2Points:
|
||||
case PrintLevelingData.LevelingSystem.Probe3Points:
|
||||
if (SampledPosition0.z == 0
|
||||
&& SampledPosition1.z == 0
|
||||
&& SampledPosition2.z == 0)
|
||||
if (SampledPositions.Count != 3) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ namespace MatterHackers.MatterControl
|
|||
{
|
||||
GCodeFile loadedGCode = GCodeFile.Load(gcodeFilename);
|
||||
GCodeFileStream gCodeFileStream0 = new GCodeFileStream(loadedGCode);
|
||||
PrintLevelingStream printLevelingStream4 = new PrintLevelingStream(gCodeFileStream0);
|
||||
PrintLevelingStream printLevelingStream4 = new PrintLevelingStream(gCodeFileStream0, false);
|
||||
// this is added to ensure we are rewriting the G0 G1 commands as needed
|
||||
FeedRateMultiplyerStream extrusionMultiplyerStream = new FeedRateMultiplyerStream(printLevelingStream4);
|
||||
|
||||
|
|
|
|||
|
|
@ -148,7 +148,6 @@
|
|||
<Compile Include="ConfigurationPage\LanguageSelector.cs" />
|
||||
<Compile Include="ConfigurationPage\CalibrationSettings\CalibrationSettingsView.cs" />
|
||||
<Compile Include="ConfigurationPage\PrinterSettings\PrinterSettingsView.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizard2Point.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\InstructionsPage.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizard7PointRadial.cs" />
|
||||
<Compile Include="ConfigurationPage\PrintLeveling\LevelWizard13PointRadial.cs" />
|
||||
|
|
|
|||
|
|
@ -38,18 +38,18 @@ using MatterHackers.MatterControl.SlicerConfiguration;
|
|||
|
||||
namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
||||
{
|
||||
public abstract class GCodeStream : IDisposable
|
||||
{
|
||||
#region Abstract Functions
|
||||
/// <summary>
|
||||
/// returns null when there are no more lines
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract string ReadLine();
|
||||
public abstract void SetPrinterPosition(PrinterMove position);
|
||||
#endregion
|
||||
public abstract class GCodeStream : IDisposable
|
||||
{
|
||||
#region Abstract Functions
|
||||
/// <summary>
|
||||
/// returns null when there are no more lines
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public abstract string ReadLine();
|
||||
public abstract void SetPrinterPosition(PrinterMove position);
|
||||
#endregion
|
||||
|
||||
public abstract void Dispose();
|
||||
public abstract void Dispose();
|
||||
|
||||
bool useG0ForMovement = false;
|
||||
|
||||
|
|
@ -59,14 +59,14 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
}
|
||||
|
||||
public string CreateMovementLine(PrinterMove currentDestination)
|
||||
{
|
||||
return CreateMovementLine(currentDestination, PrinterMove.Nowhere);
|
||||
}
|
||||
{
|
||||
return CreateMovementLine(currentDestination, PrinterMove.Nowhere);
|
||||
}
|
||||
|
||||
public string CreateMovementLine(PrinterMove destination, PrinterMove start)
|
||||
{
|
||||
string lineBeingSent;
|
||||
StringBuilder newLine = new StringBuilder("G1 ");
|
||||
public string CreateMovementLine(PrinterMove destination, PrinterMove start)
|
||||
{
|
||||
string lineBeingSent;
|
||||
StringBuilder newLine = new StringBuilder("G1 ");
|
||||
|
||||
bool moveHasExtrusion = destination.extrusion != start.extrusion;
|
||||
if (useG0ForMovement && !moveHasExtrusion)
|
||||
|
|
@ -87,40 +87,55 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
newLine = newLine.Append(String.Format("Z{0:0.###} ", destination.position.z));
|
||||
}
|
||||
|
||||
if (moveHasExtrusion)
|
||||
{
|
||||
newLine = newLine.Append(String.Format("E{0:0.###} ", destination.extrusion));
|
||||
}
|
||||
if (moveHasExtrusion)
|
||||
{
|
||||
newLine = newLine.Append(String.Format("E{0:0.###} ", destination.extrusion));
|
||||
}
|
||||
|
||||
if (destination.feedRate != start.feedRate)
|
||||
{
|
||||
newLine = newLine.Append(String.Format("F{0:0.##}", destination.feedRate));
|
||||
}
|
||||
if (destination.feedRate != start.feedRate)
|
||||
{
|
||||
newLine = newLine.Append(String.Format("F{0:0.##}", destination.feedRate));
|
||||
}
|
||||
|
||||
lineBeingSent = newLine.ToString();
|
||||
return lineBeingSent.Trim();
|
||||
}
|
||||
lineBeingSent = newLine.ToString();
|
||||
return lineBeingSent.Trim();
|
||||
}
|
||||
|
||||
public static PrinterMove GetPosition(string lineBeingSent, PrinterMove startPositionPosition)
|
||||
{
|
||||
PrinterMove currentDestination = startPositionPosition;
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref currentDestination.position.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref currentDestination.position.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref currentDestination.position.z);
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref currentDestination.extrusion);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref currentDestination.feedRate);
|
||||
return currentDestination;
|
||||
}
|
||||
public static PrinterMove GetPosition(string lineBeingSent, PrinterMove startPositionPosition)
|
||||
{
|
||||
PrinterMove currentDestination = startPositionPosition;
|
||||
GCodeFile.GetFirstNumberAfter("X", lineBeingSent, ref currentDestination.position.x);
|
||||
GCodeFile.GetFirstNumberAfter("Y", lineBeingSent, ref currentDestination.position.y);
|
||||
GCodeFile.GetFirstNumberAfter("Z", lineBeingSent, ref currentDestination.position.z);
|
||||
GCodeFile.GetFirstNumberAfter("E", lineBeingSent, ref currentDestination.extrusion);
|
||||
GCodeFile.GetFirstNumberAfter("F", lineBeingSent, ref currentDestination.feedRate);
|
||||
return currentDestination;
|
||||
}
|
||||
|
||||
public static bool LineIsMovement(string lineBeingSent)
|
||||
{
|
||||
if (lineBeingSent.StartsWith("G0 ")
|
||||
|| lineBeingSent.StartsWith("G1 "))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public static bool LineIsZHoming(string lineBeingSent)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(lineBeingSent))
|
||||
{
|
||||
bool isAZHome = lineBeingSent.StartsWith("G28") && lineBeingSent.Contains("Z");
|
||||
bool isANakedHome = lineBeingSent.Trim() == "G28";
|
||||
if (isAZHome || isANakedHome)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static bool LineIsMovement(string lineBeingSent)
|
||||
{
|
||||
if (lineBeingSent.StartsWith("G0 ")
|
||||
|| lineBeingSent.StartsWith("G1 "))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,17 +40,42 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
{
|
||||
public class PrintLevelingStream : GCodeStreamProxy
|
||||
{
|
||||
bool activePrinting;
|
||||
bool hadZHome = false;
|
||||
protected PrinterMove lastDestination = new PrinterMove();
|
||||
public PrintLevelingStream(GCodeStream internalStream)
|
||||
public PrintLevelingStream(GCodeStream internalStream, bool activePrinting)
|
||||
: base(internalStream)
|
||||
{
|
||||
this.activePrinting = activePrinting;
|
||||
}
|
||||
|
||||
public PrinterMove LastDestination { get { return lastDestination; } }
|
||||
public override string ReadLine()
|
||||
{
|
||||
if (hadZHome)
|
||||
{
|
||||
hadZHome = false;
|
||||
// only add this when exporting to gcode
|
||||
if (!activePrinting)
|
||||
{
|
||||
// return the correct G92
|
||||
double zOffset = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_offset_after_home);
|
||||
if (zOffset != 0)
|
||||
{
|
||||
double newHomePosition = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.printer_z_after_home) + zOffset;
|
||||
return $"G92 Z{newHomePosition}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string lineFromChild = base.ReadLine();
|
||||
|
||||
if (lineFromChild != null
|
||||
&& LineIsZHoming(lineFromChild))
|
||||
{
|
||||
hadZHome = true;
|
||||
}
|
||||
|
||||
if (lineFromChild != null
|
||||
&& PrinterConnectionAndCommunication.Instance.ActivePrinter.GetValue<bool>(SettingsKey.print_leveling_enabled))
|
||||
{
|
||||
|
|
@ -96,10 +121,6 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
|
|||
{
|
||||
switch (levelingData.CurrentPrinterLevelingSystem)
|
||||
{
|
||||
case PrintLevelingData.LevelingSystem.Probe2Points:
|
||||
lineBeingSent = LevelWizard2Point.ApplyLeveling(lineBeingSent, currentDestination.position, PrinterMachineInstruction.MovementTypes.Absolute);
|
||||
break;
|
||||
|
||||
case PrintLevelingData.LevelingSystem.Probe3Points:
|
||||
lineBeingSent = LevelWizard3Point.ApplyLeveling(lineBeingSent, currentDestination.position, PrinterMachineInstruction.MovementTypes.Absolute);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -1836,6 +1836,26 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
waitingForPosition.Stop();
|
||||
waitingForPosition.Reset();
|
||||
|
||||
if(storePositionToPrinterZAfterHome)
|
||||
{
|
||||
storePositionToPrinterZAfterHome = false;
|
||||
double storedHomePosition = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.printer_z_after_home);
|
||||
// if printer_z_after_home != current z position
|
||||
if (storedHomePosition != LastReportedPosition.z)
|
||||
{
|
||||
ActiveSliceSettings.Instance.SetValue(SettingsKey.printer_z_after_home, LastReportedPosition.z.ToString());
|
||||
ApplicationController.Instance.ReloadAdvancedControlsPanel();
|
||||
}
|
||||
|
||||
// now send a G92 to set the position that we want to think is home
|
||||
double zOffset = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.z_offset_after_home);
|
||||
if (zOffset != 0)
|
||||
{
|
||||
double newHomePosition = ActiveSliceSettings.Instance.GetValue<double>(SettingsKey.printer_z_after_home) + zOffset;
|
||||
SendLineToPrinterNow($"G92 Z{newHomePosition}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ReadTemperatures(object sender, EventArgs e)
|
||||
|
|
@ -2499,7 +2519,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
queuedCommandStream2 = new QueuedCommandsStream(pauseHandlingStream1);
|
||||
relativeToAbsoluteStream3 = new RelativeToAbsoluteStream(queuedCommandStream2);
|
||||
printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3);
|
||||
printLevelingStream4 = new PrintLevelingStream(relativeToAbsoluteStream3, true);
|
||||
waitForTempStream5 = new WaitForTempStream(printLevelingStream4);
|
||||
babyStepsStream6 = new BabyStepsStream(waitForTempStream5);
|
||||
if(activePrintTask != null)
|
||||
|
|
@ -2912,12 +2932,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
{
|
||||
SendLineToPrinterNow("M114");
|
||||
|
||||
// create a stream processor that does this so it can be applied to exported GCode
|
||||
// check if this is a naked G28 or a G28 Z command
|
||||
// if printer_z_after_home != current z position
|
||||
throw new NotImplementedException("Check and write printer_z_after_home");
|
||||
// if z_offset_after_home > 0
|
||||
// send a G92 with the printer_z_after_home + z_offset_after_home
|
||||
if (GCodeStream.LineIsZHoming(lineWithoutChecksum))
|
||||
{
|
||||
storePositionToPrinterZAfterHome = true;
|
||||
}
|
||||
}
|
||||
|
||||
// write data to communication
|
||||
|
|
@ -2995,6 +3013,7 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
|
||||
bool haveHookedDrawing = false;
|
||||
private bool storePositionToPrinterZAfterHome = false;
|
||||
|
||||
public class ReadThread
|
||||
{
|
||||
|
|
|
|||
|
|
@ -90,18 +90,9 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
// put in the movement edit controls
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
if (EditSamplePositionList(levelingData))
|
||||
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
||||
{
|
||||
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
||||
{
|
||||
positions.Add(levelingData.SampledPositions[i]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
positions.Add(levelingData.SampledPosition0);
|
||||
positions.Add(levelingData.SampledPosition1);
|
||||
positions.Add(levelingData.SampledPosition2);
|
||||
positions.Add(levelingData.SampledPositions[i]);
|
||||
}
|
||||
|
||||
int tab_index = 0;
|
||||
|
|
@ -184,33 +175,13 @@ namespace MatterHackers.MatterControl
|
|||
UiThread.RunOnIdle(DoSave_Click);
|
||||
}
|
||||
|
||||
bool EditSamplePositionList(PrintLevelingData levelingData)
|
||||
{
|
||||
if (levelingData.CurrentPrinterLevelingSystem == PrintLevelingData.LevelingSystem.Probe7PointRadial
|
||||
|| levelingData.CurrentPrinterLevelingSystem == PrintLevelingData.LevelingSystem.Probe13PointRadial)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoSave_Click()
|
||||
{
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
|
||||
if (EditSamplePositionList(levelingData))
|
||||
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
||||
{
|
||||
for (int i = 0; i < levelingData.SampledPositions.Count; i++)
|
||||
{
|
||||
levelingData.SampledPositions[i] = positions[i];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
levelingData.SampledPosition0 = positions[0];
|
||||
levelingData.SampledPosition1 = positions[1];
|
||||
levelingData.SampledPosition2 = positions[2];
|
||||
levelingData.SampledPositions[i] = positions[i];
|
||||
}
|
||||
|
||||
ActiveSliceSettings.Instance.Helpers.SetPrintLevelingData(levelingData);
|
||||
|
|
|
|||
|
|
@ -202,10 +202,6 @@ namespace MatterHackers.MatterControl.PrintQueue
|
|||
|
||||
switch (levelingData.CurrentPrinterLevelingSystem)
|
||||
{
|
||||
case PrintLevelingData.LevelingSystem.Probe2Points:
|
||||
instruction.Line = LevelWizard2Point.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType);
|
||||
break;
|
||||
|
||||
case PrintLevelingData.LevelingSystem.Probe3Points:
|
||||
instruction.Line = LevelWizard3Point.ApplyLeveling(instruction.Line, currentDestination, instruction.movementType);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -258,11 +258,14 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
printerSettings.GetValue(SettingsKey.print_leveling_data),
|
||||
printerSettings.GetValue("MatterControl.PrintLevelingProbePositions"));
|
||||
|
||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
||||
printLevelingData.SampledPosition0,
|
||||
printLevelingData.SampledPosition1,
|
||||
printLevelingData.SampledPosition2,
|
||||
ActiveSliceSettings.Instance.GetValue<Vector2>(SettingsKey.print_center));
|
||||
if (printLevelingData.SampledPositions.Count == 3)
|
||||
{
|
||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
||||
printLevelingData.SampledPositions[0],
|
||||
printLevelingData.SampledPositions[1],
|
||||
printLevelingData.SampledPositions[2],
|
||||
ActiveSliceSettings.Instance.GetValue<Vector2>(SettingsKey.print_center));
|
||||
}
|
||||
}
|
||||
|
||||
return printLevelingData;
|
||||
|
|
@ -290,9 +293,9 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
{
|
||||
PrintLevelingData levelingData = ActiveSliceSettings.Instance.Helpers.GetPrintLevelingData();
|
||||
PrintLevelingPlane.Instance.SetPrintLevelingEquation(
|
||||
levelingData.SampledPosition0,
|
||||
levelingData.SampledPosition1,
|
||||
levelingData.SampledPosition2,
|
||||
levelingData.SampledPositions[0],
|
||||
levelingData.SampledPositions[1],
|
||||
levelingData.SampledPositions[2],
|
||||
ActiveSliceSettings.Instance.GetValue<Vector2>(SettingsKey.print_center));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2533,7 +2533,7 @@
|
|||
"HelpText": "This is automatically set by MatterControl. You do not need to adjust it.",
|
||||
"DataEditType": "POSITIVE_DOUBLE",
|
||||
"ExtraSettings": "mm",
|
||||
"ShowAsOverride": true,
|
||||
"ShowAsOverride": false,
|
||||
"ShowIfSet": null,
|
||||
"ResetAtEndOfPrint": false,
|
||||
"DefaultValue": "0",
|
||||
|
|
@ -2547,7 +2547,7 @@
|
|||
"HelpText": "The amount to change the printers home position after a z home has occured. This is used by print leveling and recovery. This should not be manualy edited.",
|
||||
"DataEditType": "POSITIVE_DOUBLE",
|
||||
"ExtraSettings": "mm",
|
||||
"ShowAsOverride": true,
|
||||
"ShowAsOverride": false,
|
||||
"ShowIfSet": null,
|
||||
"ResetAtEndOfPrint": false,
|
||||
"DefaultValue": "0",
|
||||
|
|
|
|||
|
|
@ -5521,3 +5521,6 @@ Translated:Leveling Calibration
|
|||
English:It's time to copy your existing printer settings to your MatterHackers account. Once copied, these printers will be available whenever you sign in to MatterControl. Printers that are not copied will only be available when not signed in.
|
||||
Translated:It's time to copy your existing printer settings to your MatterHackers account. Once copied, these printers will be available whenever you sign in to MatterControl. Printers that are not copied will only be available when not signed in.
|
||||
|
||||
English:Location: 'Settings & Controls' -> 'Settings' -> 'Printer' -> 'Custom G-Code' -> 'Start G-Code'
|
||||
Translated:Location: 'Settings & Controls' -> 'Settings' -> 'Printer' -> 'Custom G-Code' -> 'Start G-Code'
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue