Skip to content

Commit 8d72750

Browse files
committed
used struct access, renamed defines, corrected diagram
1 parent ab4ffbc commit 8d72750

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

Diff for: libraries/ESP32/examples/RMT/RMTWriteNeoPixel/RMTWriteNeoPixel.ino

+16-10
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#include "esp32-hal.h"
77

88
#define NR_OF_LEDS 8*4
9-
#define NR_OF_PIXELS 24*NR_OF_LEDS
9+
#define NR_OF_ALL_BITS 24*NR_OF_LEDS
1010

1111
//
1212
// Note: This example uses Neopixel LED board, 32 LEDs chained one
@@ -16,24 +16,24 @@
1616
// Bits encoded as pulses as follows:
1717
//
1818
// "0":
19-
// ---+ +--------------+
20-
// | | |
19+
// +-------+ +--
2120
// | | |
2221
// | | |
2322
// | | |
24-
// +-------+ +--
23+
// ---| |--------------|
24+
// + + +
2525
// | 0.4us | 0.85 0us |
2626
//
2727
// "1":
28-
// ---+ +-------+
28+
// +-------------+ +--
2929
// | | |
3030
// | | |
3131
// | | |
3232
// | | |
33-
// +-------------+ +--
33+
// ---+ +-------+
3434
// | 0.8us | 0.4us |
3535

36-
rmt_data_t led_data[NR_OF_PIXELS];
36+
rmt_data_t led_data[NR_OF_ALL_BITS];
3737

3838
rmt_obj_t* rmt_send = NULL;
3939

@@ -63,9 +63,15 @@ void loop()
6363
for (col=0; col<3; col++ ) {
6464
for (bit=0; bit<8; bit++){
6565
if ( (color[col] & (1<<(8-bit))) && (led == led_index) ) {
66-
led_data[i].val = 0x80070006;
66+
led_data[i].level0 = 1;
67+
led_data[i].duration0 = 8;
68+
led_data[i].level1 = 0;
69+
led_data[i].duration1 = 4;
6770
} else {
68-
led_data[i].val = 0x80040008;
71+
led_data[i].level0 = 1;
72+
led_data[i].duration0 = 4;
73+
led_data[i].level1 = 0;
74+
led_data[i].duration1 = 8;
6975
}
7076
i++;
7177
}
@@ -77,7 +83,7 @@ void loop()
7783
}
7884

7985
// Send the data
80-
rmtWrite(rmt_send, led_data, NR_OF_PIXELS);
86+
rmtWrite(rmt_send, led_data, NR_OF_ALL_BITS);
8187

8288
delay(100);
8389
}

0 commit comments

Comments
 (0)