diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-03-21 22:21:42 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-03-21 22:21:42 +0300 |
commit | cd9bc0fdeb517c18026c8c5384ee0d04d96553fc (patch) | |
tree | 1751634ff8df267040621748794d09c17d3a762e /src/Fans | |
parent | ac1f14646c32803521ce0ce135b1c9c2b869e340 (diff) |
G30 and G28 now accept a K parameter for the Z probe number
Diffstat (limited to 'src/Fans')
-rw-r--r-- | src/Fans/FansManager.cpp | 87 | ||||
-rw-r--r-- | src/Fans/FansManager.h | 4 |
2 files changed, 43 insertions, 48 deletions
diff --git a/src/Fans/FansManager.cpp b/src/Fans/FansManager.cpp index 84b0ceac..31390b21 100644 --- a/src/Fans/FansManager.cpp +++ b/src/Fans/FansManager.cpp @@ -91,65 +91,60 @@ bool FansManager::WriteFanSettings(FileStore *f) const noexcept #endif // This is called by M950 to create a fan or change its PWM frequency -GCodeResult FansManager::ConfigureFanPort(uint32_t fanNum, GCodeBuffer& gb, const StringRef& reply) +GCodeResult FansManager::ConfigureFanPort(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException) { - if (fanNum < MaxFans) + const uint32_t fanNum = gb.GetLimitedUIValue('F', MaxFans); + const bool seenPin = gb.Seen('C'); + if (seenPin) { - const bool seenPin = gb.Seen('C'); - if (seenPin) - { - String<StringLength50> pinName; - gb.GetReducedString(pinName.GetRef()); + String<StringLength50> pinName; + gb.GetReducedString(pinName.GetRef()); - WriteLocker lock(fansLock); + WriteLocker lock(fansLock); - Fan *oldFan = nullptr; - std::swap<Fan*>(oldFan, fans[fanNum]); - delete oldFan; + Fan *oldFan = nullptr; + std::swap<Fan*>(oldFan, fans[fanNum]); + delete oldFan; - const PwmFrequency freq = (gb.Seen('Q')) ? gb.GetPwmFrequency() : DefaultFanPwmFreq; + const PwmFrequency freq = (gb.Seen('Q')) ? gb.GetPwmFrequency() : DefaultFanPwmFreq; #if SUPPORT_CAN_EXPANSION - const CanAddress board = IoPort::RemoveBoardAddress(pinName.GetRef()); - if (board != CanId::MasterAddress) + const CanAddress board = IoPort::RemoveBoardAddress(pinName.GetRef()); + if (board != CanId::MasterAddress) + { + auto *newFan = new RemoteFan(fanNum, board); + const GCodeResult rslt = newFan->ConfigurePort(pinName.c_str(), freq, reply); + if (rslt == GCodeResult::ok) { - auto *newFan = new RemoteFan(fanNum, board); - const GCodeResult rslt = newFan->ConfigurePort(pinName.c_str(), freq, reply); - if (rslt == GCodeResult::ok) - { - fans[fanNum] = newFan; - } - else - { - delete newFan; - } - return rslt; + fans[fanNum] = newFan; + } + else + { + delete newFan; } -#endif - fans[fanNum] = CreateLocalFan(fanNum, pinName.c_str(), freq, reply); - reprap.FansUpdated(); - return (fans[fanNum] == nullptr) ? GCodeResult::error : GCodeResult::ok; - } - - const auto fan = FindFan(fanNum); - if (fan.IsNull()) - { - reply.printf("Fan %u does not exist", (unsigned int)fanNum); - return GCodeResult::error; - } - - if (gb.Seen('Q')) - { - const GCodeResult rslt = fan->SetPwmFrequency(gb.GetPwmFrequency(), reply); - reprap.FansUpdated(); return rslt; } +#endif + fans[fanNum] = CreateLocalFan(fanNum, pinName.c_str(), freq, reply); + reprap.FansUpdated(); + return (fans[fanNum] == nullptr) ? GCodeResult::error : GCodeResult::ok; + } - return fan->ReportPortDetails(reply); + const auto fan = FindFan(fanNum); + if (fan.IsNull()) + { + reply.printf("Fan %u does not exist", (unsigned int)fanNum); + return GCodeResult::error; } - reply.copy("Fan number out of range"); - return GCodeResult::error; + if (gb.Seen('Q')) + { + const GCodeResult rslt = fan->SetPwmFrequency(gb.GetPwmFrequency(), reply); + reprap.FansUpdated(); + return rslt; + } + + return fan->ReportPortDetails(reply); } // Set or report the parameters for the specified fan @@ -157,7 +152,7 @@ GCodeResult FansManager::ConfigureFanPort(uint32_t fanNum, GCodeBuffer& gb, cons // then search for parameters used to configure the fan. If any are found, perform appropriate actions and return true. // If errors were discovered while processing parameters, put an appropriate error message in 'reply' and set 'error' to true. // If no relevant parameters are found, print the existing ones to 'reply' and return false. -bool FansManager::ConfigureFan(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const StringRef& reply, bool& error) +bool FansManager::ConfigureFan(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const StringRef& reply, bool& error) THROWS(GCodeException) { auto fan = FindFan(fanNum); if (fan.IsNull()) diff --git a/src/Fans/FansManager.h b/src/Fans/FansManager.h index b38986db..c0813f22 100644 --- a/src/Fans/FansManager.h +++ b/src/Fans/FansManager.h @@ -29,8 +29,8 @@ public: void Init() noexcept; bool CheckFans() noexcept; - GCodeResult ConfigureFanPort(uint32_t fanNum, GCodeBuffer& gb, const StringRef& reply); - bool ConfigureFan(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const StringRef& reply, bool& error); + GCodeResult ConfigureFanPort(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); + bool ConfigureFan(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const StringRef& reply, bool& error) THROWS(GCodeException); float GetFanValue(size_t fanNum) const noexcept; GCodeResult SetFanValue(size_t fanNum, float speed, const StringRef& reply) noexcept; void SetFanValue(size_t fanNum, float speed) noexcept; |