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() {
219
219
220
220
for (int i = MIN_MOTOR_ID; i <= MAX_MOTOR_ID; i++) {
221
221
_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) ];
226
226
}
227
227
sendPacket ();
228
228
mutex.unlock ();
Original file line number Diff line number Diff line change @@ -89,6 +89,7 @@ class SmartServoClass
89
89
static int constexpr MAX_MOTOR_ID = 6 ;
90
90
91
91
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 ); }
92
93
93
94
int calcChecksum ();
94
95
void sendPacket ();
You can’t perform that action at this time.
0 commit comments