diff options
-rw-r--r-- | src/Endstops/EndstopsManager.cpp | 40 | ||||
-rw-r--r-- | src/Endstops/EndstopsManager.h | 3 | ||||
-rw-r--r-- | src/Endstops/ZProbe.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodeMachineState.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes.cpp | 6 | ||||
-rw-r--r-- | src/GCodes/GCodes4.cpp | 2 | ||||
-rw-r--r-- | src/Movement/Move.cpp | 4 | ||||
-rw-r--r-- | src/Version.h | 4 |
8 files changed, 40 insertions, 23 deletions
diff --git a/src/Endstops/EndstopsManager.cpp b/src/Endstops/EndstopsManager.cpp index 7140902d..e7cae041 100644 --- a/src/Endstops/EndstopsManager.cpp +++ b/src/Endstops/EndstopsManager.cpp @@ -42,17 +42,16 @@ void EndstopsManager::Init() } #endif - // Z PROBE + // Z probes reprap.GetPlatform().InitZProbeFilters(); #if ALLOCATE_DEFAULT_PORTS LocalZProbe * const zp = new LocalZProbe(0); zp->AssignPorts(DefaultZProbePinNames, dummy.GetRef()); zProbes[0] = zp; -#else - zProbes[0] = new DummyZProbe(0); // we must always have a non-null Z probe #0 #endif + defaultZProbe = new DummyZProbe(0); // we must always have a non-null current Z probe so we use this one if none is defined currentZProbeNumber = 0; } @@ -353,6 +352,12 @@ const char *EndstopsManager::TranslateEndStopResult(EndStopHit es, bool atHighEn } } +ZProbe& EndstopsManager::GetCurrentZProbe() const +{ + ZProbe * const zp = zProbes[currentZProbeNumber]; + return (zp == nullptr) ? *defaultZProbe : *zp; +} + ZProbe *EndstopsManager::GetZProbe(size_t num) const { return (num < ARRAY_SIZE(zProbes)) ? zProbes[num] : nullptr; @@ -434,8 +439,8 @@ GCodeResult EndstopsManager::HandleM558(GCodeBuffer& gb, const StringRef &reply) // If we are switching between motor stall and any other type, we need a new one. A port must be specified unless it is motor stall. // If it not a motor stall probe and a port number is given, we need a new one in case it is on a different board. // If it is a motor stall endstop, there should not be a port specified, but we can ignore the port if it is present - uint32_t probeType = 0; - bool seenType; + uint32_t probeType = (uint32_t)ZProbeType::none; + bool seenType = false; gb.TryGetUIValue('P', probeType, seenType); if ( seenType && ( probeType >= (uint32_t)ZProbeType::numTypes @@ -452,17 +457,23 @@ GCodeResult EndstopsManager::HandleM558(GCodeBuffer& gb, const StringRef &reply) WriteLocker lock(endstopsLock); ZProbe * const existingProbe = zProbes[probeNumber]; - const bool seenPort = gb.Seen('C'); + if (existingProbe == nullptr && !seenType) + { + reply.printf("Z probe %u not found", probeNumber); + return GCodeResult::error; + } + const bool seenPort = gb.Seen('C'); const bool needNewProbe = (existingProbe == nullptr) - || (probeType != (uint32_t)existingProbe->GetProbeType() + || ( seenType + && probeType != (uint32_t)existingProbe->GetProbeType() && ( probeType == (uint32_t)ZProbeType::zMotorStall || probeType == (uint32_t)ZProbeType::none || existingProbe->GetProbeType() == ZProbeType::zMotorStall || existingProbe->GetProbeType() == ZProbeType::none ) ) - || (seenPort && probeType != (uint32_t)ZProbeType::zMotorStall && probeType != (uint32_t)ZProbeType::none); + || (seenPort && existingProbe->GetProbeType() != ZProbeType::zMotorStall && existingProbe->GetProbeType() != ZProbeType::none); if (needNewProbe) { @@ -472,6 +483,9 @@ GCodeResult EndstopsManager::HandleM558(GCodeBuffer& gb, const StringRef &reply) return GCodeResult::error; } + zProbes[probeNumber] = nullptr; + delete existingProbe; // delete the old probe first, the new one might use the same ports + ZProbe *newProbe; switch ((ZProbeType)probeType) { @@ -508,14 +522,16 @@ GCodeResult EndstopsManager::HandleM558(GCodeBuffer& gb, const StringRef &reply) break; } - const GCodeResult rslt = newProbe->Configure(gb, reply); - std::swap(zProbes[probeNumber], newProbe); - delete newProbe; + const GCodeResult rslt = newProbe->Configure(gb, reply, true); + if (rslt == GCodeResult::ok || rslt == GCodeResult::warning) + { + zProbes[probeNumber] = newProbe; + } return rslt; } // If we get get then there is an existing probe and we just need to change its configuration - return zProbes[probeNumber]->Configure(gb, reply); + return zProbes[probeNumber]->Configure(gb, reply, seenType); } // Set or print the Z probe. Called by G31. diff --git a/src/Endstops/EndstopsManager.h b/src/Endstops/EndstopsManager.h index 80cdab2a..8c6d3bd9 100644 --- a/src/Endstops/EndstopsManager.h +++ b/src/Endstops/EndstopsManager.h @@ -51,7 +51,7 @@ public: GCodeResult HandleM558(GCodeBuffer& gb, const StringRef &reply); // M558 GCodeResult HandleG31(GCodeBuffer& gb, const StringRef& reply); // G31 - ZProbe& GetCurrentZProbe() const { return *zProbes[currentZProbeNumber]; } + ZProbe& GetCurrentZProbe() const; ZProbe *GetZProbe(size_t num) const; void SetZProbeDefaults(); GCodeResult ProgramZProbe(GCodeBuffer& gb, const StringRef& reply); @@ -77,6 +77,7 @@ private: Endstop *axisEndstops[MaxAxes]; // the endstops assigned to each axis (each one may have several switches), each may be null ZProbe *zProbes[MaxZProbes]; // the Z probes used. The first one is always non-null. + ZProbe *defaultZProbe; ZProbeProgrammer zProbeProg; diff --git a/src/Endstops/ZProbe.cpp b/src/Endstops/ZProbe.cpp index 30ed6a4f..f1aa69c0 100644 --- a/src/Endstops/ZProbe.cpp +++ b/src/Endstops/ZProbe.cpp @@ -386,7 +386,7 @@ void LocalZProbe::SetProbing(bool isProbing) const GCodeResult LocalZProbe::AppendPinNames(const StringRef& str) const { - if (type != ZProbeType::zMotorStall) + if (type != ZProbeType::zMotorStall && type != ZProbeType::none) { str.cat(", input pin "); inputPort.AppendPinName(str); diff --git a/src/GCodes/GCodeMachineState.cpp b/src/GCodes/GCodeMachineState.cpp index 84291cdd..09893ad3 100644 --- a/src/GCodes/GCodeMachineState.cpp +++ b/src/GCodes/GCodeMachineState.cpp @@ -81,7 +81,7 @@ void GCodeMachineState::CloseFile() else #endif { -#if HAS_MAS_STORAGE +#if HAS_MASS_STORAGE fileState.Close(); #endif } diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index 26feb88c..e39c24e3 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -80,7 +80,7 @@ GCodes::GCodes(Platform& p) : powerFailScript(nullptr), #endif isFlashing(false), lastWarningMillis(0), atxPowerControlled(false) -#if HAS_MAS_STORAGE +#if HAS_MASS_STORAGE , sdTimingFile(nullptr) #endif { @@ -2487,9 +2487,9 @@ MessageType GCodes::GetMessageBoxDevice(GCodeBuffer& gb) const // Do a manual bed probe. On entry the state variable is the state we want to return to when the user has finished adjusting the height. void GCodes::DoManualProbe(GCodeBuffer& gb) { - if (Push(gb, true)) // stack the machine state including the file position + if (Push(gb, true)) // stack the machine state including the file position and set the state to GCodeState::normal { - gb.MachineState().CloseFile(); // stop reading from file + gb.MachineState().CloseFile(); // stop reading from file if we were gb.MachineState().waitingForAcknowledgement = true; // flag that we are waiting for acknowledgement const MessageType mt = GetMessageBoxDevice(gb); platform.SendAlert(mt, "Adjust height until the nozzle just touches the bed, then press OK", "Manual bed probing", 2, 0.0, MakeBitmap<AxesBitmap>(Z_AXIS)); diff --git a/src/GCodes/GCodes4.cpp b/src/GCodes/GCodes4.cpp index 34de830e..f4f7b794 100644 --- a/src/GCodes/GCodes4.cpp +++ b/src/GCodes/GCodes4.cpp @@ -926,7 +926,7 @@ void GCodes::RunStateMachine(GCodeBuffer& gb, const StringRef& reply) if (LockMovementAndWaitForStandstill(gb)) { // See whether we need to do any more taps - const ZProbe& params = platform.GetEndstops().GetCurrentZProbe(); + const ZProbe& params = platform.GetCurrentZProbe(); bool acceptReading = false; if (params.GetMaxTaps() < 2) { diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index b4e196e2..f0dce1ef 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -291,7 +291,7 @@ bool Move::IsRawMotorMove(uint8_t moveType) const // Return true if the specified point is accessible to the Z probe bool Move::IsAccessibleProbePoint(float x, float y) const { - const ZProbe& params = reprap.GetPlatform().GetEndstops().GetCurrentZProbe(); + const ZProbe& params = reprap.GetPlatform().GetCurrentZProbe(); return kinematics->IsReachable(x - params.GetXOffset(), y - params.GetYOffset(), false); } @@ -856,7 +856,7 @@ float Move::GetProbeCoordinates(int count, float& x, float& y, bool wantNozzlePo y = probePoints.GetYCoord(count); if (wantNozzlePosition) { - const ZProbe& rp = reprap.GetPlatform().GetEndstops().GetCurrentZProbe(); + const ZProbe& rp = reprap.GetPlatform().GetCurrentZProbe(); x -= rp.GetXOffset(); y -= rp.GetYOffset(); } diff --git a/src/Version.h b/src/Version.h index 45e8308b..f248c03e 100644 --- a/src/Version.h +++ b/src/Version.h @@ -10,7 +10,7 @@ #ifndef VERSION -# define MAIN_VERSION "3.0alpha" +# define MAIN_VERSION "3.0beta10" # ifdef USE_CAN0 # define VERSION_SUFFIX " (CAN0)" # else @@ -20,7 +20,7 @@ #endif #ifndef DATE -# define DATE "2019-09-11b2" +# define DATE "2019-09-12b1" #endif #define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman, printm3d" |