File tree Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Expand file tree Collapse file tree 2 files changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -93,7 +93,7 @@ BraccioClass::BraccioClass()
9393 * PUBLIC MEMBER FUNCTIONS
9494 **************************************************************************************/
9595
96- bool BraccioClass::begin (voidFuncPtr custom_menu)
96+ bool BraccioClass::begin (voidFuncPtr custom_menu, bool const wait_for_all_motor_connected )
9797{
9898 static int constexpr RS485_RX_PIN = 1 ;
9999
@@ -140,13 +140,16 @@ bool BraccioClass::begin(voidFuncPtr custom_menu)
140140
141141 _motors_connected_thd.start (mbed::callback (this , &BraccioClass::motorConnectedThreadFunc));
142142
143- /* Wait for all motors to be actually connected. */
144- for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++)
143+ if (wait_for_all_motor_connected)
145144 {
146- auto const start = millis ();
147- auto isTimeout = [start]() -> bool { return ((millis () - start) > 5000 ); };
148- for (; !isTimeout () && !connected (id); delay (100 )) { }
149- if (isTimeout ()) return false ;
145+ /* Wait for all motors to be actually connected. */
146+ for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++)
147+ {
148+ auto const start = millis ();
149+ auto isTimeout = [start]() -> bool { return ((millis () - start) > 5000 ); };
150+ for (; !isTimeout () && !connected (id); delay (100 )) { }
151+ if (isTimeout ()) return false ;
152+ }
150153 }
151154
152155 return true ;
Original file line number Diff line number Diff line change @@ -65,8 +65,7 @@ class BraccioClass
6565 BraccioClass ();
6666
6767 inline bool begin () { return begin (nullptr ); }
68- bool begin (voidFuncPtr custom_menu);
69-
68+ bool begin (voidFuncPtr custom_menu, bool const wait_for_all_motor_connected = true );
7069
7170 void pingOn ();
7271 void pingOff ();
You can’t perform that action at this time.
0 commit comments