private IEnumerable <WizardPage> DoManualOffsetMeasurment(LevelingStrings levelingStrings,
                                                                  List <PrintLevelingWizard.ProbePosition> autoProbePositions,
                                                                  List <List <PrintLevelingWizard.ProbePosition> > manualProbePositions)
        {
            int hotendCount = Math.Min(2, printer.Settings.Helpers.HotendCount());

            if (printer.Settings.Helpers.ProbeBeingUsed)
            {
                // do the automatic probing of the center position
                yield return(new AutoProbeFeedback(
                                 this,
                                 ProbeStartPosition,
                                 "Probe at bed center".Localize(),
                                 "Sample the bed center position to determine the probe distance to the bed".Localize(),
                                 autoProbePositions,
                                 0));
            }

            if (hotendCount == 1 &&
                printer.Settings.Helpers.ProbeBeingUsed &&
                printer.Settings.GetValue <bool>(SettingsKey.has_conductive_nozzle) &&
                printer.Settings.GetValue <bool>(SettingsKey.measure_probe_offset_conductively))
            {
                var conductiveProbeFeedback = new ConductiveProbeFeedback(
                    this,
                    ProbeStartPosition,
                    "Conductive Probing".Localize(),
                    "Measure the nozzle to probe offset using the conductive pad.".Localize(),
                    manualProbePositions[0]);
                yield return(conductiveProbeFeedback);

                if (conductiveProbeFeedback.MovedBelowMinZ)
                {
                    // show an error message
                    yield return(new WizardPage(
                                     this,
                                     "Error: Below Conductive Probe Min Z".Localize(),
                                     "The printer moved below the minimum height set for conductive probing. Check that the nozzle is clean and there is continuity with the pad.".Localize()));
                }
                else                 // found a good probe height
                {
                    SetExtruderOffset(autoProbePositions, manualProbePositions, 0);
                }
            }
            else             // collect the probe information manually
            {
                // 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())));

                var extruderCount = printer.Settings.GetValue <int>(SettingsKey.extruder_count);
                int totalSteps    = 3 * hotendCount;

                for (int extruderIndex = 0; extruderIndex < hotendCount; extruderIndex++)
                {
                    if (extruderCount > 1)
                    {
                        // reset the extruder that was active
                        printer.Connection.QueueLine($"T{extruderIndex}");
                    }

                    // do the manual probe 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[extruderIndex],
                                     0,
                                     levelingStrings));

                    yield return(new GetFineBedHeight(
                                     this,
                                     string.Format(
                                         "{0} {1} {2} - {3}",
                                         levelingStrings.GetStepString(totalSteps),
                                         "Position".Localize(),
                                         1,
                                         "Medium Precision".Localize()),
                                     manualProbePositions[extruderIndex],
                                     0,
                                     levelingStrings));

                    yield return(new GetUltraFineBedHeight(
                                     this,
                                     string.Format(
                                         "{0} {1} {2} - {3}",
                                         levelingStrings.GetStepString(totalSteps),
                                         "Position".Localize(),
                                         1,
                                         "High Precision".Localize()),
                                     manualProbePositions[extruderIndex],
                                     0,
                                     levelingStrings));

                    SetExtruderOffset(autoProbePositions, manualProbePositions, extruderIndex);
                }
            }

            // let the user know we are done with the manual part
            yield return(new CalibrateProbeRemovePaperInstructions(this, PageTitle, false));
        }
