Skip to content

array of leds with a point method #17

@julienhogert

Description

@julienhogert

Hello ! Thanks for the job you did.
I tried severals library, and yours is the only one I found, working with 19,18,26,23,5 pins, at the same time. I tried to use the implement of RMT of Fastled, but it didn't work so I wanted to use yours. I'm just facing one problem, I don't find a way to work with the library with a pointer array of smartleds. (It's not a necessity, but just more convenient). There is something too "high-level" for me. how is possible than a Instance of a class can be igual to a another instance of another class? (Smartled class = rgb class?)
Thanks for your help and the good job you did !

This is the code I used :

#include <Arduino.h>
#include <SmartLeds.h>

#define NB_STRIPS 4
#define NB_LEDS_PER_STRIP 6
byte leds_pins[]={19,18,26,23,5};

// SmartLed -> RMT driver (WS2812/WS2812B/SK6812/WS2813)
SmartLed *leds[3];


void setup() {
  Serial.begin(9600);  
  for(int i=0;i<NB_STRIPS;i++){
    leds[i]= new SmartLed ( LED_WS2812, NB_LEDS_PER_STRIP, leds_pins[i], i, DoubleBuffer );
}
}

uint8_t hue;
void showGradient() {
    hue++;
    // Use HSV to create nice gradient
   for(int i=0;i<NB_STRIPS;i++){
   for ( int j = 0; j != NB_LEDS_PER_STRIP; j++ ){
        //leds[i][ j ] = Hsv{ static_cast< uint8_t >( hue + 30 * j ), 255, 255 }; NOT WORKING !
        //(*leds)[i][ j ] = Hsv{ static_cast< uint8_t >( hue + 30 * j ), 255, 255 }; // NOT WORKING ! CRASH THE ESP32
        //(*leds)[i][ j ] = Rgb{ 255, 0, 0 }; NOT WORKING !
        }
    leds[i]->show();
    }
}

void loop() {
    Serial.println("New loop");
    showGradient();
    delay( 20 );
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions