From f8f130eec35b63ec379aa9a76f9969281f6044bb Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 14 Mar 2019 14:34:25 -0700 Subject: [PATCH 1/5] Use calculated E value --- MatterControlLib/CustomWidgets/GCodeSketch.cs | 32 +++++++++++++++++-- .../NozzleOffsetCalibrationPage.cs | 4 +-- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/MatterControlLib/CustomWidgets/GCodeSketch.cs b/MatterControlLib/CustomWidgets/GCodeSketch.cs index 15bea9516..190ca9f57 100644 --- a/MatterControlLib/CustomWidgets/GCodeSketch.cs +++ b/MatterControlLib/CustomWidgets/GCodeSketch.cs @@ -32,6 +32,7 @@ using System.IO; using System.Text; using MatterHackers.Agg; using MatterHackers.Agg.Transform; +using MatterHackers.MatterControl.SlicerConfiguration; using MatterHackers.VectorMath; namespace MatterHackers.MatterControl @@ -43,16 +44,23 @@ namespace MatterHackers.MatterControl { private StringBuilder sb; private StringWriter writer; + private PrinterConfig printer; + private double nozzleDiameter; + private double filamentDiameterMm; private double currentE = 0; private bool retracted = false; private bool penUp = false; private double currentSpeed = 0; private double layerHeight = 0.2; - public GCodeSketch() + public GCodeSketch(PrinterConfig printer) { sb = new StringBuilder(); writer = new StringWriter(sb); + + this.printer = printer; + nozzleDiameter = printer.Settings.GetValue(SettingsKey.nozzle_diameter); + filamentDiameterMm = printer.Settings.GetValue(SettingsKey.filament_diameter); } public double RetractLength { get; set; } = 1.2; @@ -157,6 +165,26 @@ namespace MatterHackers.MatterControl } } + public static double ExtrudeAmount(PrinterConfig printer, double widthMm, double heightMm, double lengthMm) + { + var filamentDiameterMm = printer.Settings.GetValue(SettingsKey.filament_diameter); + + var volumeMm3 = widthMm * heightMm * lengthMm; + var areaMm2 = Math.PI * Math.Pow(filamentDiameterMm / 2, 2); + var filamentLengthMm = volumeMm3 / areaMm2; + + return filamentLengthMm; + } + + public double ExtrudeAmount(double widthMm, double heightMm, double lengthMm) + { + var volumeMm3 = widthMm * heightMm * lengthMm; + var areaMm2 = Math.PI * Math.Pow(filamentDiameterMm / 2, 2); + var filamentLengthMm = volumeMm3 / areaMm2; + + return filamentLengthMm; + } + public void LineTo(double x, double y) { this.LineTo(new Vector2(x, y)); @@ -172,7 +200,7 @@ namespace MatterHackers.MatterControl position = Transform.Transform(position); var delta = this.CurrentPosition - position; - currentE += delta.Length * 0.048; + currentE += this.ExtrudeAmount(nozzleDiameter, layerHeight, delta.Length); this.WriteSpeedLine( string.Format( diff --git a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs index ff84c03cf..62fb32d24 100644 --- a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs +++ b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs @@ -138,7 +138,7 @@ namespace MatterHackers.MatterControl Task.Run(async () => { - var sketch1 = new GCodeSketch() + var sketch1 = new GCodeSketch(printer) { Speed = (int)(printer.Settings.GetValue(SettingsKey.first_layer_speed) * 60), RetractLength = printer.Settings.GetValue(SettingsKey.retract_length), @@ -147,7 +147,7 @@ namespace MatterHackers.MatterControl TravelSpeed = printer.Settings.GetValue(SettingsKey.travel_speed) * 60, }; - var sketch2 = new GCodeSketch() + var sketch2 = new GCodeSketch(printer) { Speed = sketch1.Speed, RetractLength = sketch1.RetractLength, From 99468f054cfb46b0c72f22d4275941b7e7e58c98 Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 14 Mar 2019 14:38:18 -0700 Subject: [PATCH 2/5] Use extrusion multiplier --- MatterControlLib/CustomWidgets/GCodeSketch.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/MatterControlLib/CustomWidgets/GCodeSketch.cs b/MatterControlLib/CustomWidgets/GCodeSketch.cs index 190ca9f57..4a6ab3808 100644 --- a/MatterControlLib/CustomWidgets/GCodeSketch.cs +++ b/MatterControlLib/CustomWidgets/GCodeSketch.cs @@ -47,6 +47,7 @@ namespace MatterHackers.MatterControl private PrinterConfig printer; private double nozzleDiameter; private double filamentDiameterMm; + private double printerExtrusionMultiplier; private double currentE = 0; private bool retracted = false; private bool penUp = false; @@ -61,6 +62,7 @@ namespace MatterHackers.MatterControl this.printer = printer; nozzleDiameter = printer.Settings.GetValue(SettingsKey.nozzle_diameter); filamentDiameterMm = printer.Settings.GetValue(SettingsKey.filament_diameter); + printerExtrusionMultiplier = printer.Settings.GetValue(SettingsKey.extrusion_multiplier); } public double RetractLength { get; set; } = 1.2; @@ -187,10 +189,20 @@ namespace MatterHackers.MatterControl public void LineTo(double x, double y) { - this.LineTo(new Vector2(x, y)); + this.LineTo(new Vector2(x, y), printerExtrusionMultiplier); + } + + public void LineTo(double x, double y, double extrusionMultiplier) + { + this.LineTo(new Vector2(x, y), extrusionMultiplier); } public void LineTo(Vector2 position) + { + this.LineTo(position, printerExtrusionMultiplier); + } + + public void LineTo(Vector2 position, double extrusionMultiplier) { if (retracted) { @@ -200,7 +212,7 @@ namespace MatterHackers.MatterControl position = Transform.Transform(position); var delta = this.CurrentPosition - position; - currentE += this.ExtrudeAmount(nozzleDiameter, layerHeight, delta.Length); + currentE += this.ExtrudeAmount(nozzleDiameter, layerHeight, delta.Length) * extrusionMultiplier; this.WriteSpeedLine( string.Format( From 4a3855ac8754aefacbff53b179d4931001a75586 Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 14 Mar 2019 17:48:27 -0700 Subject: [PATCH 3/5] Remove unretract at end of print - Remove unretract per suggestion - Issue MatterHackers/MCCentral#5164 Consider doing a retract at the end of the xy calibration --- MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs | 2 -- 1 file changed, 2 deletions(-) diff --git a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs index 62fb32d24..19b298f04 100644 --- a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs +++ b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs @@ -168,8 +168,6 @@ namespace MatterHackers.MatterControl templatePrinter.BuildTemplate(sketch1, sketch2, verticalLayout: true); templatePrinter.BuildTemplate(sketch1, sketch2, verticalLayout: false); - sketch1.Unretract(); - sketch2.Unretract(); string outputPath = Path.Combine( ApplicationDataStorage.Instance.GCodeOutputPath, From a81e1e5411590b747879df6b12281cdf40f9a4c7 Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 14 Mar 2019 17:57:46 -0700 Subject: [PATCH 4/5] Stroke glyph path, fix sizing and rendering artifacts --- .../CustomWidgets/CalibrationLine.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/MatterControlLib/CustomWidgets/CalibrationLine.cs b/MatterControlLib/CustomWidgets/CalibrationLine.cs index 9425b9969..646a83811 100644 --- a/MatterControlLib/CustomWidgets/CalibrationLine.cs +++ b/MatterControlLib/CustomWidgets/CalibrationLine.cs @@ -46,6 +46,7 @@ namespace MatterHackers.MatterControl private ThemeConfig theme; private IVertexSource glyph = null; + private Stroke glyphStroke; private bool _isActive; static CalibrationLine() @@ -57,13 +58,13 @@ namespace MatterHackers.MatterControl { if (parentDirection == FlowDirection.LeftToRight) { - this.Width = glyphSize; + this.Width = glyphSize + 1; this.HAnchor = HAnchor.Absolute; this.VAnchor = VAnchor.Stretch; } else { - this.Height = glyphSize; + this.Height = glyphSize + 1; this.HAnchor = HAnchor.Stretch; this.VAnchor = VAnchor.Absolute; } @@ -79,6 +80,7 @@ namespace MatterHackers.MatterControl } this.glyph = glyph; + this.glyphStroke = new Stroke(glyph.Scale(0.8)); } this.theme = theme; @@ -127,16 +129,16 @@ namespace MatterHackers.MatterControl { Color lineColor = this.IsActive ? theme.PrimaryAccentColor : theme.TextColor; - var centerX = this.LocalBounds.XCenter + .5; - var centerY = this.LocalBounds.YCenter - .5; + var centerX = this.LocalBounds.XCenter; + var centerY = this.LocalBounds.YCenter; - var start = new Vector2(centerX, (glyph == null) ? 20 : (this.IsNegative) ? 6 : 9 ); + var start = new Vector2(centerX, (glyph == null) ? 20 : (this.IsNegative) ? 6 : 12); var end = new Vector2(centerX, this.LocalBounds.Height); if (!verticalLine) { start = new Vector2(0, centerY); - end = new Vector2(this.LocalBounds.Width - ((glyph == null) ? 20 : (this.IsNegative) ? 6 : 9), centerY); + end = new Vector2(this.LocalBounds.Width - ((glyph == null) ? 20 : (this.IsNegative) ? 6 : 12), centerY); } graphics2D.Line(start, end, lineColor, 1); @@ -144,10 +146,10 @@ namespace MatterHackers.MatterControl // Draw line end if (glyph != null) { - int offset = IsNegative ? 18 : 11; + int offset = IsNegative ? 17 : 11; graphics2D.Render( - glyph, + glyphStroke, verticalLine ? new Vector2(centerX, offset) : new Vector2(this.Width - offset, centerY), lineColor); } From bb4c31c2afbbc77a5604bb34abdb2e1ece8a4728 Mon Sep 17 00:00:00 2001 From: jlewin Date: Thu, 14 Mar 2019 17:58:22 -0700 Subject: [PATCH 5/5] Adjust sizing to account for extra pixel in calibration line --- .../PrintLeveling/SetupWizards/NozzleCalibrationWizard.cs | 2 +- MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs | 4 ++-- Submodules/agg-sharp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/NozzleCalibrationWizard.cs b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/NozzleCalibrationWizard.cs index 344e5ddec..e32359cb1 100644 --- a/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/NozzleCalibrationWizard.cs +++ b/MatterControlLib/ConfigurationPage/PrintLeveling/SetupWizards/NozzleCalibrationWizard.cs @@ -41,7 +41,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling : base(printer) { this.WindowTitle = $"{ApplicationController.Instance.ProductName} - " + "Nozzle Calibration Wizard".Localize(); - this.WindowSize = new Vector2(600 * GuiWidget.DeviceScale, 645 * GuiWidget.DeviceScale); + this.WindowSize = new Vector2(600 * GuiWidget.DeviceScale, 700 * GuiWidget.DeviceScale); pages = this.GetPages(); pages.MoveNext(); diff --git a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs index 19b298f04..d6e7e9f06 100644 --- a/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs +++ b/MatterControlLib/CustomWidgets/NozzleOffsetCalibrationPage.cs @@ -65,7 +65,7 @@ namespace MatterHackers.MatterControl HAnchor = HAnchor.Absolute, VAnchor = VAnchor.Absolute, Height = 110, - Width = 420 + Width = 480 }); xOffsetWidget.OffsetChanged += (s, e) => @@ -90,7 +90,7 @@ namespace MatterHackers.MatterControl Padding = new BorderDouble(bottom: 4), VAnchor = VAnchor.Absolute, HAnchor = HAnchor.Absolute, - Height = 420, + Height = 480, Width = 110 }); diff --git a/Submodules/agg-sharp b/Submodules/agg-sharp index 9673b2754..415be0f58 160000 --- a/Submodules/agg-sharp +++ b/Submodules/agg-sharp @@ -1 +1 @@ -Subproject commit 9673b27546ae8c69ba849d643d2a7799797358fc +Subproject commit 415be0f58ce3133e9e6f65c532f753d4f60dba43