Guest User

Untitled

a guest
May 14th, 2020
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.65 KB | None | 0 0
  1. // FastLED Setup
  2. #define FASTLED_INTERNAL
  3. #include <FastLED.h>
  4. #include <LEDMatrix.h>
  5. #include <FastLED_NeoMatrix.h>
  6. #include <SmartMatrix_GFX.h>
  7. #include <Framebuffer_GFX.h>
  8.  
  9. #define LEDtilewidth 4 // How much width each input controls
  10. #define LEDtileheight 10 // how high each strip is
  11. #define LEDtilehorz 7 // number of matrices arranged horizontally
  12. #define LEDtilevert 1  // how many tiles stacked vertically
  13. #define LEDstrips (LEDtilewidth*LEDtilehorz)
  14. #define LEDper (LEDtileheight*LEDtilevert)
  15. #define LEDnum (LEDstrips*LEDper)
  16.  
  17. // Used by NeoMatrix
  18. #define mw (LEDtilewidth *  LEDtilehorz)
  19. #define mh (LEDtileheight * LEDtilevert)
  20. #define NUMMATRIX (mw*mh)
  21.  
  22. // Compat for some other demos
  23. #define NUM_LEDS NUMMATRIX
  24. #define MATRIX_HEIGHT mh
  25. #define MATRIX_WIDTH mw
  26.  
  27. cLEDMatrix<LEDtilewidth, LEDtileheight, VERTICAL_MATRIX, LEDtilehorz, LEDtilevert , VERTICAL_BLOCKS> ledmatrix;
  28. CRGB *leds = ledmatrix[0];
  29.  
  30. cLEDMatrix<LEDtilewidth, LEDtileheight, VERTICAL_MATRIX, LEDtilehorz, LEDtilevert , VERTICAL_BLOCKS> ledmatrix2;
  31. CRGB *leds2 = ledmatrix2[0];
  32.  
  33. FastLED_NeoMatrix *matrix = new FastLED_NeoMatrix(leds2, LEDtilewidth, LEDtileheight, LEDtilehorz, LEDtilevert,
  34.   NEO_MATRIX_TOP + NEO_MATRIX_LEFT + NEO_MATRIX_COLUMNS + NEO_MATRIX_PROGRESSIVE + NEO_TILE_TOP + NEO_TILE_LEFT + NEO_TILE_PROGRESSIVE);
  35.  
  36. // LED Settings
  37. #define LEDtype WS2813
  38. #define LEDcorr TypicalSMD5050
  39. #define LEDdither 255     //try 0 to reduce flickering
  40. uint8_t LEDbright = 12;
  41. int LEDamps = 3000;
  42. uint8_t crossct;
  43. bool dir;
  44.  
  45.  
  46. void setup(){
  47.   // Initialize LEDs
  48.   FastLED.setMaxPowerInVoltsAndMilliamps(5,LEDamps); //play with the order here
  49.   //FastLED.setTemperature();
  50.   FastLED.setBrightness(LEDbright);
  51.   FastLED.setDither(LEDdither);
  52.   //FastLED.addLeds<7, WS2813, 19, GRB>(leds, LEDstrips*LEDper/7);
  53.  
  54.   FastLED.addLeds<LEDtype, PIN_C4, GRB>(leds, 0, LEDper).setCorrection(LEDcorr);
  55.   FastLED.addLeds<LEDtype, PIN_C3, GRB>(leds, LEDper*1, LEDper).setCorrection(LEDcorr);
  56.   FastLED.addLeds<LEDtype, PIN_C2, GRB>(leds, LEDper*2,LEDper).setCorrection(LEDcorr);
  57.   FastLED.addLeds<LEDtype, PIN_C1, GRB>(leds, LEDper*3,LEDper).setCorrection(LEDcorr);
  58.   FastLED.addLeds<LEDtype, PIN_C0, GRB>(leds, LEDper*4,LEDper).setCorrection(LEDcorr);
  59.   FastLED.addLeds<LEDtype, PIN_E1, GRB>(leds, LEDper*5,LEDper).setCorrection(LEDcorr);
  60.   FastLED.addLeds<LEDtype, PIN_E0, GRB>(leds, LEDper*6,LEDper).setCorrection(LEDcorr);
  61.   FastLED.addLeds<LEDtype, PIN_D7, GRB>(leds, LEDper*7,LEDper).setCorrection(LEDcorr);
  62.   FastLED.addLeds<LEDtype, PIN_D6, GRB>(leds, LEDper*8,LEDper).setCorrection(LEDcorr);
  63.   FastLED.addLeds<LEDtype, PIN_D5, GRB>(leds, LEDper*9,LEDper).setCorrection(LEDcorr);
  64.   FastLED.addLeds<LEDtype, PIN_D4, GRB>(leds, LEDper*10,LEDper).setCorrection(LEDcorr);
  65.   FastLED.addLeds<LEDtype, PIN_D1, GRB>(leds, LEDper*11,LEDper).setCorrection(LEDcorr);
  66.   FastLED.addLeds<LEDtype, PIN_D0, GRB>(leds, LEDper*12,LEDper).setCorrection(LEDcorr);
  67.   FastLED.addLeds<LEDtype, PIN_B7, GRB>(leds, LEDper*13,LEDper).setCorrection(LEDcorr);
  68.   FastLED.addLeds<LEDtype, PIN_B4, GRB>(leds, LEDper*14,LEDper).setCorrection(LEDcorr);
  69.   FastLED.addLeds<LEDtype, PIN_B3, GRB>(leds, LEDper*15,LEDper).setCorrection(LEDcorr);
  70.   FastLED.addLeds<LEDtype, PIN_B2, GRB>(leds, LEDper*16,LEDper).setCorrection(LEDcorr);
  71.   FastLED.addLeds<LEDtype, PIN_B1, GRB>(leds, LEDper*17,LEDper).setCorrection(LEDcorr);
  72.   FastLED.addLeds<LEDtype, PIN_B0, GRB>(leds, LEDper*18,LEDper).setCorrection(LEDcorr);
  73.   FastLED.addLeds<LEDtype, PIN_E7, GRB>(leds, LEDper*19,LEDper).setCorrection(LEDcorr);
  74.   FastLED.addLeds<LEDtype, PIN_E6, GRB>(leds, LEDper*20,LEDper).setCorrection(LEDcorr);
  75.   FastLED.addLeds<LEDtype, PIN_F0, GRB>(leds, LEDper*21,LEDper).setCorrection(LEDcorr);
  76.   FastLED.addLeds<LEDtype, PIN_F1, GRB>(leds, LEDper*22,LEDper).setCorrection(LEDcorr);
  77.   FastLED.addLeds<LEDtype, PIN_F2, GRB>(leds, LEDper*23,LEDper).setCorrection(LEDcorr);
  78.   FastLED.addLeds<LEDtype, PIN_F3, GRB>(leds, LEDper*24,LEDper).setCorrection(LEDcorr);
  79.   FastLED.addLeds<LEDtype, PIN_F4, GRB>(leds, LEDper*25,LEDper).setCorrection(LEDcorr);
  80.   FastLED.addLeds<LEDtype, PIN_F5, GRB>(leds, LEDper*26,LEDper).setCorrection(LEDcorr);
  81.   FastLED.addLeds<LEDtype, PIN_F6, GRB>(leds, LEDper*27,LEDper).setCorrection(LEDcorr);
  82.   FastLED.clear();
  83.   FastLED.show();
  84.  
  85.   // Initialize other components
  86.   Serial.begin(38400);
  87.   matrix->begin();
  88.   delay(500);
  89.   Serial.println("Start");
  90. }
  91.  
  92. void loop(){
  93.   //leds2[10] = CHSV(155, 255, 255);
  94.   //leds[10] = CHSV(255, 255, 255);
  95.   //leds2[10] = CHSV(155, 255, 255);
  96.   ledmatrix2.DrawLine(0, 0, 5, 5, CHSV(155, 255, 255));
  97.   ledmatrix.DrawLine(0, 0, 5, 5, CHSV(25, 255, 255));
  98.   for(int i = 0; i < LEDper*LEDstrips; i++){
  99.         leds[i] = blend( leds2[i], leds[i], beatsin8(14, 0, 255));   // Blend arrays of LEDs, third value is blend %
  100.       }
  101.   //leds[10] = blend( leds2[10], leds[10], 155);
  102.   matrix->show();
  103.   FastLED.show();
  104.  
  105.  
  106.  
  107. }
  108.  
  109. void crossfader(){
  110.   if(crossct >= 255){
  111.     PATTERNlist[patternum]();   // run completed pattern only when fading is complete
  112.   }
  113.   else if(crossct < 255){
  114.     crossct+=5;           // higher increase faster xfade
  115.     if(crossct > 255){   // overflow prevention
  116.       crossct = 255;
  117.     }
  118.     uint8_t blendamt = crossct;
  119.    
  120.     PATTERNlist[oldpattern]();    // Run the old pattern and save to array
  121.     for(uint16_t i = 0; i < LEDstrips*LEDper; i++){
  122.       ledbuffer[i] = leds[i];
  123.     }
  124.    
  125.     PATTERNlist[patternum]();   // Run the new pattern and save to array // Removed extra buffering
  126.      
  127.     for(uint16_t i = 0; i < LEDper; i++){     // blend em
  128.       leds[i] = blend( leds2[i], leds[i], blendamt);   // Blend arrays of LEDs, third value is blend %
  129.     }
  130.   }
  131. }
  132.  
  133. void patcrossproc(){                                // Every time you switch patterns run this to begin crossfading
  134.   oldpattern = patternum;                           // set the current pattern to be the old one so we can make it use the same variables
  135.   crossct = 0;                                      // reset the blend amount
  136.   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
  137.  
  138.   rowcount[0] = rowcount[1];          // copy row status to default rows, and reset them for the new pattern
  139.   rowcount[1] = 0;
  140.   colcount[0] = colcount[1];
  141.   colcount[1] = 0;
  142.   count[0] = count[1];
  143.   count[1] = 0;
  144.   hue[0] = hue[1];
  145.   hue[1] = 0;
  146.  
  147.   if(patternum > 2){
  148.     patternum = 0;
  149.   }
  150. }
  151.  
  152. uint8_t fetcher(uint8_t oldcheck){        // Get which counters should be used
  153.   if(oldcheck == oldpattern){
  154.     return 0;
  155.   } else {
  156.     return 1;
  157.   }
  158. }
Add Comment
Please, Sign In to add comment