diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-06-28 15:39:43 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-06-28 15:39:43 +0300 |
commit | 4872582d0c6f26fbf513e058ab5f26a06ccf7c50 (patch) | |
tree | e0fdb2f59dc9b6f7cfa7554c73e44b07de362ca5 /src/Endstops/ZProbe.cpp | |
parent | 7bbdec319e0b0be2a8c282b0df90ebca59cded14 (diff) |
Don't abort processing G31 if we can't process the temp coefficients
Diffstat (limited to 'src/Endstops/ZProbe.cpp')
-rw-r--r-- | src/Endstops/ZProbe.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/src/Endstops/ZProbe.cpp b/src/Endstops/ZProbe.cpp index c9693168..47fa542f 100644 --- a/src/Endstops/ZProbe.cpp +++ b/src/Endstops/ZProbe.cpp @@ -280,39 +280,41 @@ GCodeResult ZProbe::HandleG31(GCodeBuffer& gb, const StringRef& reply) THROWS(GC const float currentTemperature = reprap.GetHeat().GetSensorTemperature(newSensor, terr); if (terr == TemperatureError::unknownSensor) { - reply.printf("Cannot set a temperature coefficient with invalid sensor number %d", newSensor); - return GCodeResult::error; - } - - size_t numValues = ARRAY_SIZE(temperatureCoefficients); - gb.GetFloatArray(temperatureCoefficients, numValues, false); - float newCalibTemperature = DefaultZProbeTemperature; - - if (gb.Seen('S')) - { - newCalibTemperature = gb.GetFValue(); - } - else if (terr == TemperatureError::success) - { - newCalibTemperature = currentTemperature; - } - else if (!gb.IsTimerRunning()) // the sensor may have only just been configured, so give it 500ms to produce a reading - { - gb.StartTimer(); - return GCodeResult::notFinished; - } - else if (millis() - gb.WhenTimerStarted() < 500) - { - return GCodeResult::notFinished; + reply.printf("Temperature coefficients ignored due to invalid sensor number %d", newSensor); + err = GCodeResult::warning; } else { + size_t numValues = ARRAY_SIZE(temperatureCoefficients); + gb.GetFloatArray(temperatureCoefficients, numValues, false); + float newCalibTemperature = DefaultZProbeTemperature; + + if (gb.Seen('S')) + { + newCalibTemperature = gb.GetFValue(); + } + else if (terr == TemperatureError::success) + { + newCalibTemperature = currentTemperature; + } + else if (!gb.IsTimerRunning()) // the sensor may have only just been configured, so give it 500ms to produce a reading + { + gb.StartTimer(); + return GCodeResult::notFinished; + } + else if (millis() - gb.WhenTimerStarted() < 500) + { + return GCodeResult::notFinished; + } + else + { + gb.StopTimer(); + reply.printf("Sensor %d did not provide a valid temperature reading, using default", newSensor); + err = GCodeResult::warning; + } gb.StopTimer(); - reply.printf("Sensor %d did not provide a valid temperature reading", newSensor); - err = GCodeResult::error; + calibTemperature = newCalibTemperature; } - gb.StopTimer(); - calibTemperature = newCalibTemperature; } // After this we don't return notFinished, so it is safe to amend values directly |