Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This #include statement was automatically added by the Particle IDE.
- #include <FastLED.h>
- FASTLED_USING_NAMESPACE;
- #define LED_PIN 4
- #define COLOR_ORDER GRB
- #define CHIPSET WS2811
- #define NUM_LEDS 300 //88 for testing, 300 for prodction
- #define BRIGHTNESS 150
- #define FRAMES_PER_SECOND 30
- bool gReverseDirection = false;
- unsigned long previousMillis = 0;
- unsigned long currentMillis;
- unsigned long twinkleMillis = 0;
- int mode;
- long totalModes = 3;
- CRGB leds[NUM_LEDS];
- // Forward declarations of an array of cpt-city gradient palettes, and
- // a count of how many there are. The actual color palette definitions
- // are at the bottom of this file.
- extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
- extern const uint8_t gGradientPaletteCount;
- // Current palette number from the 'playlist' of color palettes
- uint8_t gCurrentPaletteNumber = 0;
- CRGBPalette16 gCurrentPalette( CRGB::Black);
- CRGBPalette16 gTargetPalette( gGradientPalettes[0] );
- void setup() {
- delay(3000); // sanity delay
- FastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
- FastLED.setBrightness( BRIGHTNESS );
- //FastLED.setMaxPowerInVoltsAndMilliamps(5, 1500);
- randomSeed(analogRead(0));
- //Serial.begin(9600);
- mode = random(totalModes);
- }
- extern const TProgmemRGBGradientPalettePtr gGradientPalettes[];
- void loop()
- {
- }
- void runRainbow() {
- if (currentMillis - previousMillis >= 30) {
- previousMillis = currentMillis;
- static uint8_t hue = 0;
- fill_rainbow(leds, NUM_LEDS, hue++);
- FastLED.show();
- }
- }
- void twinkle() {
- //create random twinkle
- int rp = random(500,2000);
- if (currentMillis - twinkleMillis >= rp) {
- twinkleMillis = currentMillis;
- int pixel = random(NUM_LEDS);
- leds[random(NUM_LEDS)] = CRGB::White;
- FastLED.show();
- }
- }
- void palettetest( const CRGBPalette16& gCurrentPalette)
- {
- if (currentMillis - previousMillis >= 30) {
- previousMillis = currentMillis;
- static uint8_t startindex = 0;
- startindex--;
- fill_palette( leds, NUM_LEDS, startindex, (256 / NUM_LEDS) + 1, gCurrentPalette, 255, LINEARBLEND);
- FastLED.show();
- }
- }
- DEFINE_GRADIENT_PALETTE( holly_gp) {
- 0, 0, 255, 0, //green
- 48, 0, 255, 0, //green
- 49, 255, 0, 0, //red
- 64, 255, 0, 0, //red
- 65, 0, 255, 0, //green
- 114, 0, 255, 0, //green
- 115, 255, 0, 0, //red
- 118, 255, 0, 0, //red
- 119, 0, 255, 0, //green
- 168, 0, 255, 0, //green
- 169, 255, 0, 0, //red
- 184, 255, 0, 0, //red
- 185, 0, 255, 0, //green
- 234, 0, 255, 0, //green
- 235, 255, 0, 0, //red
- 255, 255, 0, 0 //red
- };
- DEFINE_GRADIENT_PALETTE( candycane_gp) {
- 0 , 128, 128, 128, //white
- 32 , 128, 128, 128, //white
- 33 , 255, 0, 0, //red
- 66 , 255, 0, 0, //red
- 67 , 128, 128, 128, //white
- 100 , 128, 128, 128, //white
- 101 , 255, 0, 0, //red
- 134 , 255, 0, 0, //red
- 135 , 128, 128, 128, //white
- 168 , 128, 128, 128, //white
- 169 , 255, 0, 0, //red
- 202 , 255, 0, 0, //red
- 203 , 128, 128, 128, //white
- 236 , 128, 128, 128, //white
- 237 , 255, 0, 0, //red
- 255 , 255, 0, 0 //red
- };
- DEFINE_GRADIENT_PALETTE( snowynight_gp) {
- 0, 163, 182, 199,
- 41, 188, 192, 200,
- 117, 117, 157, 240,
- 204, 117, 224, 240,
- 255, 163, 182, 199
- };
- DEFINE_GRADIENT_PALETTE( silvergold_gp) {
- 46, 191, 201, 224,
- 127, 255, 236, 133,
- 204, 191, 201, 224
- };
- const TProgmemRGBGradientPalettePtr gGradientPalettes[] = {
- holly_gp,
- candycane_gp,
- snowynight_gp,
- silvergold_gp
- };
Advertisement
Add Comment
Please, Sign In to add comment