Skip to content

Commit 43019c8

Browse files
committed
Optimize motors ping()
1 parent b552df7 commit 43019c8

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Braccio.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,16 @@ void BraccioClass::motors_connected_thread() {
213213
_connected[i] = (servos->ping(i) == 0);
214214
//Serial.print(String(i) + ": ");
215215
//Serial.println(_connected[i]);
216-
i2c_mutex.lock();
216+
}
217+
i2c_mutex.lock();
218+
for (int i = 1; i < 7; i++) {
217219
if (_connected[i]) {
218220
setGreen(i);
219221
} else {
220222
setRed(i);
221223
}
222-
i2c_mutex.unlock();
223224
}
225+
i2c_mutex.unlock();
224226
}
225227
delay(1000);
226228
}

src/lib/motors/SmartServo.cpp.impl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ template <int MAX_MOTORS> void SmartServoClass<MAX_MOTORS>::receiveResponse() {
6363
//Serial.print(c, HEX);
6464
//Serial.print(" ");
6565
_rxBuf[_rxLen++]=c;
66-
delayMicroseconds(2000);
66+
if (!_RS485.available()) {
67+
delay(1);
68+
}
6769
}
6870
//Serial.println();
6971
_RS485.noReceive();

0 commit comments

Comments
 (0)