Skip to content

Commit d460614

Browse files
committed
Moving implementation of RGB LED setting from header to source file.
1 parent 5a30ba0 commit d460614

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

src/Braccio++.cpp

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,12 +273,24 @@ bool BraccioClass::expander_init()
273273

274274
/* Set all motor status LEDs to red. */
275275
for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++) {
276-
setRed(id);
276+
expander_setRed(id);
277277
}
278278

279279
return true;
280280
}
281281

282+
void BraccioClass::expander_setGreen(int const i)
283+
{
284+
_expander.writePin(i * 2 - 1, 0);
285+
_expander.writePin(i * 2 - 2, 1);
286+
}
287+
288+
void BraccioClass::expander_setRed(int const i)
289+
{
290+
_expander.writePin(i * 2 - 1, 1);
291+
_expander.writePin(i * 2 - 2, 0);
292+
}
293+
282294
bool BraccioClass::isPingAllowed()
283295
{
284296
mbed::ScopedLock<rtos::Mutex> lock(_motors_connected_mtx);
@@ -305,9 +317,9 @@ void BraccioClass::motorConnectedThreadFunc()
305317

306318
for (int id = SmartServoClass::MIN_MOTOR_ID; id <= SmartServoClass::MAX_MOTOR_ID; id++) {
307319
if (connected(id))
308-
setGreen(id);
320+
expander_setGreen(id);
309321
else
310-
setRed(id);
322+
expander_setRed(id);
311323
}
312324
}
313325
delay(1000);

src/Braccio++.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ class BraccioClass
9797
PD_UFP_log_c PD_UFP;
9898
TCA6424A _expander;
9999
bool expander_init();
100+
void expander_setGreen(int const i);
101+
void expander_setRed(int const i);
100102

101103
bool _is_ping_allowed;
102104
bool _is_motor_connected[SmartServoClass::NUM_MOTORS];
@@ -150,16 +152,6 @@ class BraccioClass
150152
pd_events.set(1);
151153
}
152154

153-
void setGreen(int i) {
154-
_expander.writePin(i * 2 - 1, 0);
155-
_expander.writePin(i * 2 - 2, 1);
156-
}
157-
158-
void setRed(int i) {
159-
_expander.writePin(i * 2 - 1, 1);
160-
_expander.writePin(i * 2 - 2, 0);
161-
}
162-
163155
void pd_thread();
164156
};
165157

0 commit comments

Comments
 (0)