示例#2
0
        protected override IEnumerator <WizardPage> GetPages()
        {
            var levelingStrings      = new LevelingStrings();
            var autoProbePositions   = new List <PrintLevelingWizard.ProbePosition>(1);
            int hotendCount          = Math.Min(2, printer.Settings.Helpers.HotendCount());
            var manualProbePositions = new List <List <PrintLevelingWizard.ProbePosition> >(hotendCount);

            for (int i = 0; i < hotendCount; i++)
            {
                manualProbePositions.Add(new List <PrintLevelingWizard.ProbePosition>());
                manualProbePositions[i] = new List <PrintLevelingWizard.ProbePosition>(1)
                {
                    new PrintLevelingWizard.ProbePosition()
                };
            }

            autoProbePositions.Add(new PrintLevelingWizard.ProbePosition());

            int totalSteps = 3 * hotendCount;

            // show what steps will be taken
            yield return(new WizardPage(
                             this,
                             string.Format("{0} {1}", this.Title, "Overview".Localize()),
                             string.Format(
                                 "{0}\n\n{1}\n\n{2}\n\n",
                                 "Z Calibration measures the z position of the nozzles.".Localize(),
                                 "This data is required for software print leveling and ensures good first layer adhesion.".Localize(),
                                 "Click 'Next' to continue.".Localize()))
            {
                WindowTitle = Title,
            });

            // Initialize - turn off print leveling
            printer.Connection.AllowLeveling = false;

            printer.Settings.ForTools <double>(SettingsKey.baby_step_z_offset, (key, value, i) =>
            {
                // remember the current baby stepping values
                babySteppingValue[i] = value;
                // clear them while we measure the offsets
                printer.Settings.SetValue(key, "0");
            });

            // Require user confirmation after this point
            this.RequireCancelConfirmation = true;

            // add in the homing printer page
            yield return(new HomePrinterPage(
                             this,
                             levelingStrings.HomingPageInstructions(true, false)));

            if (LevelingPlan.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,
                             "Heating the printer".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);
            var     probeStartPosition = new Vector3(probePosition, startProbeHeight);

            int extruderPriorToMeasure = printer.Connection.ActiveExtruderIndex;

            if (extruderCount > 1)
            {
                // reset the extruder that was active
                printer.Connection.QueueLine($"T0");
            }

            bool probeBeingUsed = printer.Settings.GetValue <bool>(SettingsKey.has_z_probe) &&
                                  printer.Settings.GetValue <bool>(SettingsKey.use_z_probe);

            if (probeBeingUsed)
            {
                // do the automatic probing of the center position
                yield return(new AutoProbeFeedback(
                                 this,
                                 probeStartPosition,
                                 "Probe at bed center".Localize(),
                                 "Sample the bed center position to determine the probe distance to the bed".Localize(),
                                 autoProbePositions,
                                 0));
            }

            if (hotendCount == 1 &&
                probeBeingUsed &&
                printer.Settings.GetValue <bool>(SettingsKey.has_conductive_nozzle) &&
                printer.Settings.GetValue <bool>(SettingsKey.measure_probe_offset_conductively))
            {
                var conductiveProbeFeedback = new ConductiveProbeFeedback(
                    this,
                    probeStartPosition,
                    "Conductive Probing".Localize(),
                    "Measure the nozzle to probe offset using the conductive pad.".Localize(),
                    manualProbePositions[0]);
                yield return(conductiveProbeFeedback);

                if (conductiveProbeFeedback.MovedBelowMinZ)
                {
                    // show an error message
                    yield return(new WizardPage(
                                     this,
                                     "Error: Below Conductive Probe Min Z".Localize(),
                                     "The printer moved below the minimum height set for conductive probing. Check that the nozzle is clean and there is continuity with the pad.".Localize()));
                }
                else                 // found a good probe height
                {
                    SetExtruderOffset(autoProbePositions, manualProbePositions, false, 0);
                }
            }
            else             // collect the probe information manually
            {
                // 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())));

                for (int extruderIndex = 0; extruderIndex < hotendCount; extruderIndex++)
                {
                    if (extruderCount > 1)
                    {
                        // reset the extruder that was active
                        printer.Connection.QueueLine($"T{extruderIndex}");
                    }

                    // do the manual probe 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[extruderIndex],
                                     0,
                                     levelingStrings));

                    yield return(new GetFineBedHeight(
                                     this,
                                     string.Format(
                                         "{0} {1} {2} - {3}",
                                         levelingStrings.GetStepString(totalSteps),
                                         "Position".Localize(),
                                         1,
                                         "Medium Precision".Localize()),
                                     manualProbePositions[extruderIndex],
                                     0,
                                     levelingStrings));

                    yield return(new GetUltraFineBedHeight(
                                     this,
                                     string.Format(
                                         "{0} {1} {2} - {3}",
                                         levelingStrings.GetStepString(totalSteps),
                                         "Position".Localize(),
                                         1,
                                         "High Precision".Localize()),
                                     manualProbePositions[extruderIndex],
                                     0,
                                     levelingStrings));

                    SetExtruderOffset(autoProbePositions, manualProbePositions, probeBeingUsed, extruderIndex);
                }
            }

            if (extruderCount > 1)
            {
                // reset the extruder that was active
                printer.Connection.QueueLine($"T{extruderPriorToMeasure}");
            }

            for (int i = 0; i < extruderCount; i++)
            {
                // clear the baby stepping so we don't save the old values
                babySteppingValue[i] = 0;
            }

            yield return(new CalibrateProbeLastPageInstructions(this, this.Title + " " + "Wizard".Localize()));
        }