-
Notifications
You must be signed in to change notification settings - Fork 1
/
FirstLight_2.ino
70 lines (59 loc) · 2.91 KB
/
FirstLight_2.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#define FASTLED_INTERRUPT_RETRY_COUNT 1
#include "FastLED.h"
#include "FlexTimer.h"
#include "FastFX.h"
#include "FFXCoreEffects.h"
// How many leds are in the strip?
#define NUM_LEDS 100
// Data pin that led data will be written out over
#define DATA_PIN 5
// This is an array of leds. One item for each led in your strip.
CRGB leds[NUM_LEDS];
FFXController fxctrlr = FFXController();
// Create the custom effect class - override the writeNextFrame method to create the animation
class FirstLightFX : public FFXBase {
public:
FirstLightFX(uint16_t initSize) : FFXBase( initSize,/* interval */ 20UL,
/* min interval */ 10UL,
/* max interval */ 100UL ) {
currColor.setColorMode( FFXColor::FFXColorMode::singleCRGB );
currColor.setCRGB( CRGB::White );
}
virtual void initLeds( CRGB *bufLeds ) override {
fill_solid( bufLeds, numLeds, CRGB::Black );
}
virtual void writeNextFrame( CRGB *bufLeds ) override {
fadeToBlackBy( bufLeds, numLeds, 50 );
bufLeds[getMovementPhase()-1] = currColor.getCRGB();
switch (currColor.getColorMode()) {
// Blend the moving pixel through the entire palette range
case FFXColor::FFXColorMode::palette256 : { currColor.step(); break; }
// Step through the active colors in the palette - switching at either end of the strip
case FFXColor::FFXColorMode::palette16 : { if (getCurrPhase()==0 || getCurrPhase()==numLeds) { currColor.step(); } break; }
default: { }
}
}
};
// This function sets up the leds and tells the controller about them
// Then creates and adds the effect for the primary segment.
void setup() {
// sanity check delay - allows reprogramming if accidently blowing power w/leds
delay(1000);
pinMode( 5, OUTPUT );
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.clear();
fxctrlr.initialize( new FFXFastLEDPixelController( leds, NUM_LEDS ) );
fxctrlr.getPrimarySegment()->setFX( new FirstLightFX( NUM_LEDS ) );
fxctrlr.getPrimarySegment()->setBrightness( 100 );
// fxctrlr.getPrimarySegment()->getFrameView()->setCrossFade(false);
// fxctrlr.getPrimarySegment()->getFX()->setInterval( 30 );
fxctrlr.getPrimarySegment()->getFX()->setMovement( FFXBase::MovementType::MVT_BACKFORTH );
// fxctrlr.getPrimarySegment()->getFX()->getFXColor().setColorMode( FFXColor::FFXColorMode::palette16 );
// fxctrlr.getPrimarySegment()->getFX()->getFXColor().setPalette( NamedPalettes::getInstance()["multi"] );
// fxctrlr.getPrimarySegment()->getFX()->getFXColor().setPaletteRange( 6 );
fxctrlr.getPrimarySegment()->getFX()->getFXColor().setColorMode( FFXColor::FFXColorMode::palette256 );
fxctrlr.getPrimarySegment()->getFX()->getFXColor().setPalette( NamedPalettes::getInstance()["party"] );
}
void loop() {
fxctrlr.update();
}