Skip to content

Commit ab4ffbc

Browse files
committed
minor updates per review
1 parent 1cb7560 commit ab4ffbc

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

libraries/ESP32/examples/RMT/RMTWriteNeoPixel/RMTWriteNeoPixel.ino

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55

66
#include "esp32-hal.h"
77

8-
#define LED_MATRIX_SIZE 8*4*24
8+
#define NR_OF_LEDS 8*4
9+
#define NR_OF_PIXELS 24*NR_OF_LEDS
910

1011
//
1112
// Note: This example uses Neopixel LED board, 32 LEDs chained one
@@ -32,12 +33,10 @@
3233
// +-------------+ +--
3334
// | 0.8us | 0.4us |
3435

35-
rmt_data_t led_data[LED_MATRIX_SIZE];
36+
rmt_data_t led_data[NR_OF_PIXELS];
3637

3738
rmt_obj_t* rmt_send = NULL;
3839

39-
static EventGroupHandle_t events;
40-
4140
void setup()
4241
{
4342
Serial.begin(115200);
@@ -58,27 +57,27 @@ int led_index = 0;
5857
void loop()
5958
{
6059
// Init data with only one led ON
61-
int i;
62-
int item, bit, inx;
63-
for (i=0; i<LED_MATRIX_SIZE; i++) {
64-
65-
item = i/24;
66-
67-
bit = i%8;
68-
inx = i/8;
69-
70-
if ( (color[inx%3] & (1<<(8-bit))) && (item == led_index) )
71-
led_data[i].val = 0x80070006;
72-
else
73-
led_data[i].val = 0x80040008;
60+
int led, col, bit;
61+
int i=0;
62+
for (led=0; led<NR_OF_LEDS; led++) {
63+
for (col=0; col<3; col++ ) {
64+
for (bit=0; bit<8; bit++){
65+
if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) {
66+
led_data[i].val = 0x80070006;
67+
} else {
68+
led_data[i].val = 0x80040008;
69+
}
70+
i++;
71+
}
72+
}
7473
}
7574
// make the led travel in the pannel
76-
if ((++led_index)>=4*8) {
75+
if ((++led_index)>=NR_OF_LEDS) {
7776
led_index = 0;
7877
}
7978

8079
// Send the data
81-
rmtWrite(rmt_send, led_data, LED_MATRIX_SIZE);
80+
rmtWrite(rmt_send, led_data, NR_OF_PIXELS);
8281

8382
delay(100);
8483
}

0 commit comments

Comments
 (0)