Skip to content

Commit 7acbf71

Browse files
committed
Only update position array when we are in synched mode (otherwise this variable is not needed).
1 parent 99242d9 commit 7acbf71

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/lib/motors/SmartServo.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,13 +236,15 @@ void SmartServoClass::setPosition(uint8_t const id, float const angle)
236236
Serial.println(msg);
237237
}
238238

239-
_targetPosition[idToArrayIndex(id)] = target_position_deg;
240-
241239
if (_positionMode == PositionMode::IMMEDIATE)
242240
{
243241
mbed::ScopedLock<rtos::Mutex> lock(_mtx);
244242
writeWordCmd(id, REG(SmartServoRegister::TARGET_POSITION_H), target_position_deg);
245243
}
244+
else if (_positionMode == PositionMode::SYNC)
245+
{
246+
_targetPosition[idToArrayIndex(id)] = target_position_deg;
247+
}
246248
}
247249

248250
float SmartServoClass::getPosition(uint8_t const id)

0 commit comments

Comments
 (0)