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:
authorDavid Crocker <dcrocker@eschertech.com>2019-11-06 23:18:59 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-11-06 23:18:59 +0300
commit646ad6fd2b744492e03adf302c5c82d3cac878df (patch)
tree817083939e72c2173a00e9afc0d090ba8a226753 /src/Endstops/SwitchEndstop.h
parente9a0acd03ee8930e210dcdf5281d5f90e5733a47 (diff)
More work on remote endstops + enabled MPU
Remote endstops now working properly M950 H# C"nil" now deletes a heater and doesn;t require a sensor number MPU is now enabled M574 report includes remote endstop pin names
Diffstat (limited to 'src/Endstops/SwitchEndstop.h')
-rw-r--r--src/Endstops/SwitchEndstop.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/Endstops/SwitchEndstop.h b/src/Endstops/SwitchEndstop.h
new file mode 100644
index 00000000..480aed8d
--- /dev/null
+++ b/src/Endstops/SwitchEndstop.h
@@ -0,0 +1,71 @@
+/*
+ * LocalSwitchEndstop.h
+ *
+ * Created on: 15 Sep 2019
+ * Author: David
+ */
+
+#ifndef SRC_ENDSTOPS_SWITCHENDSTOP_H_
+#define SRC_ENDSTOPS_SWITCHENDSTOP_H_
+
+#include "Endstop.h"
+
+#include "GCodes/GCodeResult.h"
+
+// Switch-type endstop, either on the main board or on a CAN-connected board
+class SwitchEndstop : public Endstop
+{
+public:
+ void* operator new(size_t sz) { return Allocate<SwitchEndstop>(); }
+ void operator delete(void* p) { Release<SwitchEndstop>(p); }
+ ~SwitchEndstop() override;
+
+ SwitchEndstop(uint8_t axis, EndStopPosition pos);
+
+ EndStopInputType GetEndstopType() const override;
+ EndStopHit Stopped() const override;
+ void Prime(const Kinematics& kin, const AxisDriversConfig& axisDrivers) override;
+ EndstopHitDetails CheckTriggered(bool goingSlow) override;
+ bool Acknowledge(EndstopHitDetails what) override;
+ void AppendDetails(const StringRef& str) override;
+
+#if SUPPORT_CAN_EXPANSION
+ // Process a remote endstop input change that relates to this endstop. Return true if the buffer has been freed.
+ void HandleRemoteInputChange(CanAddress src, uint8_t handleMinor, bool state) override;
+#endif
+
+ GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, EndStopInputType inputType);
+ GCodeResult Configure(const char *pinNames, const StringRef& reply, EndStopInputType inputType);
+ void Reconfigure(EndStopPosition pos, EndStopInputType inputType);
+
+private:
+ typedef uint16_t PortsBitmap;
+
+ void ReleasePorts();
+
+ inline bool IsTriggered(size_t index) const
+ {
+#if SUPPORT_CAN_EXPANSION
+ return (boardNumbers[index] == CanId::MasterAddress) ? ports[index].Read() : states[index] != activeLow;
+#else
+ return ports[index].Read();
+#endif
+ }
+
+#if SUPPORT_CAN_EXPANSION
+ static constexpr uint16_t MinimumSwitchReportInterval = 30;
+#endif
+
+ IoPort ports[MaxDriversPerAxis];
+#if SUPPORT_CAN_EXPANSION
+ CanAddress boardNumbers[MaxDriversPerAxis];
+ bool states[MaxDriversPerAxis];
+ bool activeLow;
+#endif
+ size_t numPortsUsed;
+ PortsBitmap portsLeftToTrigger;
+ size_t numPortsLeftToTrigger;
+ bool stopAll;
+};
+
+#endif /* SRC_ENDSTOPS_SWITCHENDSTOP_H_ */