Go Down

Topic: [FastLED][new to arduino] Error in part of the libary i'm not using (clearLeds) (Read 1 time) previous topic - next topic

tjjensma

Hello, i recently started programming arduino, but some times i keep getting an error, and i really don't know what is causing it. It is not even much lines of code.

#include <FastLED.h>
#define NUM_LEDS 128
#define DATA_PIN 10
CRGB leds[NUM_LEDS];


Code: [Select]

  void setup() {
       FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
   }

  void loop() {
        for(int dot = 0; dot < NUM_LEDS; dot++) {
            leds[dot][0] = 255;
            FastLED.show();
            // clear this led for the next time around the loop
            leds[dot][0] = 0;
            delay(30);
        }
    }



This is just supposed to be one of the most basic pieces of code, that is supposed to just have one red led following the led strip. This is the error i keep getting, i was not able to find a clear solution to this problem online. I have also gotten this error in other occasions and it seems to just happen sometimes.:


C:\Users\Thoma\Documents\Arduino\libraries\FastLED/controller.h: In member function 'clearLeds':

C:\Users\Thoma\Documents\Arduino\libraries\FastLED/controller.h:76:82: internal compiler error: Segmentation fault

  virtual void clearLeds(int nLeds) { showColor(CRGB::Black, nLeds, CRGB::Black); }


As far as i understand it, it is an error in a file of the library. And that doesn't really make sense, so that's why i am asking here.

UKHeliBob

Code: [Select]
CRGB leds[NUM_LEDS];
Code: [Select]
leds[dot][0] = 255;

Does the leds array have one dimension or two ?
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

tjjensma

it has one, but I have read somewhere that indexing like this is a way of addressing the rgb values.
  • for red, [1] for green, and [2] for blue.

(Edit)
i just replaced  leds[dot][0] = 255; with leds[dot]  = CRGB( 255, 0, 0);
and it still gives the same error.

AWOL

Quote
but I have read somewhere that indexing like this is a way of addressing the rgb values.
Reference, please.

tjjensma

Data Members
CRGB has three one-byte data members, each representing one of the three red, green, and blue color channels of the color. There is more than one way to access the RGB data; each of these following examples does exactly the same thing:

Code: [Select]
  // The three color channel values can be referred to as "red", "green", and "blue"...
  leds[i].red   = 50;
  leds[i].green = 100;
  leds[i].blue  = 150;

  // ...or, using the shorter synonyms "r", "g", and "b"...
  leds[i].r = 50;
  leds[i].g = 100;
  leds[i].b = 150;

  // ...or as members of a three-element array:
  leds[i][0] = 50;  // red
  leds[i][1] = 100; // green
  leds[i][2] = 150; // blue


link:
https://github.com/FastLED/FastLED/wiki/Pixel-reference

UKHeliBob

What is the sense in using the obscure and opaque 2 dimensional array syntax rather than the readable and understandable syntax using names ?

By the way, your program compiles OK for me
IDE 1.8.5
Nano board
Windows 10
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

tjjensma

Its in an obscure way because i want to modify the rgb values in a weird way, because i have my leds arranged in a panel of table tennis balls, so they're arranged in triangles. Also, i just started with arduino and this is just my way of starting, definitely not efficient yet. Efficiency will come from experience i hope. i'm using windows 10, IDE 1.8.7, on a uno.
Do you thing i might have the fastled library installed wrong? i just installed it prom the ide (using the search library function)
also, I'm using FastLED version 3.002.000

UKHeliBob

That sounds like an old version.  I have FastLED version 3.1.6 installed and version 3.2.0 is available from the Library Manager in the IDE
Please do not send me PMs asking for help.  Post in the forum then everyone will benefit from seeing the questions and answers.

sterretje

The compiler encounters a segmentation fault. So that has nothing to do with your code or the library code.

Which IDE version? If it's 1.8.6, I would downgrade to 1.8.5.
If you understand an example, use it.
If you don't understand an example, don't use it.

Electronics engineer by trade, software engineer by profession. Trying to get back into electronics after 15 years absence.

tjjensma

I am using version 3.2.0 (when i try to compile it just says it is using version 3.002.000 ). I also tried using fastled 3.1.6, wich didnt solve my problem.
I am using ide 1.8.7 . I will try downgrading it to 1.8.5 . Thanks for the tip :) .

pert

The "segmentation fault" issue with the new avr-gcc 5.4.0 compiler version introduced in Arduino IDE 1.8.7/Arduino AVR Boards 1.6.22 has been reported in the Arduino bug tracker:

Unfortunately there has been no progress on that issue.

If you want to continue using Arduino IDE 1.8.7, you can simply roll back to Arduino AVR Boards 1.6.21:
  • Tools > Board > Boards Manager
  • Wait for downloads to finish
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install"
  • Wait for installation to finish.
  • Click "Close".


If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.



StantomRM3

The "segmentation fault" issue with the new avr-gcc 5.4.0 compiler version introduced in Arduino IDE 1.8.7/Arduino AVR Boards 1.6.22 has been reported in the Arduino bug tracker:

Unfortunately there has been no progress on that issue.

If you want to continue using Arduino IDE 1.8.7, you can simply roll back to Arduino AVR Boards 1.6.21:
  • Tools > Board > Boards Manager
  • Wait for downloads to finish
  • When you move the mouse pointer over "Arduino AVR Boards", you will see a "Select version" dropdown menu appear. Select "1.6.21".
  • Click "Install"
  • Wait for installation to finish.
  • Click "Close".


If you have File > Preferences > Check for updates on startup checked, the Arduino IDE may occasionally notify you that a new version of Arduino AVR Boards is available, you'll need to refrain from updating back to the new Arduino AVR Boards version, otherwise you'll be back to seeing the segmentation fault error again.


This worked for me aswell.  This segmentation issue is a funny one, sometimes simply making minor mods to the code seems to fix, however very "unscientific".  Thanks

Go Up