Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Platform/Platform.cpp')
-rw-r--r--src/Platform/Platform.cpp34
1 files changed, 19 insertions, 15 deletions
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index 9d935855..293f4038 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -425,7 +425,6 @@ Platform::Platform() noexcept :
#if SUPPORT_LASER
lastLaserPwm(0.0),
#endif
- atxPowerControlled(false),
deferredPowerDown(false)
{
}
@@ -509,12 +508,6 @@ void Platform::Init() noexcept
BoardConfig::Init();
#endif
-#if HAS_DEFAULT_PSON_PIN
- // Set up the default PS_ON port. Initialise it to off in case it is being used for something else or is inverted.
- String<1> dummy;
- PsOnPort.AssignPort("pson", dummy.GetRef(), PinUsedBy::gpout, PinAccess::write0);
-#endif
-
// Ethernet networking defaults
ipAddress = DefaultIpAddress;
netMask = DefaultNetMask;
@@ -3654,12 +3647,10 @@ GCodeResult Platform::HandleM80(GCodeBuffer& gb, const StringRef& reply) THROWS(
if (gb.Seen('C'))
{
rslt = GetGCodeResultFromSuccess(PsOnPort.AssignPort(gb, reply, PinUsedBy::gpout, PinAccess::write1));
- atxPowerControlled = PsOnPort.IsValid();
}
else if (PsOnPort.IsValid())
{
PsOnPort.WriteDigital(true);
- atxPowerControlled = true;
rslt = GCodeResult::ok;
}
else
@@ -3674,14 +3665,27 @@ GCodeResult Platform::HandleM80(GCodeBuffer& gb, const StringRef& reply) THROWS(
GCodeResult Platform::HandleM81(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException)
{
- deferredPowerDown = gb.Seen('S') && gb.GetUIValue() != 0;
- atxPowerControlled = true; // set this before calling AtxPowerOff
- if (!deferredPowerDown)
+ GCodeResult rslt;
+ if (gb.Seen('C'))
{
- AtxPowerOff();
+ rslt = GetGCodeResultFromSuccess(PsOnPort.AssignPort(gb, reply, PinUsedBy::gpout, PinAccess::write0));
+ }
+ else if (PsOnPort.IsValid())
+ {
+ deferredPowerDown = gb.Seen('S') && gb.GetUIValue() != 0;
+ if (!deferredPowerDown)
+ {
+ AtxPowerOff();
+ }
+ rslt = GCodeResult::ok;
+ }
+ else
+ {
+ reply.copy("No PS_ON port defined");
+ rslt = GCodeResult::error;
}
reprap.StateUpdated();
- return GCodeResult::ok;
+ return rslt;
}
void Platform::AtxPowerOff() noexcept
@@ -3696,7 +3700,7 @@ void Platform::AtxPowerOff() noexcept
#endif
// The PS_ON pin on Duet 3 is shared with another pin, so only try to turn off ATX power if we know that power is being controlled
- if (atxPowerControlled)
+ if (IsAtxPowerControlled())
{
PsOnPort.WriteDigital(false);
reprap.StateUpdated();