We can now move all the way through the initial setup on first run
Fixed a bug with timing of injecting regex replacements moved T (extruder) tracking to queued command stream check that we have loaded filament on extruder 1 issue: MatterHackers/MCCentral#5029 Don't do actual switch of extruders until there is a pending move command
This commit is contained in:
parent
415b16fd06
commit
d129a75311
16 changed files with 231 additions and 88 deletions
|
|
@ -43,12 +43,14 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
public class LoadFilamentWizard : PrinterSetupWizard
|
||||
{
|
||||
private bool showAlreadyLoadedButton;
|
||||
|
||||
public double TemperatureAtStart { get; private set; }
|
||||
private int extruderIndex;
|
||||
|
||||
public static void Start(PrinterConfig printer, ThemeConfig theme, int extruderIndex)
|
||||
public static void Start(PrinterConfig printer, ThemeConfig theme, int extruderIndex, bool showAlreadyLoadedButton)
|
||||
{
|
||||
var loadFilamentWizard = new LoadFilamentWizard(printer, extruderIndex);
|
||||
var loadFilamentWizard = new LoadFilamentWizard(printer, extruderIndex, showAlreadyLoadedButton);
|
||||
|
||||
loadFilamentWizard.WindowTitle = $"{ApplicationController.Instance.ProductName} - " + "Load Filament Wizard".Localize();
|
||||
|
||||
|
|
@ -62,19 +64,25 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
};
|
||||
}
|
||||
|
||||
public LoadFilamentWizard(PrinterConfig printer, int extruderIndex)
|
||||
public LoadFilamentWizard(PrinterConfig printer, int extruderIndex, bool showAlreadyLoadedButton)
|
||||
: base(printer)
|
||||
{
|
||||
this.showAlreadyLoadedButton = showAlreadyLoadedButton;
|
||||
TemperatureAtStart = printer.Connection.GetTargetHotendTemperature(extruderIndex);
|
||||
this.extruderIndex = extruderIndex;
|
||||
}
|
||||
|
||||
public static bool NeedsToBeRun(PrinterConfig printer)
|
||||
public static bool NeedsToBeRun0(PrinterConfig printer)
|
||||
{
|
||||
// we have a probe that we are using and we have not done leveling yet
|
||||
return !printer.Settings.GetValue<bool>(SettingsKey.filament_has_been_loaded);
|
||||
}
|
||||
|
||||
public static bool NeedsToBeRun1(PrinterConfig printer)
|
||||
{
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
return extruderCount > 1 && !printer.Settings.GetValue<bool>(SettingsKey.filament_1_has_been_loaded);
|
||||
}
|
||||
|
||||
protected override IEnumerator<PrinterSetupWizardPage> GetWizardSteps()
|
||||
{
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
|
@ -83,9 +91,13 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
var title = "Load Material".Localize();
|
||||
var instructions = "Please select the material you want to load.".Localize();
|
||||
if(extruderCount > 1)
|
||||
{
|
||||
instructions = "Please select the material you want to load into extruder {0}.".Localize().FormatWith(extruderIndex + 1);
|
||||
}
|
||||
|
||||
// select the material
|
||||
yield return new SelectMaterialPage(this, title, instructions, "Select".Localize(), extruderIndex, false);
|
||||
yield return new SelectMaterialPage(this, title, instructions, "Select".Localize(), extruderIndex, false, showAlreadyLoadedButton);
|
||||
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
|
|
@ -341,7 +353,16 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
};
|
||||
runningCleanPage.Closed += (s, e) =>
|
||||
{
|
||||
UiThread.ClearInterval(runningGCodeCommands);
|
||||
switch (extruderIndex)
|
||||
{
|
||||
case 0:
|
||||
printer.Settings.SetValue(SettingsKey.filament_has_been_loaded, "1");
|
||||
break;
|
||||
|
||||
case 1:
|
||||
printer.Settings.SetValue(SettingsKey.filament_1_has_been_loaded, "1");
|
||||
break;
|
||||
}
|
||||
printer.Settings.SetValue(SettingsKey.filament_has_been_loaded, "1");
|
||||
};
|
||||
|
||||
|
|
@ -384,7 +405,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
loadFilament2Button.Click += (s, e) =>
|
||||
{
|
||||
loadFilament2Button.Parents<SystemWindow>().First().Close();
|
||||
LoadFilamentWizard.Start(printer, theme, 1);
|
||||
LoadFilamentWizard.Start(printer, theme, 1, true);
|
||||
};
|
||||
theme.ApplyPrimaryActionStyle(loadFilament2Button);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,18 +71,22 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
protected override IEnumerator<PrinterSetupWizardPage> GetWizardSteps()
|
||||
{
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
var levelingStrings = new LevelingStrings(printer.Settings);
|
||||
|
||||
var title = "Unload Material".Localize();
|
||||
var instructions = "Please select the material you want to unload.".Localize();
|
||||
if (extruderCount > 1)
|
||||
{
|
||||
instructions = "Please select the material you want to unload from extruder {0}.".Localize().FormatWith(extruderIndex + 1);
|
||||
}
|
||||
|
||||
// select the material
|
||||
yield return new SelectMaterialPage(this, title, instructions, "Unload".Localize(), extruderIndex, false);
|
||||
yield return new SelectMaterialPage(this, title, instructions, "Unload".Localize(), extruderIndex, false, false);
|
||||
|
||||
var theme = ApplicationController.Instance.Theme;
|
||||
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
// wait for extruder to heat
|
||||
{
|
||||
var targetHotendTemp = printer.Settings.Helpers.ExtruderTargetTemperature(extruderIndex);
|
||||
|
|
@ -237,7 +241,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
loadFilamentButton.Click += (s, e) =>
|
||||
{
|
||||
loadFilamentButton.Parents<SystemWindow>().First().Close();
|
||||
LoadFilamentWizard.Start(printer, theme, extruderIndex);
|
||||
LoadFilamentWizard.Start(printer, theme, extruderIndex, false);
|
||||
};
|
||||
theme.ApplyPrimaryActionStyle(loadFilamentButton);
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
public class SelectMaterialPage : PrinterSetupWizardPage
|
||||
{
|
||||
public SelectMaterialPage(PrinterSetupWizard context, string headerText, string instructionsText, string nextButtonText, int extruderIndex, bool showLoadFilamentButton)
|
||||
public SelectMaterialPage(PrinterSetupWizard context, string headerText, string instructionsText, string nextButtonText, int extruderIndex, bool showLoadFilamentButton, bool showAlreadyLoadedButton)
|
||||
: base(context, headerText, instructionsText)
|
||||
{
|
||||
contentRow.AddChild(
|
||||
|
|
@ -50,39 +50,48 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
|
||||
if (showLoadFilamentButton)
|
||||
{
|
||||
AddLoadFilamentButton();
|
||||
NextButton.Visible = false;
|
||||
|
||||
var loadFilamentButton = new TextButton("Load Filament".Localize(), theme)
|
||||
{
|
||||
Name = "Load Filament",
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
};
|
||||
loadFilamentButton.Click += (s, e) =>
|
||||
{
|
||||
wizardContext.ShowNextPage(this.DialogWindow);
|
||||
};
|
||||
|
||||
this.AddPageAction(loadFilamentButton);
|
||||
}
|
||||
}
|
||||
|
||||
private void AddLoadFilamentButton()
|
||||
{
|
||||
NextButton.Visible = false;
|
||||
|
||||
var loadFilamentButton = new TextButton("Load Filament".Localize(), theme)
|
||||
if (showAlreadyLoadedButton)
|
||||
{
|
||||
Name = "Load Filament",
|
||||
BackgroundColor = theme.MinimalShade,
|
||||
};
|
||||
loadFilamentButton.Click += (s, e) =>
|
||||
{
|
||||
wizardContext.ShowNextPage(this.DialogWindow);
|
||||
};
|
||||
NextButton.Visible = false;
|
||||
|
||||
this.AddPageAction(loadFilamentButton);
|
||||
var alreadyLoadedButton = new TextButton("Already Loaded".Localize(), theme)
|
||||
{
|
||||
Name = "Already Loaded Button",
|
||||
BackgroundColor = theme.MinimalShade
|
||||
};
|
||||
|
||||
var selectButton = new TextButton("Already Loaded".Localize(), theme)
|
||||
{
|
||||
Name = "Already Loaded Button",
|
||||
BackgroundColor = theme.MinimalShade
|
||||
};
|
||||
alreadyLoadedButton.Click += (s, e) =>
|
||||
{
|
||||
this.DialogWindow.CloseOnIdle();
|
||||
switch (extruderIndex)
|
||||
{
|
||||
case 0:
|
||||
printer.Settings.SetValue(SettingsKey.filament_has_been_loaded, "1");
|
||||
break;
|
||||
|
||||
selectButton.Click += (s, e) =>
|
||||
{
|
||||
this.DialogWindow.CloseOnIdle();
|
||||
printer.Settings.SetValue(SettingsKey.filament_has_been_loaded, "1");
|
||||
};
|
||||
case 1:
|
||||
printer.Settings.SetValue(SettingsKey.filament_1_has_been_loaded, "1");
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
this.AddPageAction(selectButton);
|
||||
this.AddPageAction(alreadyLoadedButton);
|
||||
}
|
||||
}
|
||||
|
||||
public override void PageIsBecomingInactive()
|
||||
|
|
|
|||
|
|
@ -28,11 +28,13 @@ either expressed or implied, of the FreeBSD Project.
|
|||
*/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
|
||||
namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
||||
{
|
||||
|
|
@ -45,9 +47,9 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
private TextWidget bedDoneText;
|
||||
private double bedTargetTemp;
|
||||
|
||||
private ProgressBar hotEndProgressBar;
|
||||
private TextWidget hotEndProgressBarText;
|
||||
private TextWidget hotEndDoneText;
|
||||
private List<ProgressBar> hotEndProgressBars = new List<ProgressBar>();
|
||||
private List<TextWidget> hotEndProgressBarTexts = new List<TextWidget>();
|
||||
private List<TextWidget> hotEndDoneTexts = new List<TextWidget>();
|
||||
private double[] targetHotendTemps;
|
||||
|
||||
public WaitForTempPage(PrinterSetupWizard context,
|
||||
|
|
@ -58,6 +60,8 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
this.bedTargetTemp = targetBedTemp;
|
||||
this.targetHotendTemps = targetHotendTemps;
|
||||
|
||||
var extruderCount = printer.Settings.GetValue<int>(SettingsKey.extruder_count);
|
||||
|
||||
for (int i = 0; i < targetHotendTemps.Length; i++)
|
||||
{
|
||||
var hotEndTargetTemp = targetHotendTemps[i];
|
||||
|
|
@ -68,15 +72,21 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
Margin = new BorderDouble(0, 5)
|
||||
};
|
||||
|
||||
var lableText = "Hotend Temperature:".Localize();
|
||||
if (extruderCount > 1)
|
||||
{
|
||||
lableText = "Hotend {0} Temperature:".Localize().FormatWith(i + 1);
|
||||
}
|
||||
|
||||
// put in bar name
|
||||
contentRow.AddChild(new TextWidget("Hotend Temperature:".Localize(), pointSize: 10, textColor: theme.TextColor)
|
||||
contentRow.AddChild(new TextWidget(lableText, pointSize: 10, textColor: theme.TextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 5, 5),
|
||||
});
|
||||
|
||||
// put in the progress bar
|
||||
hotEndProgressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
|
||||
var hotEndProgressBar = new ProgressBar((int)(150 * GuiWidget.DeviceScale), (int)(15 * GuiWidget.DeviceScale))
|
||||
{
|
||||
FillColor = theme.PrimaryAccentColor,
|
||||
BorderColor = theme.TextColor,
|
||||
|
|
@ -85,24 +95,26 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
VAnchor = VAnchor.Center
|
||||
};
|
||||
hotEndProgressHolder.AddChild(hotEndProgressBar);
|
||||
hotEndProgressBars.Add(hotEndProgressBar);
|
||||
|
||||
// put in the status
|
||||
hotEndProgressBarText = new TextWidget("", pointSize: 10, textColor: theme.TextColor)
|
||||
var hotEndProgressBarText = new TextWidget("", pointSize: 10, textColor: theme.TextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Margin = new BorderDouble(5, 0, 5, 5),
|
||||
VAnchor = VAnchor.Center
|
||||
};
|
||||
hotEndProgressHolder.AddChild(hotEndProgressBarText);
|
||||
hotEndProgressBarTexts.Add(hotEndProgressBarText);
|
||||
|
||||
// message to show when done
|
||||
hotEndDoneText = new TextWidget("Done!", textColor: theme.TextColor)
|
||||
var hotEndDoneText = new TextWidget("Done!", textColor: theme.TextColor)
|
||||
{
|
||||
AutoExpandBoundsToText = true,
|
||||
Visible = false,
|
||||
};
|
||||
|
||||
hotEndProgressHolder.AddChild(hotEndDoneText);
|
||||
hotEndDoneTexts.Add(hotEndDoneText);
|
||||
|
||||
contentRow.AddChild(hotEndProgressHolder);
|
||||
}
|
||||
|
|
@ -224,20 +236,20 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
{
|
||||
if (targetHotendTemps[i] > 0)
|
||||
{
|
||||
hotEndProgressBar.Visible = true;
|
||||
hotEndProgressBars[i].Visible = true;
|
||||
double targetTemp = printer.Connection.GetTargetHotendTemperature(i);
|
||||
double actualTemp = printer.Connection.GetActualHotendTemperature(i);
|
||||
double totalDelta = targetTemp;
|
||||
double currentDelta = actualTemp;
|
||||
double ratioDone = hotEndDoneText.Visible ? 1 : totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
hotEndProgressBar.RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
hotEndProgressBarText.Text = $"{actualTemp:0} / {targetTemp:0}";
|
||||
double ratioDone = hotEndDoneTexts[i].Visible ? 1 : totalDelta != 0 ? (currentDelta / totalDelta) : 1;
|
||||
hotEndProgressBars[i].RatioComplete = Math.Min(Math.Max(0, ratioDone), 1);
|
||||
hotEndProgressBarTexts[i].Text = $"{actualTemp:0} / {targetTemp:0}";
|
||||
|
||||
// if we are within 1 degree of our target
|
||||
if (Math.Abs(targetTemp - actualTemp) < 2
|
||||
&& hotEndDoneText.Visible == false)
|
||||
&& hotEndDoneTexts[i].Visible == false)
|
||||
{
|
||||
hotEndDoneText.Visible = true;
|
||||
hotEndDoneTexts[i].Visible = true;
|
||||
NextButton.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -264,7 +276,7 @@ namespace MatterHackers.MatterControl.ConfigurationPage.PrintLeveling
|
|||
}
|
||||
|
||||
if ((bedTargetTemp == 0 || bedDoneText.Visible)
|
||||
&& (targetHotendTemps.All(i => i== 0) || hotEndDoneText.Visible)
|
||||
&& (targetHotendTemps.All(i => i== 0) || hotEndDoneTexts.All(i => i.Visible))
|
||||
&& !HasBeenClosed)
|
||||
{
|
||||
// advance to the next page
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue