private void SampleProbePoints() { double startProbeHeight = printer.Settings.GetValue <double>(SettingsKey.print_leveling_probe_start); for (var i = 0; i < probePoints.Count; i++) { var goalProbePosition = probePoints[i]; if (this.HasBeenClosed) { // Make sure when the wizard is done we turn off the bed heating printer.Connection.TurnOffBedAndExtruders(TurnOff.AfterDelay); if (printer.Settings.GetValue <bool>(SettingsKey.z_homes_to_max)) { printer.Connection.HomeAxis(PrinterConnection.Axis.XYZ); } break; } var validProbePosition = PrintLevelingWizard.EnsureInPrintBounds(printer, goalProbePosition); var probePosition = new Vector3(validProbePosition, startProbeHeight); //this.lastReportedPosition = printer.Connection.LastReportedPosition; probePositionsWidget.ActiveProbeIndex = i; probePositionsWidget.Invalidate(); this.StartSampling(i, probePosition); autoResetEvent.WaitOne(); } probePositionsWidget.ActiveProbeIndex = probePoints.Count; this.NextButton.Enabled = true; // Auto advance UiThread.RunOnIdle(this.NextButton.InvokeClick); }
private void SampleProbePoints() { if (waitingToCompleteNextSample) { return; } double startProbeHeight = printer.Settings.GetValue <double>(SettingsKey.print_leveling_probe_start) + ZProbePrintCalibrationPartPage.CalibrationObjectHeight(printer); if (!dataCollected) { var validProbePosition2D = PrintLevelingWizard.EnsureInPrintBounds(printer, printer.Bed.BedCenter); positionToSample = new Vector3(validProbePosition2D, startProbeHeight); this.SamplePoint(); } else { SaveSamplePoints(); CancelValidation(); } }
public static void Start(PrinterConfig printer, ThemeConfig theme) { // turn off print leveling PrintLevelingStream.AllowLeveling = false; // clear any data that we are going to be acquiring (sampled positions, after z home offset) var levelingData = new PrintLevelingData() { LevelingSystem = printer.Settings.GetValue <LevelingSystem>(SettingsKey.print_leveling_solution) }; printer.Settings.SetValue(SettingsKey.baby_step_z_offset, "0"); LevelingPlan levelingPlan; switch (levelingData.LevelingSystem) { case LevelingSystem.Probe3Points: levelingPlan = new LevelWizard3Point(printer); break; case LevelingSystem.Probe7PointRadial: levelingPlan = new LevelWizard7PointRadial(printer); break; case LevelingSystem.Probe13PointRadial: levelingPlan = new LevelWizard13PointRadial(printer); break; case LevelingSystem.Probe100PointRadial: levelingPlan = new LevelWizard100PointRadial(printer); break; case LevelingSystem.Probe3x3Mesh: levelingPlan = new LevelWizardMesh(printer, 3, 3); break; case LevelingSystem.Probe5x5Mesh: levelingPlan = new LevelWizardMesh(printer, 5, 5); break; case LevelingSystem.Probe10x10Mesh: levelingPlan = new LevelWizardMesh(printer, 10, 10); break; case LevelingSystem.ProbeCustom: levelingPlan = new LevelWizardCustom(printer); break; default: throw new NotImplementedException(); } var levelingContext = new PrintLevelingWizard(levelingPlan, printer) { WindowTitle = $"{ApplicationController.Instance.ProductName} - " + "Print Leveling Wizard".Localize() }; var printLevelWizardWindow = DialogWindow.Show(new LevelingWizardRootPage(levelingContext) { WindowTitle = levelingContext.WindowTitle }); printLevelWizardWindow.Closed += (s, e) => { // If leveling was on when we started, make sure it is on when we are done. PrintLevelingStream.AllowLeveling = true; printLevelWizardWindow = null; // make sure we raise the probe on close 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}"); } }; }
protected override IEnumerator <WizardPage> GetPages() { var levelingStrings = new LevelingStrings(); var autoProbePositions = new List <ProbePosition>(3); var manualProbePositions = new List <ProbePosition>(3); autoProbePositions.Add(new ProbePosition()); manualProbePositions.Add(new ProbePosition()); int totalSteps = 3; // make a welcome page if this is the first time calibrating the probe if (!printer.Settings.GetValue <bool>(SettingsKey.probe_has_been_calibrated)) { yield return(new WizardPage( this, "Initial Printer Setup".Localize(), string.Format( "{0}\n\n{1}", "Congratulations on connecting to your printer. Before starting your first print we need to run a simple calibration procedure.".Localize(), "The next few screens will walk your through calibrating your printer.".Localize())) { WindowTitle = Title }); } // Initialize - turn off print leveling printer.Connection.AllowLeveling = false; // remember the current baby stepping values babySteppingValue = printer.Settings.GetValue <double>(SettingsKey.baby_step_z_offset); // clear them while we measure the offsets printer.Settings.SetValue(SettingsKey.baby_step_z_offset, "0"); // show what steps will be taken yield return(new WizardPage( this, "Probe Calibration Overview".Localize(), string.Format( "{0}\n\n\t• {1}\n\t• {2}\n\t• {3}\n\n{4}\n\n{5}", "Welcome to the probe calibration wizard. Here is a quick overview on what we are going to do.".Localize(), "Home the printer".Localize(), "Probe the bed at the center".Localize(), "Manually measure the extruder at the center".Localize(), "We should be done in less than five minutes.".Localize(), "Click 'Next' to continue.".Localize())) { WindowTitle = Title }); // add in the homing printer page yield return(new HomePrinterPage( this, "Homing The Printer".Localize(), levelingStrings.HomingPageInstructions(true, false), false)); // if there is a level_x_carriage_markdown oem markdown page if (!string.IsNullOrEmpty(printer.Settings.GetValue(SettingsKey.level_x_carriage_markdown))) { yield return(PrintLevelingWizard.GetLevelXCarriagePage(this, printer)); } if (LevelingValidation.NeedsToBeRun(printer)) { // start heating up the bed as that will be needed next var bedTemperature = printer.Settings.GetValue <bool>(SettingsKey.has_heated_bed) ? printer.Settings.GetValue <double>(SettingsKey.bed_temperature) : 0; if (bedTemperature > 0) { printer.Connection.TargetBedTemperature = bedTemperature; } } var extruderCount = printer.Settings.GetValue <int>(SettingsKey.extruder_count); var temps = new double[4]; for (int i = 0; i < extruderCount; i++) { temps[i] = printer.Settings.Helpers.ExtruderTargetTemperature(i); } yield return(new WaitForTempPage( this, "Waiting For Printer To Heat".Localize(), ((extruderCount == 1) ? "Waiting for the hotend to heat to ".Localize() + temps[0] + "°C.\n" : "Waiting for the hotends to heat up.".Localize()) + "This will ensure that no filament is stuck to your nozzle.".Localize() + "\n" + "\n" + "Warning! The tip of the nozzle will be HOT!".Localize() + "\n" + "Avoid contact with your skin.".Localize(), 0, temps)); double startProbeHeight = printer.Settings.GetValue <double>(SettingsKey.print_leveling_probe_start); Vector2 probePosition = LevelingPlan.ProbeOffsetSamplePosition(printer); Vector3 probeStartPosition = new Vector3(probePosition, startProbeHeight); int extruderPriorToMeasure = printer.Connection.ActiveExtruderIndex; if (extruderCount > 1) { // reset the extruder that was active printer.Connection.QueueLine($"T0"); } int numberOfSamples = printer.Settings.GetValue <int>(SettingsKey.z_probe_samples); // do the automatic probing of the center position yield return(new AutoProbeFeedback( this, probeStartPosition, $"{"Step".Localize()} 1 {"of".Localize()} {numberOfSamples}: {"Position".Localize()} 1 - {"Auto Calibrate".Localize()}", autoProbePositions, 0)); // show what steps will be taken yield return(new WizardPage( this, "Measure the nozzle offset".Localize(), "{0}:\n\n\t• {1}\n\n{2}\n\n{3}".FormatWith( "To complete the next few steps you will need".Localize(), "A sheet of paper".Localize(), "We will use this paper to measure the distance between the nozzle and the bed.".Localize(), "Click 'Next' to continue.".Localize()))); // we currently only support calibrating 2 extruders for (int extruderIndex = 0; extruderIndex < Math.Min(extruderCount, 2); extruderIndex++) { if (extruderCount > 1) { // reset the extruder that was active printer.Connection.QueueLine($"T{extruderIndex}"); } // do the manual prob of the same position yield return(new GetCoarseBedHeight( this, new Vector3(probePosition, startProbeHeight), string.Format( "{0} {1} {2} - {3}", levelingStrings.GetStepString(totalSteps), "Position".Localize(), 1, "Low Precision".Localize()), manualProbePositions, 0, levelingStrings)); yield return(new GetFineBedHeight( this, string.Format( "{0} {1} {2} - {3}", levelingStrings.GetStepString(totalSteps), "Position".Localize(), 1, "Medium Precision".Localize()), manualProbePositions, 0, levelingStrings)); yield return(new GetUltraFineBedHeight( this, string.Format( "{0} {1} {2} - {3}", levelingStrings.GetStepString(totalSteps), "Position".Localize(), 1, "High Precision".Localize()), manualProbePositions, 0, levelingStrings)); if (extruderIndex == 0) { // set the probe z offset double newProbeOffset = autoProbePositions[0].position.Z - manualProbePositions[0].position.Z; var probe_offset = printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset); probe_offset.Z = -newProbeOffset; printer.Settings.SetValue(SettingsKey.probe_offset, $"{probe_offset.X},{probe_offset.Y},{probe_offset.Z}"); } else if (extruderIndex == 1) { // store the offset into the extruder offset z position double newProbeOffset = autoProbePositions[0].position.Z - manualProbePositions[0].position.Z; var hotend0Offset = printer.Settings.GetValue <Vector3>(SettingsKey.probe_offset); var newZOffset = newProbeOffset + hotend0Offset.Z; printer.Settings.Helpers.SetExtruderZOffset(1, newZOffset); } } printer.Settings.SetValue(SettingsKey.probe_has_been_calibrated, "1"); if (extruderCount > 1) { // reset the extruder that was active printer.Connection.QueueLine($"T{extruderPriorToMeasure}"); } // clear the baby stepping so we don't save the old values babySteppingValue = 0; yield return(new CalibrateProbeLastPageInstructions( this, "Done".Localize())); }