diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-09-15 11:36:03 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-09-15 11:36:03 +0300 |
commit | 6941819ed6cbce7a26e877fc118f0f8d40472901 (patch) | |
tree | a43b22cec434e62d30ae6aab3115f2f306944338 /src/Endstops/ZProbeEndstop.cpp | |
parent | 2b0ee17e0b5f32a936b2c6f3dafc37685673adbc (diff) |
Refactoring
Refactored endstop source files in preparation for supporting remote endstops on Duet 3
Diffstat (limited to 'src/Endstops/ZProbeEndstop.cpp')
-rw-r--r-- | src/Endstops/ZProbeEndstop.cpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/src/Endstops/ZProbeEndstop.cpp b/src/Endstops/ZProbeEndstop.cpp new file mode 100644 index 00000000..6bb55b60 --- /dev/null +++ b/src/Endstops/ZProbeEndstop.cpp @@ -0,0 +1,79 @@ +/* + * ZProbeEndstop.cpp + * + * Created on: 15 Sep 2019 + * Author: David + */ + +#include "ZProbeEndstop.h" + +#include "ZProbe.h" +#include "RepRap.h" +#include "Platform.h" +#include "Movement/Kinematics/Kinematics.h" + +// Z probe endstop +ZProbeEndstop::ZProbeEndstop(uint8_t axis, EndStopPosition pos) : Endstop(axis, pos), zProbeNumber(0) +{ +} + +// Test whether we are at or near the stop +EndStopHit ZProbeEndstop::Stopped() const +{ + const ZProbe * const zp = reprap.GetPlatform().GetEndstops().GetZProbe(zProbeNumber); + return (zp != nullptr) ? zp->Stopped() : EndStopHit::atStop; +} + +// This is called to prime axis endstops +void ZProbeEndstop::Prime(const Kinematics& kin, const AxisDriversConfig& axisDrivers) +{ + // Decide whether we stop just the driver, just the axis, or everything + stopAll = (kin.GetConnectedAxes(GetAxis()) & ~MakeBitmap<AxesBitmap>(GetAxis())) != 0; +} + +// Check whether the endstop is triggered and return the action that should be performed. Called from the step ISR. +EndstopHitDetails ZProbeEndstop::CheckTriggered(bool goingSlow) +{ + EndstopHitDetails rslt; // initialised by default constructor + switch (Stopped()) + { + case EndStopHit::atStop: + rslt.SetAction((stopAll) ? EndstopHitAction::stopAll : EndstopHitAction::stopAxis); + rslt.axis = GetAxis(); + if (GetAtHighEnd()) + { + rslt.setAxisHigh = true; + } + else + { + rslt.setAxisLow = true; + } + break; + + case EndStopHit::nearStop: + if (!goingSlow) + { + rslt.SetAction(EndstopHitAction::reduceSpeed); + } + break; + + default: + break; + } + return rslt; +} + +// This is called by the ISR to acknowledge that it is acting on the return from calling CheckTriggered. Called from the step ISR. +// Return true if we have finished with this endstop or probe in this move. +bool ZProbeEndstop::Acknowledge(EndstopHitDetails what) +{ + return what.GetAction() != EndstopHitAction::reduceSpeed; +} + +void ZProbeEndstop::AppendDetails(const StringRef& str) +{ + str.cat("Z probe"); +} + +// End + |