Code to enable going below 0 for printe recovery

This commit is contained in:
larsbrubaker 2016-10-10 19:30:48 -07:00
parent ed0b271ddb
commit 426c0ede6a
11 changed files with 85 additions and 53 deletions

View file

@ -89,16 +89,16 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
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], true));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabelTwo, highPrecisionTwoLabel), probePositions[0], 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], true));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabelThree, highPrecisionLabelThree), probePositions[2], 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]));

View file

@ -51,7 +51,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
public LevelWizard3Point(LevelWizardBase.RuningState runningState)
: base(500, 370, 9)
{
bool allowLessThanZero = ActiveSliceSettings.Instance.GetValue("z_can_be_negative") == "1";
string printLevelWizardTitle = LocalizedString.Get("MatterControl");
string printLevelWizardTitleFull = LocalizedString.Get("Print Leveling Wizard");
Title = string.Format("{0} - {1}", printLevelWizardTitle, printLevelWizardTitleFull);
@ -81,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], allowLessThanZero));
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[0], allowLessThanZero));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 1 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[0], allowLessThanZero));
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], allowLessThanZero));
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[1], allowLessThanZero));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 2 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[1], allowLessThanZero));
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], allowLessThanZero));
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, medPrecisionLabel), probePositions[2], allowLessThanZero));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} 3 - {2}", GetStepString(), positionLabel, highPrecisionLabel), probePositions[2], allowLessThanZero));
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));

View file

@ -182,7 +182,6 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
{
pageOneInstructionsTextThree = pageOneInstructionsTextThree.FormatWith(numberOfRadialSamples+1);
bool allowLessThanZero = ActiveSliceSettings.Instance.GetValue("z_can_be_negative") == "1";
string printLevelWizardTitle = "MatterControl";
string printLevelWizardTitleFull = "Print Leveling Wizard".Localize();
Title = string.Format("{0} - {1}", printLevelWizardTitle, printLevelWizardTitleFull);
@ -218,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], allowLessThanZero));
printLevelWizard.AddPage(new GetFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, medPrecisionLabel), probePositions[i], allowLessThanZero));
printLevelWizard.AddPage(new GetUltraFineBedHeight(string.Format("{0} {1} {2} - {3}", GetStepString(), positionLabel, i + 1, highPrecisionLabel), probePositions[i], allowLessThanZero));
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);

View file

@ -232,15 +232,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
private Vector3 lastReportedPosition;
private ProbePosition probePosition;
private double moveAmount;
private bool allowLessThan0;
protected JogControls.MoveButton zPlusControl;
protected JogControls.MoveButton zMinusControl;
public FindBedHeight(string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance, ProbePosition whereToWriteProbePosition, bool allowLessThan0)
public FindBedHeight(string pageDescription, string setZHeightCoarseInstruction1, string setZHeightCoarseInstruction2, double moveDistance, ProbePosition whereToWriteProbePosition)
: base(pageDescription, setZHeightCoarseInstruction1)
{
this.allowLessThan0 = allowLessThan0;
this.moveAmount = moveDistance;
this.lastReportedPosition = PrinterConnectionAndCommunication.Instance.LastReportedPosition;
this.probePosition = whereToWriteProbePosition;
@ -300,21 +298,18 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
return zButtons;
}
private static string zIsTooLowMessage = "You cannot move any lower. This position on your bed is too low for the extruder to reach. You need to raise your bed, or adjust your limits to allow the extruder to go lower.".Localize();
private static string zTooLowTitle = "Warning - Moving Too Low".Localize();
private void zMinusControl_Click(object sender, EventArgs mouseEvent)
{
if (!allowLessThan0
&& PrinterConnectionAndCommunication.Instance.LastReportedPosition.z - moveAmount < 0)
double newPosition = PrinterConnectionAndCommunication.Instance.LastReportedPosition.z - moveAmount;
bool moveBelow0 = newPosition < 0;
if (moveBelow0)
{
UiThread.RunOnIdle(() =>
{
StyledMessageBox.ShowMessageBox(null, zIsTooLowMessage, zTooLowTitle, StyledMessageBox.MessageType.OK);
});
// don't move the bed lower it will not work when we print.
return;
throw new NotImplementedException("If we are going to go below 0");
// increment the z_offset_after_home
// adjust all previously sampled points
// send a G92 z position to the printer to adjust the current z height
}
PrinterConnectionAndCommunication.Instance.MoveRelative(PrinterConnectionAndCommunication.Axis.Z, -moveAmount, ActiveSliceSettings.Instance.Helpers.ManualMovementSpeeds().z);
PrinterConnectionAndCommunication.Instance.ReadPosition();
}
@ -340,8 +335,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
protected Vector3 probeStartPosition;
protected WizardControl container;
public GetCoarseBedHeight(WizardControl container, Vector3 probeStartPosition, string pageDescription, ProbePosition whereToWriteProbePosition, bool allowLessThan0)
: base(pageDescription, setZHeightCoarseInstruction1, setZHeightCoarseInstruction2, 1, whereToWriteProbePosition, allowLessThan0)
public GetCoarseBedHeight(WizardControl container, Vector3 probeStartPosition, string pageDescription, ProbePosition whereToWriteProbePosition)
: base(pageDescription, setZHeightCoarseInstruction1, setZHeightCoarseInstruction2, 1, whereToWriteProbePosition)
{
this.container = container;
this.probeStartPosition = probeStartPosition;
@ -383,7 +378,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
private ProbePosition whereToWriteSamplePosition;
public GetCoarseBedHeightProbeFirst(WizardControl container, Vector3 probeStartPosition, string pageDescription, ProbePosition whereToWriteProbePosition, ProbePosition whereToWriteSamplePosition, bool allowLessThan0)
: base(container, probeStartPosition, pageDescription, whereToWriteProbePosition, allowLessThan0)
: base(container, probeStartPosition, pageDescription, whereToWriteProbePosition)
{
this.whereToWriteSamplePosition = whereToWriteSamplePosition;
}
@ -446,8 +441,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, bool allowLessThan0)
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .1, whereToWriteProbePosition, allowLessThan0)
public GetFineBedHeight(string pageDescription, ProbePosition whereToWriteProbePosition)
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .1, whereToWriteProbePosition)
{
}
}
@ -459,8 +454,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, bool allowLessThan0)
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .02, whereToWriteProbePosition, allowLessThan0)
public GetUltraFineBedHeight(string pageDescription, ProbePosition whereToWriteProbePosition)
: base(pageDescription, setZHeightFineInstruction1, setZHeightFineInstruction2, .02, whereToWriteProbePosition)
{
}

