Add check for PWM being ENABLED

This commit is contained in:
Henry Gabryjelski committed 2020-07-28 23:05:10 -07:00
1 parent 3efce16900
commit c58c01df68
2 files changed
+6 -1

No files matched your search

+4 -1
View File
@@ -108,7 +108,10 @@ void Servo::detach()
HardwarePWM * pwm = this->pwm;
this->pwm = nullptr;
pwm->removePin(pin);
pwm->releaseOwnership(_servoToken); // ignore failure ... which happens if a pin is still in use, for example
if (pwm->usedChannelCount() == 0) {
pwm->stop(); // disables peripheral so can release ownership
pwm->releaseOwnership(_servoToken);
}
}
void Servo::write(int value)