Skip to content

Commit e74b95e

Browse files
committed
more formatting pass
1 parent 122eca4 commit e74b95e

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

src/ODriveCAN.h

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@
1212
static inline ODriveCanIntfWrapper wrap_can_intf(TIntf& intf) { \
1313
return { \
1414
&intf, \
15-
[](void* intf, uint32_t id, uint8_t length, const uint8_t* data) { return sendMsg(*(TIntf*)intf, id, length, data); }, \
16-
[](void* intf) { pumpEvents(*(TIntf*)intf); } \
15+
([](void* intf, uint32_t id, uint8_t length, const uint8_t* data) { \
16+
return sendMsg(*(TIntf*)intf, id, length, data); \
17+
}), \
18+
[](void* intf) { pumpEvents(*(TIntf*)intf); }, \
1719
}; \
1820
}
1921

2022

2123
struct ODriveCanIntfWrapper {
22-
bool sendMsg(uint32_t id, uint8_t length, const uint8_t* data) {
23-
return (*send_msg_)(can_intf_, id, length, data);
24-
}
25-
void pump_events() {
26-
(*pump_events_)(can_intf_);
27-
}
24+
bool sendMsg(uint32_t id, uint8_t length, const uint8_t* data) { return (*send_msg_)(can_intf_, id, length, data); }
25+
void pump_events() { (*pump_events_)(can_intf_); }
2826

2927
void* can_intf_;
3028
bool (*send_msg_)(void* intf, uint32_t id, uint8_t length, const uint8_t* data);
@@ -33,8 +31,7 @@ struct ODriveCanIntfWrapper {
3331

3432
class ODriveCAN {
3533
public:
36-
ODriveCAN(const ODriveCanIntfWrapper& can_intf, uint32_t node_id)
37-
: can_intf_(can_intf), node_id_(node_id) {};
34+
ODriveCAN(const ODriveCanIntfWrapper& can_intf, uint32_t node_id) : can_intf_(can_intf), node_id_(node_id){};
3835

3936
/**
4037
* @brief Clear all errors on the ODrive.
@@ -202,8 +199,11 @@ class ODriveCAN {
202199
/**
203200
* @brief Registers a callback for ODrive feedback processing.
204201
*/
205-
void onFeedback(void (*callback)(Get_Encoder_Estimates_msg_t& feedback, void* user_data), void* user_data = nullptr) {
206-
feedback_callback_ = callback;
202+
void onFeedback(
203+
void (*callback)(Get_Encoder_Estimates_msg_t& feedback, void* user_data),
204+
void* user_data = nullptr
205+
) {
206+
feedback_callback_ = callback;
207207
feedback_user_data_ = user_data;
208208
}
209209

@@ -234,7 +234,10 @@ class ODriveCAN {
234234
/**
235235
* @brief Registers a callback for ODrive bus voltage/current feedback.
236236
*/
237-
void onBusVI(void (*callback)(Get_Bus_Voltage_Current_msg_t& feedback, void* user_data), void* user_data = nullptr) {
237+
void onBusVI(
238+
void (*callback)(Get_Bus_Voltage_Current_msg_t& feedback, void* user_data),
239+
void* user_data = nullptr
240+
) {
238241
busVI_callback_ = callback;
239242
busVI_user_data_ = user_data;
240243
}
@@ -288,11 +291,7 @@ class ODriveCAN {
288291
bool send(const T& msg) {
289292
uint8_t data[8] = {};
290293
msg.encode_buf(data);
291-
return can_intf_.sendMsg(
292-
(node_id_ << ODriveCAN::kNodeIdShift) | msg.cmd_id,
293-
msg.msg_length,
294-
data
295-
);
294+
return can_intf_.sendMsg((node_id_ << ODriveCAN::kNodeIdShift) | msg.cmd_id, msg.msg_length, data);
296295
}
297296

298297
/**

src/ODriveHardwareCAN.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ static bool sendMsg(HardwareCAN& can_intf, uint32_t id, uint8_t length, const ui
2626
// Note: Arduino_CAN does not support the RTR bit. The ODrive interprets
2727
// zero-length packets the same as RTR=1, but it creates the possibility of
2828
// collisions.
29-
CanMsg msg(
29+
CanMsg msg{
3030
(id & 0x80000000) ? CanExtendedId(id) : CanStandardId(id),
3131
length,
32-
data
33-
);
32+
data,
33+
};
3434
return can_intf.write(msg) >= 0;
3535
}
3636

src/ODriveUART.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,10 @@
99
static const int kMotorNumber = 0;
1010

1111
// Print with stream operator
12+
// clang-format off
1213
template<class T> inline Print& operator <<(Print &obj, T arg) { obj.print(arg); return obj; }
1314
template<> inline Print& operator <<(Print &obj, float arg) { obj.print(arg, 4); return obj; }
15+
// clang-format on
1416

1517
ODriveUART::ODriveUART(Stream& serial) : serial_(serial) {}
1618

0 commit comments

Comments
 (0)