diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-09-14 22:41:21 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-09-14 22:41:21 +0300 |
commit | 2b0ee17e0b5f32a936b2c6f3dafc37685673adbc (patch) | |
tree | 2159fd7209bb53683559ec062b417e3465efed69 /src/Endstops/ZProbe.h | |
parent | 7340676a46146d3581855aa1294c5dff18d8e48b (diff) |
More work on remote Z probe support
Diffstat (limited to 'src/Endstops/ZProbe.h')
-rw-r--r-- | src/Endstops/ZProbe.h | 96 |
1 files changed, 21 insertions, 75 deletions
diff --git a/src/Endstops/ZProbe.h b/src/Endstops/ZProbe.h index 0e7c10f4..58b486ea 100644 --- a/src/Endstops/ZProbe.h +++ b/src/Endstops/ZProbe.h @@ -17,11 +17,11 @@ public: ZProbe(unsigned int num, ZProbeType p_type); virtual void SetIREmitter(bool on) const = 0; - virtual void SetProgramOutput(bool b) const = 0; virtual uint16_t GetRawReading() const = 0; virtual void SetProbing(bool isProbing) const = 0; virtual GCodeResult AppendPinNames(const StringRef& str) const = 0; - virtual GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool dontReport = false); + virtual GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& seen); // 'seen' is an in-out parameter + virtual GCodeResult SendProgram(const uint32_t zProbeProgram[], size_t len, const StringRef& reply); EndStopHit Stopped() const override; EndstopHitDetails CheckTriggered(bool goingSlow) override; @@ -40,17 +40,17 @@ public: float GetTravelSpeed() const { return travelSpeed; } float GetRecoveryTime() const { return recoveryTime; } float GetTolerance() const { return tolerance; } - bool GetTurnHeatersOff() const { return turnHeatersOff; } - bool GetSaveToConfigOverride() const { return saveToConfigOverride; } + bool GetTurnHeatersOff() const { return misc.parts.turnHeatersOff; } + bool GetSaveToConfigOverride() const { return misc.parts.saveToConfigOverride; } int GetAdcValue() const { return adcValue; } - unsigned int GetMaxTaps() const { return maxTaps; } + unsigned int GetMaxTaps() const { return misc.parts.maxTaps; } int GetReading() const; int GetSecondaryValues(int& v1, int& v2); GCodeResult HandleG31(GCodeBuffer& gb, const StringRef& reply); void SetTriggerHeight(float height) { triggerHeight = height; } - void SetSaveToConfigOverride() { saveToConfigOverride = true; } + void SetSaveToConfigOverride() { misc.parts.saveToConfigOverride = true; } #if HAS_MASS_STORAGE bool WriteParameters(FileStore *f, unsigned int probeNumber) const; @@ -59,7 +59,21 @@ public: static constexpr unsigned int MaxTapsLimit = 31; // must be low enough to fit in the maxTaps field protected: - unsigned int number; + uint8_t number; + ZProbeType type; + int8_t sensor; // the sensor number used for temperature calibration + int16_t adcValue; // the target ADC value, after inversion if enabled + union + { + struct + { + uint16_t maxTaps : 5, // maximum probes at each point + invertReading : 1, // true if we need to invert the reading + turnHeatersOff : 1, // true to turn heaters off while probing + saveToConfigOverride : 1; // true if the trigger height should be saved to config-override.g + } parts; + uint16_t all; + } misc; float xOffset, yOffset; // the offset of the probe relative to the print head float triggerHeight; // the nozzle height at which the target ADC value is returned float calibTemperature; // the temperature at which we did the calibration @@ -69,51 +83,8 @@ protected: float travelSpeed; // the speed at which we travel to the probe point float recoveryTime; // Z probe recovery time float tolerance; // maximum difference between probe heights when doing >1 taps - int16_t adcValue; // the target ADC value, after inversion if enabled - uint16_t maxTaps : 5, // maximum probes at each point - invertReading : 1, // true if we need to invert the reading - turnHeatersOff : 1, // true to turn heaters off while probing - saveToConfigOverride : 1; // true if the trigger height should be saved to config-override.g - ZProbeType type; - int sensor; // the sensor number used for temperature calibration }; -class LocalZProbe final : public ZProbe -{ -public: - void* operator new(size_t sz) { return Allocate<LocalZProbe>(); } - void operator delete(void* p) { Release<LocalZProbe>(p); } - - LocalZProbe(unsigned int num) : ZProbe(num, ZProbeType::none) { } - ~LocalZProbe() override; - void SetIREmitter(bool on) const override; - void SetProgramOutput(bool b) const override; - uint16_t GetRawReading() const override; - void SetProbing(bool isProbing) const override; - GCodeResult AppendPinNames(const StringRef& str) const override; - GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool dontReport) override; - - bool AssignPorts(const char *pinNames, const StringRef& reply); - -private: - IoPort inputPort; - IoPort modulationPort; // the modulation port we are using -}; - -// If this is a dumb modulated IR probe, set the IR LED on or off. Called from the tick ISR, so inlined for speed. -inline void LocalZProbe::SetIREmitter(bool on) const -{ - if (type == ZProbeType::dumbModulated) - { - modulationPort.WriteDigital(on); - } -} - -inline void LocalZProbe::SetProgramOutput(bool b) const -{ - modulationPort.WriteDigital(b); -} - // MotorStall Z probes have no port, also in a CAN environment the local and remote proxy versions are the same class MotorStallZProbe final : public ZProbe { @@ -124,7 +95,6 @@ public: MotorStallZProbe(unsigned int num) : ZProbe(num, ZProbeType::zMotorStall) { } ~MotorStallZProbe() override { } void SetIREmitter(bool on) const override { } - void SetProgramOutput(bool b) const override { } uint16_t GetRawReading() const override { return 4000; } void SetProbing(bool isProbing) const override { } GCodeResult AppendPinNames(const StringRef& str) const override { return GCodeResult::ok; } @@ -142,7 +112,6 @@ public: DummyZProbe(unsigned int num) : ZProbe(num, ZProbeType::none) { } ~DummyZProbe() override { } void SetIREmitter(bool on) const override { } - void SetProgramOutput(bool b) const override { } uint16_t GetRawReading() const override { return 4000; } void SetProbing(bool isProbing) const override { } GCodeResult AppendPinNames(const StringRef& str) const override { return GCodeResult::ok; } @@ -150,27 +119,4 @@ public: private: }; -#if SUPPORT_CAN_EXPANSION - -class RemoteZProbe final : public ZProbe -{ -public: - void* operator new(size_t sz) { return Allocate<RemoteZProbe>(); } - void operator delete(void* p) { Release<RemoteZProbe>(p); } - - RemoteZProbe(unsigned int num, CanAddress bn) : ZProbe(num, ZProbeType::none), boardNumber(bn) { } - ~RemoteZProbe() override; - void SetIREmitter(bool on) const override { } - void SetProgramOutput(bool b) const override; - uint16_t GetRawReading() const override { return 0; } - void SetProbing(bool isProbing) const override; - GCodeResult AppendPinNames(const StringRef& str) const override; - GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool dontReport) override; - -private: - CanAddress boardNumber; -}; - -#endif - #endif /* SRC_ZPROBE_H_ */ |