@@ -72,31 +72,9 @@ bool BraccioClass::begin(voidFuncPtr custom_menu)
72
72
return false ;
73
73
_bl.turnOn ();
74
74
75
-
76
- if (!_expander.testConnection ())
75
+ if (!expander_init ())
77
76
return false ;
78
77
79
- for (int i = 0 ; i < 14 ; i++) {
80
- _expander.setPinDirection (i, 0 );
81
- }
82
-
83
- // Set SLEW to low
84
- _expander.setPinDirection (21 , 0 ); // P25 = 8 * 2 + 5
85
- _expander.writePin (21 , 0 );
86
-
87
- // Set TERM to HIGH (default)
88
- _expander.setPinDirection (19 , 0 ); // P23 = 8 * 2 + 3
89
- _expander.writePin (19 , 1 );
90
-
91
- _expander.setPinDirection (18 , 0 ); // P22 = 8 * 2 + 2
92
- _expander.writePin (18 , 0 ); // reset LCD
93
- _expander.writePin (18 , 1 ); // LCD out of reset
94
-
95
- /* Set all motor status LEDs to red. */
96
- for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++) {
97
- setRed (id);
98
- }
99
-
100
78
pinMode (BTN_LEFT, INPUT_PULLUP);
101
79
pinMode (BTN_RIGHT, INPUT_PULLUP);
102
80
pinMode (BTN_UP, INPUT_PULLUP);
@@ -332,6 +310,37 @@ void BraccioClass::lvgl_defaultMenu()
332
310
lv_obj_set_pos (label1, 0 , 0 );
333
311
}
334
312
313
+ bool BraccioClass::expander_init ()
314
+ {
315
+ if (!_expander.testConnection ())
316
+ return false ;
317
+
318
+ /* Init IO expander outputs of RGB LEDs */
319
+ for (int i = 0 ; i < 14 ; i++) {
320
+ _expander.setPinDirection (i, 0 );
321
+ }
322
+
323
+ /* Set SLEW to low */
324
+ _expander.setPinDirection (21 , 0 ); // P25 = 8 * 2 + 5
325
+ _expander.writePin (21 , 0 );
326
+
327
+ /* Set TERM to HIGH (default) */
328
+ _expander.setPinDirection (19 , 0 ); // P23 = 8 * 2 + 3
329
+ _expander.writePin (19 , 1 );
330
+
331
+ /* Reset GLCD */
332
+ _expander.setPinDirection (18 , 0 ); // P22 = 8 * 2 + 2
333
+ _expander.writePin (18 , 0 ); // reset LCD
334
+ _expander.writePin (18 , 1 ); // LCD out of reset
335
+
336
+ /* Set all motor status LEDs to red. */
337
+ for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++) {
338
+ setRed (id);
339
+ }
340
+
341
+ return true ;
342
+ }
343
+
335
344
bool BraccioClass::isPingAllowed ()
336
345
{
337
346
mbed::ScopedLock<rtos::Mutex> lock (_motors_connected_mtx);
0 commit comments