View file

@ -2911,6 +2911,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|| (lineWithoutChecksum.StartsWith("T") && !lineWithoutChecksum.StartsWith("T:"))) // is a switch extruder (verify this is the right time to ask this)
{
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
}
// write data to communication

View file

@ -132,12 +132,7 @@ namespace MatterHackers.MatterControl
int linkCompatibleRow = row;
int linkCompatibleAxis = axis;
double minValue = double.MinValue;
if (axis == 2 && ActiveSliceSettings.Instance.GetValue("z_can_be_negative") == "0")
{
minValue = 0;
}
MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, minValue: minValue, pixelWidth: 60, tabIndex: tab_index++);
MHNumberEdit valueEdit = new MHNumberEdit(positions[linkCompatibleRow][linkCompatibleAxis], allowNegatives: true, allowDecimals: true, pixelWidth: 60, tabIndex: tab_index++);
valueEdit.ActuallNumberEdit.InternalTextEditWidget.EditComplete += (sender, e) =>
{
Vector3 position = positions[linkCompatibleRow];

View file

@ -104,6 +104,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
public const string temperature = nameof(temperature);
public const string windows_driver = nameof(windows_driver);
public const string z_homes_to_max = nameof(z_homes_to_max);
public const string printer_z_after_home = nameof(printer_z_after_home);
public const string z_offset_after_home = nameof(z_offset_after_home);
}
public class SettingsHelpers

View file

@ -69,7 +69,8 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
SettingsKey.recover_position_before_z_home,
SettingsKey.resume_gcode,
SettingsKey.temperature,
"z_can_be_negative",
SettingsKey.printer_z_after_home,
SettingsKey.z_offset_after_home,
"z_homes_to_max",
// TODO: merge the items below into the list above after some validation - setting that weren't previously mapped to Cura but probably should be.

View file

@ -305,7 +305,6 @@ Advanced
has_power_control
Behavior
z_homes_to_max
z_can_be_negative
heat_extruder_before_homing
extruders_share_temperature
Firmware
@ -321,6 +320,9 @@ Advanced
print_leveling_required_to_print
Probe Settings
manual_probe_paper_width
Leveling Calibration
printer_z_after_home
z_offset_after_home
Options
Print Recovery
Recover Settings

View file

@ -2528,13 +2528,27 @@
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_can_be_negative",
"PresentationName": "Z Can Be Negative",
"HelpText": "Allows the printer to attempt going below 0 along the Z axis during the Software Print Leveling wizard, and disables related warnings. Does not override actual endstops, physical or software.",
"DataEditType": "CHECK_BOX",
"ExtraSettings": "",
"SlicerConfigName": "printer_z_after_home",
"PresentationName": "Z Home Position",
"HelpText": "This is automatically set by MatterControl. You do not need to adjust it.",
"DataEditType": "POSITIVE_DOUBLE",
"ExtraSettings": "mm",
"ShowAsOverride": true,
"ShowIfSet": "!has_hardware_leveling",
"ShowIfSet": null,
"ResetAtEndOfPrint": false,
"DefaultValue": "0",
"RebuildGCodeOnChange": false
},
{
"QuickMenuSettings": [ ],
"SetSettingsOnChange": [ ],
"SlicerConfigName": "z_offset_after_home",
"PresentationName": "Offset After Homing",
"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,
"ShowIfSet": null,
"ResetAtEndOfPrint": false,
"DefaultValue": "0",
"RebuildGCodeOnChange": false

View file

@ -5503,3 +5503,21 @@ Translated:Oops! Please select a folder to search
English:The bed is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting bed temperature in SETTINGS -> Filament -> Temperatures.\n\n{1}
Translated:The bed is currently heating and its target temperature cannot be changed until it reaches {0}°C.\n\nYou can set the starting bed temperature in SETTINGS -> Filament -> Temperatures.\n\n{1}
English:This is automatically set by MatterControl. You do not need to adjust it.
Translated:This is automatically set by MatterControl. You do not need to adjust it.
English: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.
Translated: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.
English:Z Home Position
Translated:Z Home Position
English:Offset After Homing
Translated:Offset After Homing
English:Leveling Calibration
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.