diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-04-30 16:56:48 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-04-30 16:56:48 +0300 |
commit | aae6ef4c8844dc7a94208ef7e0f6cca2cbc3c206 (patch) | |
tree | d2f089e1ba383384528183786544018450be3b2d | |
parent | 500c6eb865dcb1cc246874da5c187424ffc5dc51 (diff) |
Bug fixes to triggers, still 3.01-RC113.01-RC11
-rw-r--r-- | src/GCodes/Trigger.cpp | 59 | ||||
-rw-r--r-- | src/Platform.cpp | 12 | ||||
-rw-r--r-- | src/Version.h | 2 |
3 files changed, 55 insertions, 18 deletions
diff --git a/src/GCodes/Trigger.cpp b/src/GCodes/Trigger.cpp index 883d237b..991b3101 100644 --- a/src/GCodes/Trigger.cpp +++ b/src/GCodes/Trigger.cpp @@ -44,10 +44,21 @@ bool Trigger::Check() noexcept const bool stopped = (endstops.Stopped(axis) == EndStopHit::atStop); if (stopped != endstopStates.IsBitSet(axis)) { - endstopStates.SetOrClearBit(axis, stopped); - if (stopped == highLevelEndstops.IsBitSet(axis)) + if (stopped) { - triggered = true; + endstopStates.SetBit(axis); + if (highLevelEndstops.IsBitSet(axis)) + { + triggered = true; + } + } + else + { + endstopStates.ClearBit(axis); + if (lowLevelEndstops.IsBitSet(axis)) + { + triggered = true; + } } } } @@ -60,11 +71,23 @@ bool Trigger::Check() noexcept const bool isActive = reprap.GetPlatform().GetGpInPort(inPort).GetState(); if (isActive != inputStates.IsBitSet(inPort)) { - inputStates.SetOrClearBit(inPort, isActive); - if (isActive == highLevelInputs.IsBitSet(inPort)) + if (isActive) { - triggered = true; + inputStates.SetBit(inPort); + if (highLevelInputs.IsBitSet(inPort)) + { + triggered = true; + } } + else + { + inputStates.ClearBit(inPort); + if (lowLevelInputs.IsBitSet(inPort)) + { + triggered = true; + } + } + } } ); @@ -76,7 +99,7 @@ bool Trigger::Check() noexcept GCodeResult Trigger::Configure(unsigned int number, GCodeBuffer &gb, const StringRef &reply) { bool seen = false; - if (gb.Seen('C')) + if (gb.Seen('R')) { seen = true; condition = gb.GetIValue(); @@ -102,9 +125,18 @@ GCodeResult Trigger::Configure(unsigned int number, GCodeBuffer &gb, const Strin size_t numValues = MaxGpInPorts; gb.GetUnsignedArray(inputNumbers, numValues, false); const InputPortsBitmap portsToWaitFor = InputPortsBitmap::MakeFromArray(inputNumbers, numValues); - ((sParam >= 1) ? highLevelInputs : lowLevelInputs) |= portsToWaitFor; + if (sParam < 0) + { + highLevelInputs &= ~portsToWaitFor; + lowLevelInputs &= ~portsToWaitFor; + } + else + { + ((sParam >= 1) ? highLevelInputs : lowLevelInputs) |= portsToWaitFor; + } } } + AxesBitmap endstopsToWaitFor; for (size_t axis = 0; axis < reprap.GetGCodes().GetTotalAxes(); ++axis) { @@ -115,8 +147,15 @@ GCodeResult Trigger::Configure(unsigned int number, GCodeBuffer &gb, const Strin } } - ((sParam >= 1) ?highLevelEndstops : lowLevelEndstops) |= endstopsToWaitFor; - + if (sParam < 0) + { + highLevelEndstops &= ~endstopsToWaitFor; + lowLevelEndstops &= ~endstopsToWaitFor; + } + else + { + ((sParam >= 1) ? highLevelEndstops : lowLevelEndstops) |= endstopsToWaitFor; + } inputStates.Clear(); (void)Check(); // set up initial input states diff --git a/src/Platform.cpp b/src/Platform.cpp index 0fd7a693..b150a215 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -882,8 +882,10 @@ void Platform::Exit() noexcept // Stop processing data. Don't try to send a message because it will probably never get there. active = false; - // Close down USB and serial ports + // Close down USB and serial ports and release output buffers SERIAL_MAIN_DEVICE.end(); + usbOutput.ReleaseAll(); + #ifdef SERIAL_AUX_DEVICE # ifdef DUET3 if (auxEnabled) @@ -891,15 +893,11 @@ void Platform::Exit() noexcept { SERIAL_AUX_DEVICE.end(); } -#endif -#ifdef SERIAL_AUX2_DEVICE - SERIAL_AUX2_DEVICE.end(); + auxOutput.ReleaseAll(); #endif - // Release all output buffers - usbOutput.ReleaseAll(); - auxOutput.ReleaseAll(); #ifdef SERIAL_AUX2_DEVICE + SERIAL_AUX2_DEVICE.end(); aux2Output.ReleaseAll(); #endif diff --git a/src/Version.h b/src/Version.h index 65503398..6ed997e4 100644 --- a/src/Version.h +++ b/src/Version.h @@ -19,7 +19,7 @@ #endif #ifndef DATE -# define DATE "2020-04-30b1" +# define DATE "2020-04-30b3" #endif #define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman, printm3d" |