fix servo not reattaching with same target (#1649)

This commit is contained in:
Guillermo Ruffino 2021-03-28 22:35:39 -03:00 committed by GitHub
parent 2028362fd5
commit ad76312f66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,6 +52,8 @@ void Servo::loop() {
void Servo::write(float value) { void Servo::write(float value) {
value = clamp(value, -1.0f, 1.0f); value = clamp(value, -1.0f, 1.0f);
if (this->target_value_ == value)
this->internal_write(value);
this->target_value_ = value; this->target_value_ = value;
this->source_value_ = this->current_value_; this->source_value_ = this->current_value_;
this->state_ = STATE_ATTACHED; this->state_ = STATE_ATTACHED;