5
5
6
6
#include " esp32-hal.h"
7
7
8
- #define LED_MATRIX_SIZE 8 *4 *24
8
+ #define NR_OF_LEDS 8 *4
9
+ #define NR_OF_PIXELS 24 *NR_OF_LEDS
9
10
10
11
//
11
12
// Note: This example uses Neopixel LED board, 32 LEDs chained one
32
33
// +-------------+ +--
33
34
// | 0.8us | 0.4us |
34
35
35
- rmt_data_t led_data[LED_MATRIX_SIZE ];
36
+ rmt_data_t led_data[NR_OF_PIXELS ];
36
37
37
38
rmt_obj_t * rmt_send = NULL ;
38
39
39
- static EventGroupHandle_t events;
40
-
41
40
void setup ()
42
41
{
43
42
Serial.begin (115200 );
@@ -58,27 +57,27 @@ int led_index = 0;
58
57
void loop ()
59
58
{
60
59
// 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
+ }
74
73
}
75
74
// make the led travel in the pannel
76
- if ((++led_index)>=4 * 8 ) {
75
+ if ((++led_index)>=NR_OF_LEDS ) {
77
76
led_index = 0 ;
78
77
}
79
78
80
79
// Send the data
81
- rmtWrite (rmt_send, led_data, LED_MATRIX_SIZE );
80
+ rmtWrite (rmt_send, led_data, NR_OF_PIXELS );
82
81
83
82
delay (100 );
84
83
}
0 commit comments