Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define FASTLED_INTERRUPT_RETRY_COUNT 1
- #define FASTLED_ALLOW_INTERRUPTS 1
- #define USE_OCTOWS2811
- #include <OctoWS2811.h>
- #include <MIDI.h>
- #include <FastLED.h>
- #include <SD.h>
- // DEFIIIIINEEEE
- #define NUM_LEDS_PER_STRIP 256
- #define NUM_STRIPS 8
- #define NUM_PIXELS 2048
- #define BRIGHTNESS 32
- #define UPDATE_TIME 22 //ms between each LED update
- //VARIABLES
- CRGB leds[NUM_PIXELS];
- CRGBPalette16 VUPalette;
- CRGB palettes[18][4];
- CRGB modcolor;
- CRGB modcolor2;
- CRGB modcolor3;
- unsigned int previousMillis; //holds the previous millis
- unsigned int fpsMillis;
- unsigned int prevMil;
- unsigned int saveMillis;
- int fpsCount = 0;
- int fpsLoop = 0;
- int saveCount = 0;
- int ringMatrix[3][17];
- int shift1 = 0;
- int cc[127];
- int nrpn[512];
- int runner = 0;
- int cyclecolor[4];
- int times = 10;
- int cyclecounter = 0;
- int moddot[32];
- int moddotnrpn[32];
- int shiftdot[32];
- int pi;
- int pj;
- int bpmGlobal = 100;
- int bpmGlobal256 = 0;
- int bpmGlobal27 = 0;
- int bpmGlobalTrigger = 0;
- int periodGlobal = 60000 / bpmGlobal;
- bool pickedMode = 0;
- int saverMode;
- int saveTime = 8000; //800-23sec @30 . // . 1000 = 14sec @UPDATE_TIME 14 hmmmmm.... 14 = 14
- int saveChangeTime = 15000;
- File presetFile;
- const int chipSelect = BUILTIN_SDCARD;
- //MIDI_CREATE_DEFAULT_INSTANCE();
- MIDI_CREATE_INSTANCE(HardwareSerial, Serial2, MIDI); // teensy pin 8 & 9
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void setup() {
- randomSeed(analogRead(0));
- delay(300);
- LEDS.addLeds<OCTOWS2811>(leds, NUM_LEDS_PER_STRIP);
- LEDS.setBrightness(BRIGHTNESS);
- clearLEDRingAll();
- setPalettes();
- setVUPalette();
- setcyclecolor();
- setRingMatrix();
- MIDI.begin();
- Serial.begin(9600);
- Serial.println("RGB LED RING CONTROL v5");
- saveMillis = millis();
- Serial.print("Initializing SD card...");
- if (!SD.begin(chipSelect)) {
- Serial.println("initialization failed!");
- return;
- }
- Serial.println("initialization done.");
- }
- void loop() {
- /////// READ NEW MIDI DATA, UPDATE CC ARRAY
- midiParse();
- /////// run this loop every "times" milliseconds
- if (millis() >= previousMillis + UPDATE_TIME) {
- previousMillis = millis();
- fpsCount++;
- saveCount++;
- if (runner < NUM_PIXELS - 1) runner++; else runner = 0;
- fpsCounter();
- updateLEDRings();
- /////// OH WAIT MAYBE START SCREENSAVER?
- if (saveCount > saveTime) screensaver();
- /////// UPDATE LEDs AND GO SMOKE A SPLIFF
- LEDS.show();
- /////// GET READY FOR NEXT ROUND
- clearLEDRingAll(); // delete old LED values
- }
- fpsLoop++;
- }
- void updateLEDRings() {
- delay(1);
- /////// SET LEDS ARRAY TO NEW VALUES FROM CC ARRAY
- //Serial.println(nrpn[150]);
- // PRESET
- setLEDRingLine(1, 26, CHSV((runner % 1024) / 4 , 255, 255));
- setLEDRingDot(6, map(nrpn[51], 0, 4095, 0, 26), COLLFO1);
- for (int j = 0; j < 9; j++) {
- for (int i = 0; i < 31; i++) {
- int l = nrpn[201 + (10 * moddotnrpn[i]) + j];
- if (l > 0)
- leds[(moddot[i] * 32) - 1].addToRGB((l >> 6) + 20);
- }
- }
- }
- void setPalettes() {
- for (int i = 0; i < 4; i++) {
- palettes[0][i] = RED;
- palettes[1][i] = BLUE;
- palettes[2][i] = GREEN;
- palettes[3][i] = YELLOW;
- palettes[4][i] = ORANGE;
- palettes[5][i] = PINK;
- palettes[6][i] = WHITE;
- palettes[7][i] = CRGB::Aqua;
- palettes[8][i] = CRGB::Aquamarine;
- palettes[9][i] = CRGB::CadetBlue;
- palettes[10][i] = CRGB::CRGB::Coral;
- palettes[11][i] = CRGB::Aquamarine;
- palettes[12][i] = CRGB::Aquamarine;
- }
- for (int i = 0; i < 16; i++) {
- palettes[i][0].addToRGB(30);
- palettes[i][2].fadeLightBy(80);
- palettes[i][3].fadeLightBy(160);
- }
- }
- void setVUPalette() {
- VUPalette[0] = CRGB(0, 100, 0);
- VUPalette[1] = CRGB(0, 170, 0);
- VUPalette[2] = CRGB(0, 255, 0);
- VUPalette[3] = CRGB(200, 255, 0);
- VUPalette[4] = CRGB::Yellow;
- VUPalette[5] = CRGB(255, 150, 0);
- VUPalette[6] = CRGB(255, 0, 0);
- VUPalette[7] = CRGB(255, 0, 0);
- }
- void setcyclecolor() {
- cyclecolor[0] = 0xFF0000;
- cyclecolor[1] = 0xFF8f00;
- cyclecolor[2] = 0x0000FF;
- cyclecolor[3] = 0x00ff00;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////// LED RING FUNCTIONS
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void clearLEDRing(int ringNr) {
- int offseti = (ringNr - 1) * 32;
- for (int i = 0; i < 32; i++) leds[offseti + i] = 0;
- }
- void clearLEDRingAll(void) {
- for (int i = 0; i < NUM_PIXELS; i++) leds[i] = 0;
- }
- // Sets one LED at VALUE to COLOR
- void setLEDRingDot(int ringNr, int value, CRGB color) {
- leds[(ringNr - 1) * 32 + 2 + value] = color;
- }
- // Sets all LEDs up to VALUE to COLOR
- void setLEDRingLine(int ringNr, int value, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i <= value; i++) {
- leds[offseti + i] = color;
- }
- }
- // VU Style green-yellow-red
- void setLEDRingVU(int ringNr, int value) {
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i <= value; i++) {
- leds[offseti + i] = ColorFromPalette(VUPalette, i * 4, 255, LINEARBLEND);
- }
- }
- // VU Style green-yellow-red line
- void setLEDRingVULine(int ringNr, int value) {
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i <= value; i++) {
- leds[offseti + i] = ColorFromPalette(VUPalette, value * 4, 255, LINEARBLEND);
- }
- }
- // Divides LED Ring into SEGMENTS
- void setLEDRingDivide(int ringNr, int segments, CRGB color, CRGB bgcolor) {
- int stepSize = 31 / segments;
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i < 32; i++) leds[offseti + i] = bgcolor;
- for (int i = 0; i < segments + 1; i++) leds[offseti + (i * stepSize)] = color;
- }
- // Multiply LED Ring by STEPSIZE
- void setLEDRingMultiply(int ringNr, int stepSize, CRGB color, CRGB bgcolor) {
- if (stepSize == 0) stepSize = 32;
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i < 32; i++) leds[offseti + i] = bgcolor;
- for (int i = 0; i < 32; i = i + stepSize) leds[offseti + i] = color;
- }
- // Multiply LED Ring by STEPSIZE, Fading out
- void setLEDRingMultiplyFade(int ringNr, int stepSize, CRGB color, CRGB bgcolor) {
- if (stepSize == 0) stepSize = 32;
- int offseti = (ringNr - 1) * 32 + 2;
- for (int i = 0; i < 32; i++) leds[offseti + i] = bgcolor;
- for (int i = stepSize; i < 32; i = i + stepSize) {
- leds[offseti + i] = color;
- leds[offseti + i] = (i * 8);
- }
- leds[offseti] = color;
- }
- void setLEDRingFadeIn(int ringNr, int value, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- int j = 255 / value;
- for (int i = 0; i <= value; i++) {
- leds[offseti + i] = CRGB(
- map(color.r, 0 , 255, 0, i * j),
- map(color.g, 0 , 255, 0, i * j),
- map(color.b, 0 , 255, 0, i * j)
- );
- }
- leds[offseti + value] = color;
- }
- void setLEDRingFadeOut(int ringNr, int value, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- int j = 255 / value;
- for (int i = 0; i <= value; i++) {
- leds[offseti + i] = CRGB(
- map(color.r, 0 , 255, 0, 255 - (i * j)),
- map(color.g, 0 , 255, 0, 255 - (i * j)),
- map(color.b, 0 , 255, 0, 255 - (i * j))
- );
- }
- }
- // block segment number VALUE out of SEGMENTS
- void setLEDRingSegments(int ringNr, int value, int segments, CRGB color) {
- int stepSize = 216 / segments;
- int offseti = (ringNr - 1) * 32 + 2 + ((value * stepSize) >> 3);
- for (int i = 0; i <= (stepSize >> 3); i++) {
- leds[offseti + i] = color;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////PANNING / BIPOLAR///////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- // Panning v2
- void setLEDRingPan(int ringNr, int value, CRGB valcolor, CRGB centercolor, CRGB linecolor) {
- int offseti = (ringNr - 1) * 32 + 15;
- if (value > 0) {
- for (int i = 1; i < value; i++) leds[offseti + i] = linecolor;
- }
- else if (value < 0) {
- for (int i = -1; i > value ; i--) leds[offseti + i] = linecolor;
- }
- leds[offseti + value] = valcolor;
- leds[offseti] = centercolor;
- }
- void setLEDRingPitch(int ringNr, int value, CRGB valcolor, CRGB centercolor) {
- int offseti = (ringNr - 1) * 32 + 15;
- leds[offseti] = centercolor;
- if (abs(value) > 24) {
- if (value > 0) leds[offseti + value - 24] = valcolor.subtractFromRGB(180);
- else leds[offseti + value + 24] = valcolor.subtractFromRGB(180);
- }
- else if (abs(value) > 12) {
- if (value > 0) leds[offseti + value - 12] = valcolor.subtractFromRGB(100);
- else leds[offseti + value + 12] = valcolor.subtractFromRGB(100);
- }
- else leds[offseti + value] = valcolor;
- }
- // QPanning
- void setLEDRingQ(int ringNr, int value, CRGB valcolor, CRGB centercolor, CRGB linecolor) {
- int offseti = (ringNr - 1) * 32 + 15;
- for (int i = 1; i <= value; i++) {
- leds[offseti + i] = linecolor;
- leds[offseti - i] = linecolor;
- }
- leds[offseti + value] = valcolor;
- leds[offseti - value] = valcolor;
- leds[offseti] = centercolor;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////SINGLE LED///////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- // Blink one LED at LEDNR to COLOR at BPM speed
- void setLEDBlink(int ledNr, int bpm, CRGB color) {
- int period = 60000 / bpm;
- static unsigned int prevMil;
- if (millis() >= (prevMil + period)) {
- prevMil = millis();
- }
- else if (millis() >= (prevMil + 90)) {
- leds[ledNr] = BLACK;
- }
- else {
- leds[ledNr] = color;
- }
- }
- // Pulse one LED at LEDNR to COLOR at BPM speed
- void setLEDPulse(int ledNr, int bpm, CRGB color) {
- int period = 60000 / bpm;
- static CRGB col2;
- static unsigned int prevMil2;
- if (millis() >= (prevMil2 + period)) {
- prevMil2 = millis();
- col2 = color;
- }
- col2.subtractFromRGB(4);
- leds[ledNr] = col2;
- }
- void setLEDVLine (int value, CRGB color) {
- //16x17horiz pixel = 272
- int ringHoriz = value >> 4;
- for (int i = 0; i <= 2; i++) {
- setLEDRingHLine(ringMatrix[i][ringHoriz], value % 16, color);
- }
- }
- void setLEDHLine (int value, CRGB color) {
- //16x17horiz pixel = 272
- int ringVert = value >> 4;
- for (int i = 0; i < 17; i++) {
- setLEDRingVLine(ringMatrix[ringVert][i], value % 16, color);
- }
- }
- void setLEDHRGBLine (int value, CRGB color) {
- //16x17horiz pixel = 272
- int ringVert = value >> 4;
- for (int i = 0; i < 17; i++) {
- setLEDRingVLine(ringMatrix[ringVert][i], value % 16, CHSV(i << 4, 255, 255));
- }
- }
- void setLEDRingNightrider(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- static bool dir;
- if (bpmGlobalTrigger) {
- leds[offseti + bpmGlobal27] = color;
- leds[offseti + bpmGlobal27 - 1] = color.nscale8( 192);
- leds[offseti + bpmGlobal27 - 2] = color.nscale8( 128);
- leds[offseti + bpmGlobal27 - 3] = color.nscale8( 96);
- leds[offseti + bpmGlobal27 - 4] = color.nscale8( 64);
- leds[offseti + bpmGlobal27 - 5] = color.nscale8( 32);
- leds[offseti + bpmGlobal27 - 6] = color.nscale8( 16);
- }
- else {
- leds[offseti - bpmGlobal27 + 27] = color;
- leds[offseti - bpmGlobal27 + 28] = color.nscale8( 192);
- leds[offseti - bpmGlobal27 + 29] = color.nscale8( 128);
- leds[offseti - bpmGlobal27 + 30] = color.nscale8( 96);
- leds[offseti - bpmGlobal27 + 31] = color.nscale8( 64);
- leds[offseti - bpmGlobal27 + 32] = color.nscale8( 32);
- leds[offseti - bpmGlobal27 + 33] = color.nscale8( 16);
- }
- if (bpmGlobal27 == 0) dir = !dir;
- /*
- Serial.print(dir);
- Serial.print(" . ");
- Serial.print(bpmGlobal27);
- Serial.print(" . ");
- Serial.print(bpmGlobalTrigger);
- Serial.println(" . ");
- */
- }
- ////////////////////////////////////////////////////////////////////////////////////
- /////////////////////////HELPER / OTHERS///////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////
- // swipe dot
- void setLEDRingSwipe(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- leds[offseti + (runner % 30)] = color;
- }
- void setLEDRingSwipeSlow(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- leds[offseti + ((runner >> 1) % 30)] = color;
- }
- void setLEDRingSwipeSlow2(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- leds[offseti + ((runner >> 2) % 30)] = color;
- }
- void setLEDRingSwipeSlow4(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- leds[offseti + ((runner >> 3) % 30)] = color;
- }
- void setLEDRingBlinkFull(int ringNr, CRGB color) {
- int offseti = (ringNr - 1) * 32 + 2;
- if ((runner % 16) < 8) {
- for (int i = 0; i < 27; i++) {
- leds[offseti + i] = color;
- }
- } else {
- for (int i = 0; i < 27; i++) {
- leds[offseti + i] = 0x000000;
- }
- }
- }
- void setLEDModDot(CRGB color) {
- for (int i = 0; i < 31; i++) {
- leds[(moddot[i] * 32) - 1] = color;
- }
- }
- void setLEDRingVLine(int ringNr, int value, CRGB color) {
- int offseti = (ringNr * 32) - 17;
- leds[offseti + value] += color;
- leds[offseti - value] += color;
- }
- void setLEDRingHRand(int ringNr, int value, CRGB color) {
- int offseti = (ringNr * 32) - 17;
- bool odd = random(2);
- //Serial.println(odd);
- if (odd) leds[offseti + value] = color;
- else leds[offseti - value] = color;
- }
- void setLEDRingHLine(int ringNr, int value, CRGB color) {
- int offseti = (ringNr * 32) - 25;
- if (value < 8) {
- leds[offseti + value] += color;
- leds[offseti - value] += color;
- }
- else {
- leds[offseti + value] += color;
- leds[offseti + 32 - value] += color;
- }
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////SCREENSAVER////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void saverSnowfall(int spd) {
- while (!MIDI.read()) {
- int l = random(255);
- if ((saveCount % (spd > 1)) == 0) {
- if ((saveCount >> (spd - 3)) <= 17) setLEDRingHRand(ringMatrix[0][random(17)], random((saveCount >> (spd - 3)) % 17), CRGB(l, l, l));
- else if ((saveCount >> (spd - 3)) <= 34) {
- setLEDRingHRand(ringMatrix[0][random(17)], random(17), CRGB(l, l, l));
- setLEDRingHRand(ringMatrix[1][random(17)], random((saveCount >> (spd - 3)) % 17), CRGB(l, l, l));
- }
- else if ((saveCount >> (spd - 3)) > 34) {
- setLEDRingHRand(ringMatrix[0][random(17)], random(17), CRGB(l, l, l));
- setLEDRingHRand(ringMatrix[1][random(17)], random(17), CRGB(l, l, l));
- setLEDRingHRand(ringMatrix[2][random(17)], random((saveCount >> (spd - 3)) % 17), CRGB(l, l, l));
- }
- }
- for (int i = 0; i < 2047; i++) leds[i].fadeToBlackBy(1);
- delay(spd << 1);
- LEDS.show();
- saveCount++;
- if (millis() > (saveMillis + saveChangeTime)) {
- pickedMode = 0;
- break;
- }
- }
- if (pickedMode) {
- //saveCount = saveTime + 2; //test & copy to all
- pickedMode = 0;
- }
- }
- void saverAddRandomBWFade(int spd) {
- while (!MIDI.read()) {
- int l = random (255);
- leds[random(2048)] += CRGB (l, l, l);
- for (int i = 0; i < 2047; i++) leds[i].fadeToBlackBy(1);
- delay(spd);
- LEDS.show();
- if (millis() > (saveMillis + saveChangeTime)) {
- pickedMode = 0;
- break;
- }
- }
- pickedMode = 0;
- }
- void saverAddRandom(int spd) {
- while (!MIDI.read()) {
- leds[random(2048)] += CHSV(random(255), random(255), random(64));
- delay(spd);
- LEDS.show();
- if (millis() > (saveMillis + saveChangeTime)) {
- pickedMode = 0;
- break;
- }
- }
- pickedMode = 0;
- }
- /////////////// non interrupt
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- void saverHWave(int spd, int lngth, CRGB color) {
- int dir = (((saveCount << spd) >> 2) % ((17 + lngth) * 8)) >> 3;
- //Serial.println(dir);
- for (int j = 0; j < 3; j++) {
- for (int k = 0; k < lngth; k++) {
- CRGB c2 = color;
- if (((dir - k) > 0) && ((dir - k) < 17)) setLEDRingLine(ringMatrix[j][dir - k], 32, c2.subtractFromRGB((k * lngth * 4)));
- }
- }
- }
- void saverHueSnake (int spd) {
- int dir = ((saveCount << spd) % 2300);
- for (int i = 0; i < 255; i++) {
- int k = 2048 - dir + i;
- if ((k > 0) && (k < 2048)) leds[k] += CHSV(dir % 255, 255, i);
- }
- }
- void saverNightriderFine (int spd, int nwidth, CRGB color) {
- int dir = (((saveCount << spd) >> 2) % 544);
- if (dir > 272)dir = 544 - dir;
- for (int i = 0; i < nwidth; i++) {
- if ((dir + i) < 272) setLEDVLine(dir + i, color); // needs >=0 check
- setLEDVLine(dir - i, color);
- }
- }
- void saverNightriderFineH (int spd, int nwidth, CRGB color) {
- int dir = (((saveCount << spd) >> 2) % 93);
- if (dir > 47) dir = 93 - dir;
- for (int i = 0; i < nwidth; i++) {
- if ((dir + i) < 47) setLEDHLine(dir + i, color); // needs >=0 check
- setLEDHLine(dir, color);
- }
- }
- void saverNightriderFineHRGB (int spd, int nwidth, CRGB color) {
- int dir = (((saveCount << spd) >> 2) % 93);
- if (dir > 47) dir = 93 - dir;
- for (int i = 0; i < nwidth; i++) {
- if ((dir + i) < 47) setLEDHLine(dir + i, color); // needs >=0 check
- setLEDHRGBLine(dir, color);
- }
- }
- void saverHSwipeAll(int spd) {
- int dir = ((saveCount << spd) % 128) >> 3;
- for (int i = 0; i < 17; i++) {
- for (int j = 0; j <= 2; j++) setLEDRingHLine(ringMatrix[j][i], dir, RED);
- }
- }
- void saverVSwipeAll (int spd) {
- int dir = ((saveCount << spd) % 384) >> 3;
- if (dir < 16) {
- for (int i = 0; i < 17; i++) {
- setLEDRingVLine(ringMatrix[0][i], dir, RED);
- }
- }
- else if (dir < 32) {
- for (int i = 0; i < 17; i++) {
- setLEDRingVLine(ringMatrix[1][i], dir - 16, RED);
- }
- }
- else if (dir < 48) {
- for (int i = 0; i < 17; i++) {
- setLEDRingVLine(ringMatrix[2][i], dir - 32, RED);
- }
- }
- }
- void saverNightriderCoarse (int spd, CRGB color) {
- int dir = ((saveCount << spd) % 256) >> 3;
- if (dir >= 17) dir = 32 - dir;
- for (int i = 0; i <= 2; i++) {
- setLEDRingLine(ringMatrix[i][dir], 27, color);
- }
- delay(spd + 1);
- }
- /*
- void saverNightriderCoarse (int spd, CRGB color) {
- int dir = ((saveCount << spd) % 256) >> 3;
- if (dir >= 17) dir = 32 - dir;
- if (dir < 17) && ((dir + k) >= 0)) setLEDRingLine(ringMatrix[i][dir + k], 27, col );
- if (dir < 17) {
- for (int i = 0; i <= 2; i++) {
- setLEDRingLine(ringMatrix[i][dir], 27, color);
- }
- }
- else {
- for (int i = 0; i <= 2; i++) {
- setLEDRingLine(ringMatrix[i][33 - dir], 27, RED);
- }
- }
- delay(spd + 1);
- }
- */
- void saverNightriderCoarseFade(int spd, CRGB color) {
- int dir = ((saveCount << spd) % 272) >> 3;
- if (dir >= 18) dir = 34 - dir;
- for (int i = 0; i <= 2; i++) {
- for (int k = -2; k <= 2; k++) {
- CRGB col = color;
- if (abs(k) > 0) col = col / (abs(k) << 2);
- if (((dir + k) < 17) && ((dir + k) >= 0)) setLEDRingLine(ringMatrix[i][dir + k], 27, col );
- Serial.println(abs(k));
- }
- }
- delay(spd + 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment