Put in temp that leveling occurred at
Put in date Made rebuild data happen correctly Improved leveling messages Fixed a bug with leveling happening after line cutting Added 5x5 leveling
This commit is contained in:
parent
34970a6462
commit
3f8f0cbe28
14 changed files with 283 additions and 81 deletions
|
|
@ -46,13 +46,17 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public override IEnumerable<Vector2> GetPrintLevelPositionToSample()
|
||||
{
|
||||
for(int y=0; y<3; y++)
|
||||
{
|
||||
for(int x=0; x<3; x++)
|
||||
{
|
||||
yield return GetPosition(x, y);
|
||||
}
|
||||
}
|
||||
yield return GetPosition(0, 0);
|
||||
yield return GetPosition(1, 0);
|
||||
yield return GetPosition(2, 0);
|
||||
|
||||
yield return GetPosition(2, 1);
|
||||
yield return GetPosition(1, 1);
|
||||
yield return GetPosition(0, 1);
|
||||
|
||||
yield return GetPosition(0, 2);
|
||||
yield return GetPosition(1, 2);
|
||||
yield return GetPosition(2, 2);
|
||||
}
|
||||
|
||||
private Vector2 GetPosition(int xIndex, int yIndex)
|
||||
|
|
|
|||
147
ConfigurationPage/PrintLeveling/LevelWizard5x5Mesh.cs
Normal file
147
ConfigurationPage/PrintLeveling/LevelWizard5x5Mesh.cs
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
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;
|
||||
using System.Collections.Generic;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using MatterHackers.MeshVisualizer;
|
||||
using MatterHackers.VectorMath;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class LevelWizard5x5Mesh : LevelWizardBase
|
||||
{
|
||||
public LevelWizard5x5Mesh(PrinterConfig printer, LevelWizardBase.RuningState runningState)
|
||||
: base(printer, runningState)
|
||||
{
|
||||
}
|
||||
|
||||
public override int ProbeCount => 25;
|
||||
|
||||
public override IEnumerable<Vector2> GetPrintLevelPositionToSample()
|
||||
{
|
||||
yield return GetPosition(0, 0);
|
||||
yield return GetPosition(1, 0);
|
||||
yield return GetPosition(2, 0);
|
||||
yield return GetPosition(3, 0);
|
||||
yield return GetPosition(4, 0);
|
||||
|
||||
yield return GetPosition(4, 1);
|
||||
yield return GetPosition(3, 1);
|
||||
yield return GetPosition(2, 1);
|
||||
yield return GetPosition(1, 1);
|
||||
yield return GetPosition(0, 1);
|
||||
|
||||
yield return GetPosition(0, 2);
|
||||
yield return GetPosition(1, 2);
|
||||
yield return GetPosition(2, 2);
|
||||
yield return GetPosition(3, 2);
|
||||
yield return GetPosition(4, 2);
|
||||
|
||||
yield return GetPosition(4, 3);
|
||||
yield return GetPosition(3, 3);
|
||||
yield return GetPosition(2, 3);
|
||||
yield return GetPosition(1, 3);
|
||||
yield return GetPosition(0, 3);
|
||||
|
||||
yield return GetPosition(0, 4);
|
||||
yield return GetPosition(1, 4);
|
||||
yield return GetPosition(2, 4);
|
||||
yield return GetPosition(3, 4);
|
||||
yield return GetPosition(4, 4);
|
||||
}
|
||||
|
||||
private Vector2 GetPosition(int xIndex, int yIndex)
|
||||
{
|
||||
Vector2 bedSize = printer.Settings.GetValue<Vector2>(SettingsKey.bed_size);
|
||||
Vector2 printCenter = printer.Settings.GetValue<Vector2>(SettingsKey.print_center);
|
||||
|
||||
if (printer.Settings.GetValue<BedShape>(SettingsKey.bed_shape) == BedShape.Circular)
|
||||
{
|
||||
// reduce the bed size by the ratio of the radius (square root of 2) so that the sample positions will fit on a ciclular bed
|
||||
bedSize *= 1.0 / Math.Sqrt(2);
|
||||
}
|
||||
|
||||
Vector2 samplePosition = new Vector2();
|
||||
switch (xIndex)
|
||||
{
|
||||
case 0:
|
||||
samplePosition.X = printCenter.X - (bedSize.X / 2) * .8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
samplePosition.X = printCenter.X - (bedSize.X / 2) * .4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
samplePosition.X = printCenter.X;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
samplePosition.X = printCenter.X + (bedSize.X / 2) * .4;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
samplePosition.X = printCenter.X + (bedSize.X / 2) * .8;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
|
||||
switch (yIndex)
|
||||
{
|
||||
case 0:
|
||||
samplePosition.Y = printCenter.Y - (bedSize.Y / 2) * .8;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
samplePosition.Y = printCenter.Y - (bedSize.Y / 2) * .4;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
samplePosition.Y = printCenter.Y;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
samplePosition.Y = printCenter.Y + (bedSize.Y / 2) * .4;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
samplePosition.Y = printCenter.Y + (bedSize.Y / 2) * .8;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new IndexOutOfRangeException();
|
||||
}
|
||||
|
||||
return samplePosition;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -99,8 +99,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
printLevelWizard.AddPage(new HomePrinterPage(printer, printLevelWizard,
|
||||
levelingStrings.HomingPageStepText,
|
||||
levelingStrings.HomingPageInstructions(useZProbe),
|
||||
levelingStrings.HomingPageInstructions(useZProbe, hasHeatedBed),
|
||||
useZProbe));
|
||||
|
||||
if (hasHeatedBed)
|
||||
{
|
||||
printLevelWizard.AddPage(new WaitForTempPage(printer, printLevelWizard, levelingStrings));
|
||||
|
|
@ -219,6 +220,10 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
printLevelWizardWindow = new LevelWizard3x3Mesh(printer, runningState);
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe5x5Mesh:
|
||||
printLevelWizardWindow = new LevelWizard5x5Mesh(printer, runningState);
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,13 +41,13 @@ using MIConvexHull;
|
|||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
public class MeshLevlingFunctions : IDisposable
|
||||
public class LevelingFunctions : IDisposable
|
||||
{
|
||||
private Vector3 lastDestinationWithLevelingApplied = new Vector3();
|
||||
|
||||
PrinterSettings printerSettings;
|
||||
|
||||
public MeshLevlingFunctions(PrinterSettings printerSettings, int gridWidth, int gridHeight, PrintLevelingData levelingData)
|
||||
public LevelingFunctions(PrinterSettings printerSettings, PrintLevelingData levelingData)
|
||||
{
|
||||
this.printerSettings = printerSettings;
|
||||
this.SampledPositions = new List<Vector3>(levelingData.SampledPositions);
|
||||
|
|
@ -47,17 +47,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
private string doneLine2 = "Remove the paper".Localize();
|
||||
private string doneLine3 = "If you need to recalibrate the printer in the future, the print leveling controls can be found under: Controls, Calibration";
|
||||
private string doneLine3b = "Click 'Done' to close this window.".Localize();
|
||||
private string homingLine1 = "The printer should now be 'homing'. Once it is finished homing we will heat the bed.";
|
||||
private string homingLine1b = "To complete the next few steps you will need".Localize();
|
||||
private string homingLine2 = "A standard sheet of paper".Localize();
|
||||
private string homingLine3 = "We will use this paper to measure the distance between the extruder and the bed.";
|
||||
private int stepNumber = 1;
|
||||
private string welcomeLine1 = "Welcome to the print leveling wizard. Here is a quick overview on what we are going to do.".Localize();
|
||||
private string selectMaterial = "Select the material you are printing".Localize();
|
||||
private string heatTheBed = "Heat the bed".Localize();
|
||||
private string sampelAtPoints = "Sample the bed at {0} points".Localize();
|
||||
private string turnOnLeveling = "Turn auto leveling on".Localize();
|
||||
private string timeToDone = "We should be done in less than {0} minutes.".Localize();
|
||||
private string timeToDone = "We should be done in approximately {0} minutes.".Localize();
|
||||
public string CleanExtruder => "Be sure the tip of the extruder is clean and the bed is clear.".Localize();
|
||||
public string ClickNext => "Click 'Next' to continue.".Localize();
|
||||
|
||||
|
|
@ -100,15 +96,23 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
public string HomingPageInstructions(bool useZProbe)
|
||||
public string HomingPageInstructions(bool useZProbe, bool heatBed)
|
||||
{
|
||||
string line1 = "The printer should now be 'homing'.".Localize();
|
||||
if (heatBed)
|
||||
{
|
||||
line1 += " " + "Once it is finished homing we will heat the bed.".Localize();
|
||||
}
|
||||
if (useZProbe)
|
||||
{
|
||||
return homingLine1;
|
||||
return line1;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "{0}\n\n{1}:\n\n\t• {2}\n\n{3}\n\n{4}".FormatWith(homingLine1, homingLine1b, homingLine2, homingLine3, ClickNext);
|
||||
string line2 = "To complete the next few steps you will need".Localize();
|
||||
string line3 = "A standard sheet of paper".Localize();
|
||||
string line4 = "We will use this paper to measure the distance between the extruder and the bed.".Localize();
|
||||
return $"{line1}\n\n{line2}:\n\n\t• {line3}\n\n{line4}\n\n{ClickNext}";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -144,11 +148,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public string WelcomeText(int numberOfSteps, int numberOfMinutes)
|
||||
{
|
||||
if (printerSettings.Helpers.UseZProbe())
|
||||
{
|
||||
numberOfMinutes = 2;
|
||||
}
|
||||
|
||||
if (printerSettings.GetValue<bool>(SettingsKey.has_heated_bed))
|
||||
{
|
||||
return "{0}\n\n\t• {1}\n\t• {2}\n\t• {3}\n\t• {4}\n\t• {5}\n\n{6}\n\n{7}".FormatWith(
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
progressBarText.Text = $"Temperature: {actualTemp:0} / {targetTemp:0}";
|
||||
|
||||
// if we are within 1 degree of our target
|
||||
if (Math.Abs(targetTemp - actualTemp) < 1
|
||||
if (Math.Abs(targetTemp - actualTemp) < 2
|
||||
&& doneText.Visible == false)
|
||||
{
|
||||
doneText.Visible = true;
|
||||
|
|
@ -217,6 +217,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
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.AlowLeveling = true;
|
||||
|
|
|
|||
|
|
@ -10,13 +10,16 @@ using System.Linq;
|
|||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum LevelingSystem { Probe3Points, Probe7PointRadial, Probe13PointRadial, Probe3x3Mesh }
|
||||
public enum LevelingSystem { Probe3Points, Probe7PointRadial, Probe13PointRadial, Probe3x3Mesh, Probe5x5Mesh }
|
||||
|
||||
public class PrintLevelingData
|
||||
{
|
||||
#region JSON data
|
||||
public List<Vector3> SampledPositions = new List<Vector3>();
|
||||
|
||||
public LevelingSystem LevelingSystem;
|
||||
public DateTime CreationData;
|
||||
public double BedTemperature;
|
||||
#endregion
|
||||
|
||||
public PrintLevelingData()
|
||||
{
|
||||
|
|
@ -24,11 +27,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
public bool HasBeenRunAndEnabled(PrinterConfig printer)
|
||||
{
|
||||
// check if leveling is turned on
|
||||
if(!ActiveSliceSettings.Instance.GetValue<bool>(SettingsKey.print_leveling_enabled))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that there are no duplicate points
|
||||
var positionCounts = from x in SampledPositions
|
||||
group x by x into g
|
||||
let count = g.Count()
|
||||
|
|
@ -43,11 +48,25 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
}
|
||||
|
||||
// check that the solution last measured is the currently selected solution
|
||||
if(printer.Settings.GetValue<LevelingSystem>(SettingsKey.print_leveling_solution) != LevelingSystem)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// check that the bed temperature at probe time was close enough to the current print bed temp
|
||||
double reqiredLevlingTemp = printer.Settings.GetValue<bool>(SettingsKey.has_heated_bed) ?
|
||||
printer.Settings.GetValue<double>(SettingsKey.bed_temperature)
|
||||
: 0;
|
||||
|
||||
// check that it is within 10 degrees
|
||||
if(Math.Abs(reqiredLevlingTemp - BedTemperature) > 10)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// check that the number of poins sampled is correct for the solution
|
||||
switch (LevelingSystem)
|
||||
{
|
||||
case LevelingSystem.Probe3Points:
|
||||
|
|
@ -78,6 +97,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
break;
|
||||
|
||||
case LevelingSystem.Probe5x5Mesh:
|
||||
if (SampledPositions.Count != 25) // different criteria for what is not initialized
|
||||
{
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
bool useZProbe = printer.Settings.Helpers.UseZProbe();
|
||||
printLevelWizard.AddPage(new HomePrinterPage(printer, printLevelWizard,
|
||||
levelingStrings.HomingPageStepText,
|
||||
levelingStrings.HomingPageInstructions(useZProbe),
|
||||
levelingStrings.HomingPageInstructions(useZProbe, false),
|
||||
false));
|
||||
|
||||
string lowPrecisionLabel = "Low Precision".Localize();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue