Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Palette Pointers working
- *
- * By: Andrew Tuline
- *
- * Date: January, 2021
- *
- * Finally, a working version of code that programatically refers to built-in palettes by an index number.
- *
- */
- #include <FastLED.h>
- #define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))
- #define LED_DT 12
- #define COLOR_ORDER GRB
- #define LED_TYPE WS2812
- #define NUM_LEDS 30
- #define BRIGHTNESS 64
- struct CRGB leds[NUM_LEDS];
- FL_PROGMEM extern const TProgmemRGBPalette16 *const palettes[] = {
- &PartyColors_p, &CloudColors_p, &OceanColors_p, &ForestColors_p,
- &LavaColors_p, &HeatColors_p, &RainbowColors_p
- };
- CRGBPalette16 currentPalette;
- void setup() {
- Serial.begin(115200);
- LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- } // setup()
- void loop () {
- uint8_t palette_num = (millis()/2000) % sizeof(palettes);
- currentPalette = *(TProgmemRGBPalette16 *) pgm_read_ptr_near(&palettes[palette_num]);
- Serial.println(palette_num);
- fill_palette(leds, NUM_LEDS, 0, (256/NUM_LEDS)+1, currentPalette, 255, NOBLEND);
- FastLED.show();
- } // loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement