Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // FastLED Setup
- #define FASTLED_INTERNAL
- #include <FastLED.h>
- #include <LEDMatrix.h>
- #include <FastLED_NeoMatrix.h>
- #include <SmartMatrix_GFX.h>
- #include <Framebuffer_GFX.h>
- #define LEDtilewidth 4 // How much width each input controls
- #define LEDtileheight 10 // how high each strip is
- #define LEDtilehorz 7 // number of matrices arranged horizontally
- #define LEDtilevert 1 // how many tiles stacked vertically
- #define LEDstrips (LEDtilewidth*LEDtilehorz)
- #define LEDper (LEDtileheight*LEDtilevert)
- #define LEDnum (LEDstrips*LEDper)
- // Used by NeoMatrix
- #define mw (LEDtilewidth * LEDtilehorz)
- #define mh (LEDtileheight * LEDtilevert)
- #define NUMMATRIX (mw*mh)
- // Compat for some other demos
- #define NUM_LEDS NUMMATRIX
- #define MATRIX_HEIGHT mh
- #define MATRIX_WIDTH mw
- cLEDMatrix<LEDtilewidth, LEDtileheight, VERTICAL_MATRIX, LEDtilehorz, LEDtilevert , VERTICAL_BLOCKS> ledmatrix;
- CRGB *leds = ledmatrix[0];
- cLEDMatrix<LEDtilewidth, LEDtileheight, VERTICAL_MATRIX, LEDtilehorz, LEDtilevert , VERTICAL_BLOCKS> ledmatrix2;
- CRGB *leds2 = ledmatrix2[0];
- FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds2, LEDtilewidth, LEDtileheight, LEDtilehorz, LEDtilevert,
- NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE + NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_PROGRESSIVE);
- // LED Settings
- #define LEDtype WS2813
- #define LEDcorr TypicalSMD5050
- #define LEDdither 255 //try 0 to reduce flickering
- uint8_t LEDbright = 12;
- int LEDamps = 3000;
- uint8_t crossct;
- bool dir;
- void setup(){
- // Initialize LEDs
- FastLED.setMaxPowerInVoltsAndMilliamps(5,LEDamps); //play with the order here
- //FastLED.setTemperature();
- FastLED.setBrightness(LEDbright);
- FastLED.setDither(LEDdither);
- //FastLED.addLeds<7, WS2813, 19, GRB>(leds, LEDstrips*LEDper/7);
- FastLED.addLeds<LEDtype, PIN_C4, GRB>(leds, 0, LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C3, GRB>(leds, LEDper*1, LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C2, GRB>(leds, LEDper*2,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C1, GRB>(leds, LEDper*3,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_C0, GRB>(leds, LEDper*4,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E1, GRB>(leds, LEDper*5,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E0, GRB>(leds, LEDper*6,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D7, GRB>(leds, LEDper*7,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D6, GRB>(leds, LEDper*8,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D5, GRB>(leds, LEDper*9,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D4, GRB>(leds, LEDper*10,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D1, GRB>(leds, LEDper*11,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_D0, GRB>(leds, LEDper*12,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B7, GRB>(leds, LEDper*13,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B4, GRB>(leds, LEDper*14,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B3, GRB>(leds, LEDper*15,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B2, GRB>(leds, LEDper*16,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B1, GRB>(leds, LEDper*17,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_B0, GRB>(leds, LEDper*18,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E7, GRB>(leds, LEDper*19,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_E6, GRB>(leds, LEDper*20,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F0, GRB>(leds, LEDper*21,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F1, GRB>(leds, LEDper*22,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F2, GRB>(leds, LEDper*23,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F3, GRB>(leds, LEDper*24,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F4, GRB>(leds, LEDper*25,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F5, GRB>(leds, LEDper*26,LEDper).setCorrection(LEDcorr);
- FastLED.addLeds<LEDtype, PIN_F6, GRB>(leds, LEDper*27,LEDper).setCorrection(LEDcorr);
- FastLED.clear();
- FastLED.show();
- // Initialize other components
- Serial.begin(38400);
- matrix->begin();
- delay(500);
- Serial.println("Start");
- }
- void loop(){
- //leds2[10] = CHSV(155, 255, 255);
- //leds[10] = CHSV(255, 255, 255);
- //leds2[10] = CHSV(155, 255, 255);
- ledmatrix2.DrawLine(0, 0, 5, 5, CHSV(155, 255, 255));
- ledmatrix.DrawLine(0, 0, 5, 5, CHSV(25, 255, 255));
- for(int i = 0; i < LEDper*LEDstrips; i++){
- leds[i] = blend( leds2[i], leds[i], beatsin8(14, 0, 255)); // Blend arrays of LEDs, third value is blend %
- }
- //leds[10] = blend( leds2[10], leds[10], 155);
- matrix->show();
- FastLED.show();
- }
- void crossfader(){
- if(crossct >= 255){
- PATTERNlist[patternum](); // run completed pattern only when fading is complete
- }
- else if(crossct < 255){
- crossct+=5; // higher increase faster xfade
- if(crossct > 255){ // overflow prevention
- crossct = 255;
- }
- uint8_t blendamt = crossct;
- PATTERNlist[oldpattern](); // Run the old pattern and save to array
- for(uint16_t i = 0; i < LEDstrips*LEDper; i++){
- ledbuffer[i] = leds[i];
- }
- PATTERNlist[patternum](); // Run the new pattern and save to array // Removed extra buffering
- for(uint16_t i = 0; i < LEDper; i++){ // blend em
- leds[i] = blend( leds2[i], leds[i], blendamt); // Blend arrays of LEDs, third value is blend %
- }
- }
- }
- void patcrossproc(){ // Every time you switch patterns run this to begin crossfading
- oldpattern = patternum; // set the current pattern to be the old one so we can make it use the same variables
- crossct = 0; // reset the blend amount
- patternum++; // increase pattern number -> this just goes in sequence, but the best part of this is that you can control this by remote or any other system
- rowcount[0] = rowcount[1]; // copy row status to default rows, and reset them for the new pattern
- rowcount[1] = 0;
- colcount[0] = colcount[1];
- colcount[1] = 0;
- count[0] = count[1];
- count[1] = 0;
- hue[0] = hue[1];
- hue[1] = 0;
- if(patternum > 2){
- patternum = 0;
- }
- }
- uint8_t fetcher(uint8_t oldcheck){ // Get which counters should be used
- if(oldcheck == oldpattern){
- return 0;
- } else {
- return 1;
- }
- }
Add Comment
Please, Sign In to add comment