@@ -128,7 +128,7 @@ rmt_data_t blink_1s_rmt_data[] = {
128
128
0 ,
129
129
},
130
130
// Looping mode needs a Zero ending data to mark the EOF
131
- {0 , 0 , 0 , 0 }
131
+ { 0 , 0 , 0 , 0 }
132
132
};
133
133
134
134
// RMT is at 400KHz with a 2.5us tick
@@ -185,7 +185,7 @@ rmt_data_t blink_500ms_rmt_data[] = {
185
185
0 ,
186
186
},
187
187
// Looping mode needs a Zero ending data to mark the EOF
188
- {0 , 0 , 0 , 0 }
188
+ { 0 , 0 , 0 , 0 }
189
189
};
190
190
191
191
// RMT is at 400KHz with a 2.5us tick
@@ -218,7 +218,7 @@ rmt_data_t blink_250ms_rmt_data[] = {
218
218
0 ,
219
219
},
220
220
// Looping mode needs a Zero ending data to mark the EOF
221
- {0 , 0 , 0 , 0 }
221
+ { 0 , 0 , 0 , 0 }
222
222
};
223
223
224
224
void RMT_Mixed_Write_Blink () {
@@ -244,7 +244,8 @@ void RMT_Mixed_Write_Blink() {
244
244
Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
245
245
}
246
246
// wait (blocks) until all the data is sent out
247
- while (!rmtTransmitCompleted (BLINK_GPIO));
247
+ while (!rmtTransmitCompleted (BLINK_GPIO))
248
+ ;
248
249
}
249
250
Serial.println (" Blinking OFF for 1 seconds" );
250
251
delay (1000 );
@@ -269,13 +270,34 @@ void RMT_Loop_Write_Blink() {
269
270
delay (5000 );
270
271
271
272
Serial.println (" Blinking OFF for 2 seconds" );
272
- rmt_data_t blink_STOP_rmt_data[] = {{ 0 , 0 , 0 , 0 } };
273
+ rmt_data_t blink_STOP_rmt_data[] = { { 0 , 0 , 0 , 0 } };
273
274
if (!rmtWrite (BLINK_GPIO, blink_STOP_rmt_data, RMT_SYMBOLS_OF (blink_STOP_rmt_data), RMT_WAIT_FOR_EVER)) {
274
275
Serial.println (" ===> rmtWrite Blink STOP Error!" );
275
276
}
276
277
delay (2000 );
277
278
}
278
279
280
+ void RMT_Repeated_Write_Blink () {
281
+ Serial.println (" Using RMT Writing repeated N times to blink an LED." );
282
+ Serial.println (" Blinking at 1s on + 1s off :: 2 blinks" );
283
+ // repeating blink_1s_rmt_data (1s on + 1s off) 2 times for 2 blinks
284
+ if (!rmtWriteRepeated (BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF (blink_1s_rmt_data) - 1 , 2 )) {
285
+ Serial.println (" ===> rmtWrite Blink 1s Error!" );
286
+ }
287
+ Serial.println (" Blinking at 500ms on + 500ms off :: 4 blinks" );
288
+ // repeating blink_500ms_rmt_data (500ms on + 500ms off) 4 times for 4 blinks
289
+ if (!rmtWriteRepeated (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 1 , 4 )) {
290
+ Serial.println (" ===> rmtWrite Blink 0.5s Error!" );
291
+ }
292
+ Serial.println (" Blinking at 250ms on + 250ms off :: 8 blinks" );
293
+ // repeating blink_250ms_rmt_data (250ms on + 250ms off) 8 times for 8 blinks
294
+ if (!rmtWriteRepeated (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 1 , 8 )) {
295
+ Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
296
+ }
297
+ Serial.println (" Blinking is OFF for 2 seconds" );
298
+ delay (2000 );
299
+ }
300
+
279
301
void RMT_Single_Write_Blocking_Blink () {
280
302
Serial.println (" Using RMT Writing and its Completion to blink an LED." );
281
303
Serial.println (" Blinking at 1s on + 1s off :: 2 blinks" );
@@ -308,23 +330,26 @@ void RMT_Write_Aync_Non_Blocking_Blink() {
308
330
Serial.println (" ===> rmtWrite Blink 1s Error!" );
309
331
}
310
332
// wait (blocks) until all the data is sent out
311
- while (!rmtTransmitCompleted (BLINK_GPIO));
333
+ while (!rmtTransmitCompleted (BLINK_GPIO))
334
+ ;
312
335
}
313
336
Serial.println (" Blinking at 500ms on + 500ms off :: 5 blinks" );
314
337
for (uint8_t i = 0 ; i < 5 ; i++) {
315
338
if (!rmtWriteAsync (BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF (blink_500ms_rmt_data) - 1 )) {
316
339
Serial.println (" ===> rmtWrite Blink 0.5s Error!" );
317
340
}
318
341
// wait (blocks) until all the data is sent out
319
- while (!rmtTransmitCompleted (BLINK_GPIO));
342
+ while (!rmtTransmitCompleted (BLINK_GPIO))
343
+ ;
320
344
}
321
345
Serial.println (" Blinking at 250ms on + 250ms off :: 5 blinks" );
322
346
for (uint8_t i = 0 ; i < 5 ; i++) {
323
347
if (!rmtWriteAsync (BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF (blink_250ms_rmt_data) - 1 )) {
324
348
Serial.println (" ===> rmtWrite Blink 0.25s Error!" );
325
349
}
326
350
// wait (blocks) until all the data is sent out
327
- while (!rmtTransmitCompleted (BLINK_GPIO));
351
+ while (!rmtTransmitCompleted (BLINK_GPIO))
352
+ ;
328
353
}
329
354
Serial.println (" Blinking OFF for 1 seconds" );
330
355
delay (1000 );
@@ -356,6 +381,7 @@ void setup() {
356
381
void loop () {
357
382
RMT_Write_Aync_Non_Blocking_Blink ();
358
383
RMT_Loop_Write_Blink ();
384
+ RMT_Repeated_Write_Blink ();
359
385
RMT_Single_Write_Blocking_Blink ();
360
386
Serial.println (" \n Starting OVER...\n " );
361
387
}
0 commit comments