Skip to content

Commit fdd3ac4

Browse files
authored
feat(rmt): code improvement and clarity
1 parent 55b8244 commit fdd3ac4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

cores/esp32/esp32-hal-rmt.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -310,11 +310,12 @@ static bool _rmtWrite(int pin, rmt_data_t *data, size_t num_rmt_symbols, bool bl
310310
// loop == 1: infinite looping
311311
// loop > 1: transmit the data 'loop' times
312312
{
313-
char buf[20];
313+
char buf[12]; // place holder up to 5 + 1 + 5 + 1 bytes
314+
sprintf(buf, "%lu times", loop);
314315
log_v(
315316
"GPIO: %d - Currently in Loop Mode: [%s] | Loop Request: [%s], LoopCancel: [%s]", pin,
316317
bus->rmt_ch_is_looping ? "YES" : "NO",
317-
loop == 0 ? "NO" : (loop == 1 ? "FOREVER" : ({ sprintf(buf, "%lu times", loop); buf; })),
318+
loop == 0 ? "NO" : (loop == 1 ? "FOREVER" : buf),
318319
loopCancel ? "YES" : "NO"
319320
);
320321
}
@@ -428,9 +429,9 @@ bool rmtWriteLooping(int pin, rmt_data_t *data, size_t num_rmt_symbols) {
428429

429430
// Same as rmtWriteLooping(...) but it transmits the data a fixed number of times ("loop_count").
430431
// loop_count == 0 is invalid (no transmission); loop_count >= 1 means transmit that many times.
431-
bool rmtWriteLoopingCount(int pin, rmt_data_t *data, size_t num_rmt_symbols, uint32_t loop_count) {
432+
bool rmtWriteRepeated(int pin, rmt_data_t *data, size_t num_rmt_symbols, uint32_t loop_count) {
432433
if (loop_count == 0) {
433-
log_w("rmtWriteLoopingCount: Invalid loop_count (%u). Must be at least 1.", loop_count);
434+
log_w("rmtWriteRepeated: Invalid loop_count (%u). Must be at least 1.", loop_count);
434435
return false;
435436
}
436437
if (loop_count == 1) {

0 commit comments

Comments
 (0)