Revise ATX Power submission from peter1960
This commit is contained in:
parent
a25be64859
commit
875bbb40b0
11 changed files with 204 additions and 1 deletions
|
|
@ -194,6 +194,7 @@
|
|||
<Compile Include="PrinterControls\ControlWidgets\ControlWidgetBase.cs" />
|
||||
<Compile Include="PrinterControls\ControlWidgets\FanControls.cs" />
|
||||
<Compile Include="PrinterControls\ControlWidgets\MovementControls.cs" />
|
||||
<Compile Include="PrinterControls\ControlWidgets\PowerControls.cs" />
|
||||
<Compile Include="PrinterControls\ControlWidgets\TemperatureControls.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -102,6 +102,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
public RootedObjectEventHandler WroteLine = new RootedObjectEventHandler();
|
||||
|
||||
public RootedObjectEventHandler AtxPowerStateChanged = new RootedObjectEventHandler();
|
||||
|
||||
private bool atxPowerIsOn = false;
|
||||
|
||||
private const int MAX_EXTRUDERS = 16;
|
||||
|
||||
private const int MAX_INVALID_CONNECTION_CHARS = 3;
|
||||
|
|
@ -274,6 +278,10 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
|
||||
WriteLineStartCallBacks.AddCallBackToKey("G90", MovementWasSetToAbsoluteMode);
|
||||
WriteLineStartCallBacks.AddCallBackToKey("G91", MovementWasSetToRelativeMode);
|
||||
|
||||
WriteLineStartCallBacks.AddCallBackToKey("M80", AtxPowerUpWasWritenToPrinter);
|
||||
WriteLineStartCallBacks.AddCallBackToKey("M81", AtxPowerDownWasWritenToPrinter);
|
||||
|
||||
}
|
||||
|
||||
private event EventHandler unregisterEvents;
|
||||
|
|
@ -482,6 +490,25 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
}
|
||||
|
||||
public bool AtxPowerEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return atxPowerIsOn;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("M80");
|
||||
}
|
||||
else
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.SendLineToPrinterNow("M81");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string ConnectionFailureMessage { get { return connectionFailureMessage; } }
|
||||
|
||||
public Vector3 CurrentDestination { get { return currentDestination; } }
|
||||
|
|
@ -2428,6 +2455,16 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
movementMode = PrinterMachineInstruction.MovementTypes.Relative;
|
||||
}
|
||||
|
||||
private void AtxPowerUpWasWritenToPrinter(object sender, EventArgs e)
|
||||
{
|
||||
OnAtxPowerStateChanged(true);
|
||||
}
|
||||
|
||||
private void AtxPowerDownWasWritenToPrinter(object sender, EventArgs e)
|
||||
{
|
||||
OnAtxPowerStateChanged(false);
|
||||
}
|
||||
|
||||
private void OnActivePrintItemChanged(EventArgs e)
|
||||
{
|
||||
ActivePrintItemChanged.CallEvents(this, e);
|
||||
|
|
@ -2487,6 +2524,12 @@ namespace MatterHackers.MatterControl.PrinterCommunication
|
|||
}
|
||||
}
|
||||
|
||||
private void OnAtxPowerStateChanged(bool enableAtxPower)
|
||||
{
|
||||
atxPowerIsOn = enableAtxPower;
|
||||
AtxPowerStateChanged.CallEvents(this, null);
|
||||
}
|
||||
|
||||
private void partToPrint_SliceDone(object sender, EventArgs e)
|
||||
{
|
||||
PrintItemWrapper partToPrint = sender as PrintItemWrapper;
|
||||
|
|
|
|||
118
PrinterControls/ControlWidgets/PowerControls.cs
Normal file
118
PrinterControls/ControlWidgets/PowerControls.cs
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
/*
|
||||
Copyright (c) 2014, Kevin Pope
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright notice, this
|
||||
list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
The views and conclusions contained in the software and documentation are those
|
||||
of the authors and should not be interpreted as representing official policies,
|
||||
either expressed or implied, of the FreeBSD Project.
|
||||
*/
|
||||
|
||||
using MatterHackers.Agg;
|
||||
using MatterHackers.Agg.UI;
|
||||
using MatterHackers.Localizations;
|
||||
using MatterHackers.MatterControl.PrinterCommunication;
|
||||
using MatterHackers.MatterControl.SlicerConfiguration;
|
||||
using System;
|
||||
|
||||
namespace MatterHackers.MatterControl.PrinterControls
|
||||
{
|
||||
public class PowerControls : ControlWidgetBase
|
||||
{
|
||||
private event EventHandler unregisterEvents;
|
||||
|
||||
private CheckBox atxPowertoggleSwitch;
|
||||
|
||||
public PowerControls()
|
||||
{
|
||||
ActiveSliceSettings.Instance.SettingsChanged.RegisterEvent(this.UpdateControlVisibility, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(this.UpdateControlVisibility, ref unregisterEvents);
|
||||
PrinterConnectionAndCommunication.Instance.AtxPowerStateChanged.RegisterEvent(this.UpdatePowerSwitch, ref unregisterEvents);
|
||||
|
||||
this.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
this.HAnchor = HAnchor.ParentLeftRight;
|
||||
this.VAnchor = VAnchor.ParentBottomTop;
|
||||
}
|
||||
|
||||
private void UpdateControlVisibility(object sender, EventArgs args)
|
||||
{
|
||||
this.Visible = ActiveSliceSettings.Instance.HasPowerControl;
|
||||
this.SetEnableLevel(PrinterConnectionAndCommunication.Instance.PrinterIsConnected ? EnableLevel.Enabled : EnableLevel.Disabled);
|
||||
}
|
||||
|
||||
private void UpdatePowerSwitch(object sender, EventArgs args)
|
||||
{
|
||||
this.atxPowertoggleSwitch.Checked = PrinterConnectionAndCommunication.Instance.AtxPowerEnabled;
|
||||
}
|
||||
|
||||
protected override void AddChildElements()
|
||||
{
|
||||
AltGroupBox fanControlsGroupBox = new AltGroupBox(new TextWidget("ATX Power Control".Localize(), pointSize: 18, textColor: ActiveTheme.Instance.SecondaryAccentColor));
|
||||
fanControlsGroupBox.Margin = new BorderDouble(0);
|
||||
fanControlsGroupBox.BorderColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
fanControlsGroupBox.HAnchor |= Agg.UI.HAnchor.ParentLeftRight;
|
||||
this.AddChild(fanControlsGroupBox);
|
||||
|
||||
atxPowertoggleSwitch = ImageButtonFactory.CreateToggleSwitch(false);
|
||||
atxPowertoggleSwitch.Margin = new BorderDouble(6, 0, 6, 6);
|
||||
atxPowertoggleSwitch.CheckedStateChanged += (sender, e) =>
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.AtxPowerEnabled = atxPowertoggleSwitch.Checked;
|
||||
};
|
||||
|
||||
FlowLayoutWidget paddingContainer = new FlowLayoutWidget();
|
||||
paddingContainer.Padding = new BorderDouble(3, 5, 3, 0) * TextWidget.GlobalPointSizeScaleRatio;
|
||||
{
|
||||
paddingContainer.AddChild(atxPowertoggleSwitch);
|
||||
}
|
||||
fanControlsGroupBox.AddChild(paddingContainer);
|
||||
|
||||
UpdateControlVisibility(null, null);
|
||||
}
|
||||
|
||||
private void SetDisplayAttributes()
|
||||
{
|
||||
this.textImageButtonFactory.normalFillColor = RGBA_Bytes.Transparent;
|
||||
|
||||
this.textImageButtonFactory.FixedWidth = 38 * TextWidget.GlobalPointSizeScaleRatio;
|
||||
this.textImageButtonFactory.FixedHeight = 20 * TextWidget.GlobalPointSizeScaleRatio;
|
||||
this.textImageButtonFactory.fontSize = 10;
|
||||
this.textImageButtonFactory.borderWidth = 1;
|
||||
this.textImageButtonFactory.normalBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
this.textImageButtonFactory.hoverBorderColor = new RGBA_Bytes(ActiveTheme.Instance.PrimaryTextColor, 200);
|
||||
|
||||
this.textImageButtonFactory.disabledTextColor = RGBA_Bytes.Gray;
|
||||
this.textImageButtonFactory.hoverTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
this.textImageButtonFactory.normalTextColor = ActiveTheme.Instance.SecondaryTextColor;
|
||||
this.textImageButtonFactory.pressedTextColor = ActiveTheme.Instance.PrimaryTextColor;
|
||||
}
|
||||
|
||||
public override void OnClosed(EventArgs e)
|
||||
{
|
||||
if (unregisterEvents != null)
|
||||
{
|
||||
unregisterEvents(this, null);
|
||||
}
|
||||
base.OnClosed(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -78,7 +78,14 @@ namespace MatterHackers.MatterControl
|
|||
|
||||
AddTemperatureControls(controlsTopToBottomLayout);
|
||||
AddMovementControls(controlsTopToBottomLayout);
|
||||
AddFanControls(controlsTopToBottomLayout);
|
||||
|
||||
FlowLayoutWidget linearPanel = new FlowLayoutWidget();
|
||||
linearPanel.HAnchor = Agg.UI.HAnchor.ParentLeftRight;
|
||||
controlsTopToBottomLayout.AddChild(linearPanel);
|
||||
|
||||
AddFanControls(linearPanel);
|
||||
AddAtxPowerControls(linearPanel);
|
||||
|
||||
AddMacroControls(controlsTopToBottomLayout);
|
||||
AddAdjustmentControls(controlsTopToBottomLayout);
|
||||
|
||||
|
|
@ -125,6 +132,11 @@ namespace MatterHackers.MatterControl
|
|||
}
|
||||
}
|
||||
|
||||
private void AddAtxPowerControls(FlowLayoutWidget controlsTopToBottomLayout)
|
||||
{
|
||||
controlsTopToBottomLayout.AddChild(new PowerControls());
|
||||
}
|
||||
|
||||
private void AddHandlers()
|
||||
{
|
||||
PrinterConnectionAndCommunication.Instance.CommunicationStateChanged.RegisterEvent(onPrinterStatusChanged, ref unregisterEvents);
|
||||
|
|
|
|||
|
|
@ -263,6 +263,17 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Control the PS_ON pin via M80/81 if enabled in firmware and printer settings, allowing the printer board to toggle off the ATX power supply
|
||||
/// </summary>
|
||||
public bool HasPowerControl
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetActiveValue("has_power_control") == "1";
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasHeatedBed()
|
||||
{
|
||||
return GetActiveValue("has_heated_bed") == "1";
|
||||
|
|
|
|||
|
|
@ -94,6 +94,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
new VisibleButNotMappedToEngine("", "bed_shape"),
|
||||
|
||||
new VisibleButNotMappedToEngine("", "has_fan"),
|
||||
new VisibleButNotMappedToEngine("", "has_power_control"),
|
||||
new VisibleButNotMappedToEngine("", "has_heated_bed"),
|
||||
new VisibleButNotMappedToEngine("", "has_hardware_leveling"),
|
||||
new VisibleButNotMappedToEngine("", "has_sd_card_reader"),
|
||||
|
|
|
|||
|
|
@ -209,6 +209,7 @@ namespace MatterHackers.MatterControl.SlicerConfiguration
|
|||
|
||||
new VisibleButNotMappedToEngine("", "has_fan"),
|
||||
new VisibleButNotMappedToEngine("", "has_hardware_leveling"),
|
||||
new VisibleButNotMappedToEngine("", "has_power_control"),
|
||||
new VisibleButNotMappedToEngine("", "has_heated_bed"),
|
||||
new VisibleButNotMappedToEngine("", "has_sd_card_reader"),
|
||||
new VisibleButNotMappedToEngine("", "z_can_be_negative"),
|
||||
|
|
|
|||
|
|
@ -51,6 +51,7 @@ gcode_output_type = REPRAP
|
|||
has_fan = 1
|
||||
has_hardware_leveling = 0
|
||||
has_heated_bed = 1
|
||||
has_power_control=0
|
||||
has_sd_card_reader = 0
|
||||
show_reset_connection = 0
|
||||
heat_extruder_before_homing = 0
|
||||
|
|
|
|||
|
|
@ -251,6 +251,7 @@ Advanced
|
|||
has_hardware_leveling
|
||||
has_heated_bed
|
||||
has_sd_card_reader
|
||||
has_power_control
|
||||
show_reset_connection
|
||||
extruder_count
|
||||
heat_extruder_before_homing
|
||||
|
|
|
|||
|
|
@ -406,6 +406,13 @@
|
|||
"DataEditType": "HARDWARE_PRESENT",
|
||||
"ExtraSettings": ""
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "has_power_control",
|
||||
"PresentationName": "Has Power Control",
|
||||
"HelpText": "Specify if your printer can control the power supply",
|
||||
"DataEditType": "HARDWARE_PRESENT",
|
||||
"ExtraSettings": ""
|
||||
},
|
||||
{
|
||||
"SlicerConfigName": "has_sd_card_reader",
|
||||
"PresentationName": "Has SD Card Reader",
|
||||
|
|
|
|||
|
|
@ -3196,4 +3196,11 @@ Translated:This will cause the extruder to try to wipe itself after retracting t
|
|||
|
||||
English:Calculating Positions...
|
||||
Translated:Calculating Positions...
|
||||
English:ATX Power Control
|
||||
Translated:ATX Power Control
|
||||
|
||||
English:Specify if your printer can control the power supply
|
||||
Translated:Specify if your printer can control the power supply
|
||||
|
||||
English:Has Power Control
|
||||
Translated:Has Power Control
|
||||
Loading…
Add table
Add a link
Reference in a new issue