File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -219,10 +219,10 @@ void SmartServoClass::synchronize() {
219219
220220 for (int i = MIN_MOTOR_ID; i <= MAX_MOTOR_ID; i++) {
221221 _txPacket.payload [index++] = i;
222- _txPacket.payload [index++] = _targetPosition[i- 1 ] >>8 ;
223- _txPacket.payload [index++] = _targetPosition[i- 1 ];
224- _txPacket.payload [index++] = _targetSpeed[i- 1 ]>>8 ;
225- _txPacket.payload [index++] = _targetSpeed[i- 1 ];
222+ _txPacket.payload [index++] = _targetPosition[idToArrayIndex (i) ] >>8 ;
223+ _txPacket.payload [index++] = _targetPosition[idToArrayIndex (i) ];
224+ _txPacket.payload [index++] = _targetSpeed[idToArrayIndex (i) ]>>8 ;
225+ _txPacket.payload [index++] = _targetSpeed[idToArrayIndex (i) ];
226226 }
227227 sendPacket ();
228228 mutex.unlock ();
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ class SmartServoClass
8989 static int constexpr MAX_MOTOR_ID = 6 ;
9090
9191 inline bool isValidId (int const id) const { return ((id >= MIN_MOTOR_ID) && (id <= MAX_MOTOR_ID)); }
92+ inline int idToArrayIndex (int const id) const { return (id - 1 ); }
9293
9394 int calcChecksum ();
9495 void sendPacket ();
You can’t perform that action at this time.
0 commit comments