Put in baby stepping for T1 (extruder 2)

issue: MatterHackers/MCCentral#5877
Print recovery does not work correctly when the print is extruder 2 only
This commit is contained in:
LarsBrubaker 2020-08-09 12:37:37 -07:00
parent 23e7263da5
commit 7945b381f5
11 changed files with 206 additions and 61 deletions

View file

@ -42,7 +42,9 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
private PrinterMove outputWithBabyStepping = PrinterMove.Unknown;
private PrinterMove inputNoBabyStepping = PrinterMove.Unknown;
public Vector3 BabbyStepOffset { get; private set; } = Vector3.Zero;
public Vector3 BabbyStepOffsetT0 { get; private set; } = Vector3.Zero;
public Vector3 BabbyStepOffsetT1 { get; private set; } = Vector3.Zero;
public BabyStepsStream(PrinterConfig printer, GCodeStream internalStream)
: base(printer, internalStream)
@ -51,7 +53,8 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
extruderIndex = printer.Connection.ActiveExtruderIndex;
BabbyStepOffset = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset));
BabbyStepOffsetT0 = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset));
BabbyStepOffsetT1 = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset_t1));
ReadExtruderOffsets();
}
@ -76,8 +79,13 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
{
if (e?.Data == SettingsKey.baby_step_z_offset)
{
var currentOffset = BabbyStepOffset.Z;
BabbyStepOffset = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset));
var currentOffset = BabbyStepOffsetT0.Z;
BabbyStepOffsetT0 = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset));
}
else if (e?.Data == SettingsKey.baby_step_z_offset_t1)
{
var currentOffset = BabbyStepOffsetT1.Z;
BabbyStepOffsetT1 = new Vector3(0, 0, printer.Settings.GetValue<double>(SettingsKey.baby_step_z_offset_t1));
}
else if (e?.Data == SettingsKey.extruder_offset
&& !printer.Connection.Printing
@ -94,7 +102,15 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
// calculate our offset to pass on to internal streams
inputNoBabyStepping = outputWithBabyStepping;
inputNoBabyStepping.position -= BabbyStepOffset;
if (extruderIndex == 1)
{
inputNoBabyStepping.position -= BabbyStepOffsetT1;
}
else
{
inputNoBabyStepping.position -= BabbyStepOffsetT0;
}
inputNoBabyStepping.position += extruderOffsets[Math.Min(extruderIndex, 4)];
internalStream.SetPrinterPosition(inputNoBabyStepping);
@ -134,7 +150,15 @@ namespace MatterHackers.MatterControl.PrinterCommunication.Io
// it is a struct so this is making a new copy we con modify
PrinterMove moveToSend = inputNoBabyStepping;
moveToSend.position += BabbyStepOffset;
if (extruderIndex == 1)
{
moveToSend.position += BabbyStepOffsetT1;
}
else
{
moveToSend.position += BabbyStepOffsetT0;
}
moveToSend.position -= extruderOffsets[Math.Min(extruderIndex, 4)];
if (moveToSend.HaveAnyPosition)