Skip to content

Instantly share code, notes, and snippets.

@hpwit
Last active October 1, 2018 11:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hpwit/19e237f4d4cf3545a6f26f8c135e4753 to your computer and use it in GitHub Desktop.
Save hpwit/19e237f4d4cf3545a6f26f8c135e4753 to your computer and use it in GitHub Desktop.
class for strips
//You would have a class define like this
class Strip
{
public:
CRGB *leds;
Strip(int num_leds);
void Comet(CRGB color);
void OTC(CRGB color);
void Ravel(CRGB color);
int numLeds=0;
}
Strip::Strip(int num_leds)
{
leds =(CRGB*)malloc(num_leds*sizeof(CRGB)) ;
if(leds==NULL)
{
Serial.println("Error not able to create the strip");
}
else
{
numLeds=num_leds;
}
}
//the way you use it
Strip strip1=Strip(200);
if(strip1.numLeds>0)
FastLED.addLeds<..,2>(strip1.leds, strip1£.numLeds);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment