Fastled not enough CPU power?

0

I was wondering if someone could help me out?

I have a 5M ledstrip (300 leds) and running the following code on my ESP32. The code will make a led light spinning around!

void spinningwheel(){
int random_number;
int spin_speed;
for(int i =0; i < 1; i++){
random_number = random(NUM_LEDS);
}

Serial.println(random_number);
for (int i = 0; i <= random(6,15); i++){
spin_speed = i+1;
for (int i = 0; i <= NUM_LEDS; i++){
leds[i] = CRGB ( 0, 0, 255);
leds[i-10] = CRGB ( 0, 0, 0);
FastLED.show();
delay(spin_speed);
}
FastLED.clear();

}
for (int i = 0; i <= random_number; i++){
leds[i] = CRGB ( 0, 0, 255);
leds[i-10] = CRGB ( 0, 0, 0);
FastLED.show();
delay(spin_speed);
}
FastLED.clear();
delay(1000);
}

The code is working fine if i use leds[i-3] = CRGB ( 0, 0, 0); But when i change the number i-3 to something like i-10 ill get a error in my Serial port

15:51:36.233 -> 258
15:51:36.267 -> Guru Meditation Error: Core  1 panic'ed (StoreProhibited). 
Exception was unhandled.
15:51:36.335 -> Core 1 register dump:
15:51:36.368 -> PC      : 0x400d12ae  PS      : 0x00060930  A0      : 
0x800d1658  A1      : 0x3ffb1e80  
15:51:36.469 -> A2      : 0x3ffc0124  A3      : 0x3ffb1ea4  A4      : 
0x3ffc04bc  A5      : 0x3ffb1eb0  
15:51:36.571 -> A6      : 0x00000000  A7      : 0x3ffb0060  A8      : 
0x00000000  A9      : 0x3ffb1e40  
15:51:36.639 -> A10     : 0x00000001  A11     : 0x00000000  A12     : 
0x3ffb8570  A13     : 0x00000000  
15:51:36.742 -> A14     : 0x3ffb8528  A15     : 0x00000000  SAR     : 
0x00000020  EXCCAUSE: 0x0000001d  
15:51:36.843 -> EXCVADDR: 0x00000000  LBEG    : 0x400d0dfd  LEND    : 
0x400d0e0c  LCOUNT  : 0x00000000  
15:51:36.944 -> 
15:51:36.944 -> Backtrace: 0x400d12ae:0x3ffb1e80 0x400d1655:0x3ffb1ea0 
0x400d1741:0x3ffb1ee0 0x400d0ee0:0x3ffb1f20 0x400d0fe1:0x3ffb1f40 
0x400d115e:0x3ffb1f70 0x400d118f:0x3ffb1f90 0x400d216d:0x3ffb1fb0 
0x40088215:0x3ffb1fd0
15:51:37.147 -> 
15:51:37.147 -> Rebooting...
15:51:37.180 -> :⸮⸮⸮⸮L⸮⸮1⸮m֊⸮1
HL⸮⸮b⸮⸮⸮

DECODE OF THE ERROR

PC: 0x400d12ae: ClocklessController14, 60, 150, 90, (EOrder)66, 0, false, 
5>::showPixels(PixelController(EOrder)66, 1, 4294967295u>&) at 
D:\Documenten\Arduino\libraries\FastLED/controller.h line 178
EXCVADDR: 0x00000000

Decoding stack results
0x400d12ae: ClocklessController14, 60, 150, 90, (EOrder)66, 0, false, 
5>::showPixels(PixelController(EOrder)66, 1, 4294967295u>&) at 
D:\Documenten\Arduino\libraries\FastLED/controller.h line 178
0x400d1655: CPixelLEDController(EOrder)66, 1, 4294967295u>::show(CRGB const*, 
int, CRGB) at D:\Documenten\Arduino\libraries\FastLED/controller.h line 408
0x400d1741: CFastLED::show(unsigned char) at 
D:\Documenten\Arduino\libraries\FastLED/controller.h line 90
0x400d0ee0: CFastLED::show() at 
D:\Documenten\Arduino\libraries\FastLED/FastLED.h line 500
0x400d0fe1: spinningwheel() at 
D:\Documenten\Arduino\Ledstrip_wave/Ledstrip_wave.ino line 48
0x400d115e: Binair_buttons() at 
D:\Documenten\Arduino\Ledstrip_wave/Ledstrip_wave.ino line 125
0x400d118f: loop() at D:\Documenten\Arduino\Ledstrip_wave/Ledstrip_wave.ino 
line 141
0x400d216d: loopTask(void*) at 
C:\Users\....\AppData\Local\Arduino15\packages\esp32\
hardware\esp32\1.0.4\cores\esp32\main.cpp line 19
0x40088215: vPortTaskWrapper at /home/runner/work/esp32-arduino-lib- 
builder/esp32-arduino-lib-builder/esp-idf/components/freertos/port.c line 143

Can someone please explain me what i am doing wrong? Or did i passed the max RAM or CPU usage.

error-handling
arduino
esp32
fastled
asked on Stack Overflow Mar 27, 2021 by Ikben niekjuuhh • edited Mar 27, 2021 by Ikben niekjuuhh

1 Answer

0

You have array of colors indexed from 0 up to NUM_LEDS-1, if you use indexes before or after that space, you are destroying something you shouldn't. And now:

for (int i = 0; i <= NUM_LEDS; i++){  // values of i  0 .. NUM_LEDS (including! -buffer overflow)
  leds[i] = CRGB ( 0, 0, 255);
  leds[i-10] = CRGB ( 0, 0, 0);  // for all i less than 0, you are BEFORE the actual array

So you've achieved to go outside the array on both sides. Going three elements before the first element obviously didn't do so much damage to crash the program, but 10 elements before must've destroyed something really important. And also going after the array boundaries destroys something stored just after it..

answered on Stack Overflow Mar 27, 2021 by KIIV • edited Apr 1, 2021 by marc_s

User contributions licensed under CC BY-SA 3.0