Basically, I want to define a value, which can change depending on what is going on elsewhere in the project.
I am using FastLED and an OLED screen, I basically want it to display what pattern it is showing when it comes on.
Each pattern shown below has a void() statement before it, and basically I want it to throw a value at the display function of the OLED.
void rainbow()
{
// FastLED's built-in rainbow generator
fill_rainbow( leds, NUM_LEDS, gHue, 7);
}
void sinelon()
{
// a colored dot sweeping back and forth, with fading trails
fadeToBlackBy( leds, NUM_LEDS, 20);
int pos = beatsin16( 13, 0, NUM_LEDS-1 );
leds[pos] += CHSV( gHue, 255, 192);
}
void bpm()
{
// colored stripes pulsing at a defined Beats-Per-Minute (BPM)
uint8_t BeatsPerMinute = 380;
CRGBPalette16 palette = PartyColors_p;
uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);
for( int i = 0; i < NUM_LEDS; i++) { //9948
leds[i] = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));
}
}
eg, I have made a 'display.print(displayPattern)' statement, of which I want to be able to reference displayPattern to make it display whatever void pattern() it is inside of.
void setup() {
//OLED
// initialize and clear display
display.begin(SSD1306_SWITCHCAPVCC, OLED_ADDR);
display.clearDisplay();
display.display();
// display a line of text
display.setTextSize(1);
display.setTextColor(WHITE);
display.setCursor(27,30);
display.print(displayPattern);
display.display();
}
Hopefully you can help! I'd also appreciate an explanation to why you have done what you have, in terms of coding. I am new to C/C++, I have a fair knowledge on Java but this is completely Alien to me.
Thanks.