File tree Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Expand file tree Collapse file tree 3 files changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -185,7 +185,7 @@ void BraccioClass::pingOff()
185
185
bool BraccioClass::connected (int const id)
186
186
{
187
187
mbed::ScopedLock<rtos::Mutex> lock (_motors_connected_mtx);
188
- return _is_motor_connected[id ];
188
+ return _is_motor_connected[SmartServoClass::idToArrayIndex (id) ];
189
189
}
190
190
191
191
MotorsWrapper BraccioClass::move (int const id)
@@ -323,7 +323,7 @@ bool BraccioClass::isPingAllowed()
323
323
void BraccioClass::setMotorConnectionStatus (int const id, bool const is_connected)
324
324
{
325
325
mbed::ScopedLock<rtos::Mutex> lock (_motors_connected_mtx);
326
- _is_motor_connected[id ] = is_connected;
326
+ _is_motor_connected[SmartServoClass::idToArrayIndex (id) ] = is_connected;
327
327
}
328
328
329
329
void BraccioClass::motorConnectedThreadFunc ()
Original file line number Diff line number Diff line change @@ -114,7 +114,7 @@ class BraccioClass
114
114
void display_thread_func ();
115
115
116
116
bool _is_ping_allowed;
117
- bool _is_motor_connected[8 ];
117
+ bool _is_motor_connected[SmartServoClass::NUM_MOTORS ];
118
118
rtos::Mutex _motors_connected_mtx;
119
119
rtos::Thread _motors_connected_thd;
120
120
bool isPingAllowed ();
Original file line number Diff line number Diff line change @@ -74,18 +74,19 @@ class SmartServoClass
74
74
static int constexpr BROADCAST = 0xFE ;
75
75
static int constexpr MIN_MOTOR_ID = 1 ;
76
76
static int constexpr MAX_MOTOR_ID = 6 ;
77
+ static int constexpr NUM_MOTORS = 6 ;
77
78
static float constexpr MAX_ANGLE = 315 .0f ;
78
79
80
+ static int idToArrayIndex (int const id) { return (id - 1 ); }
81
+
79
82
private:
80
83
81
- static int constexpr NUM_MOTORS = 6 ;
82
84
static int constexpr MAX_TX_PAYLOAD_LEN = (5 *NUM_MOTORS+4 );
83
85
static int constexpr MAX_RX_PAYLOAD_LEN = 10 ;
84
86
static int constexpr MAX_POSITION = 4000 ;
85
87
86
88
inline bool isValidAngle (float const angle) { return ((angle >= 0 .0f ) && (angle <= MAX_ANGLE)); }
87
89
inline bool isValidId (int const id) const { return ((id >= MIN_MOTOR_ID) && (id <= MAX_MOTOR_ID)); }
88
- inline int idToArrayIndex (int const id) const { return (id - 1 ); }
89
90
90
91
int calcChecksum ();
91
92
void sendPacket ();
You can’t perform that action at this time.
0 commit comments