diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-11-06 16:31:18 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-11-06 16:31:18 +0300 |
commit | eebd32c8f7e40aaaef055e86eccbe166c741a70c (patch) | |
tree | b678c2e7ed1d52d2f4265175db4d00ea8e158537 /src/Platform/Platform.cpp | |
parent | 0feb1388fdc29c09e1183203a142f7f01a6a6c14 (diff) |
Removed default PS_ON (still version 3.4.0beta6)3.4.0beta6
Diffstat (limited to 'src/Platform/Platform.cpp')
-rw-r--r-- | src/Platform/Platform.cpp | 34 |
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(); |