Browse Source

Added support for two splits (and goundwork for more)
First commit

jediemil 4 years ago
parent
commit
b086be5f7e
3 changed files with 277 additions and 198 deletions
  1. 29 20
      LedThing.ino/AnimationSetups.ino
  2. 120 88
      LedThing.ino/Animations.ino
  3. 128 90
      LedThing.ino/LedThing.ino.ino

+ 29 - 20
LedThing.ino/AnimationSetups.ino

@@ -1,34 +1,43 @@
-void setup_rainbow() {
-  normal_setup();
-  animation_var_1 = 5.12;
+//0: animation_number
+//1: NUM_LEDS
+//2: led_offset
+//3: speed
+//4: table
+//5: var_1
+//6: i
+//7: lastAnimationMillis
+
+void setup_rainbow(int currentStripDiv) {
+  normal_setup(currentStripDiv);
+  current_animation_table[currentStripDiv][5] = 5.12;
 }
 }
 
 
-void normal_setup() {
-  clear_strip();
-  animation_step_time = 100;
-  animation_i = 0;
-  animation_var_1 = 0;
+void normal_setup(int currentStripDiv) {
+  clear_strip(currentStripDiv);
+  current_animation_table[currentStripDiv][3] = 100;
+  current_animation_table[currentStripDiv][6] = 0;
+  current_animation_table[currentStripDiv][5] = 0;
 }
 }
 
 
-void clean_animation_table_1() {
+void clean_animation_table_1(int currentStripDiv) {
   for (int i = 0; i < 10; i++) {
   for (int i = 0; i < 10; i++) {
     for (int y = 0; y < 8; y++) {
     for (int y = 0; y < 8; y++) {
-      animation_table_1[i][y] = 0;
+      animation_table_1[currentStripDiv][i][y] = 0;
     }
     }
     //Start R, Start G, Start B, fR, fG, fB, cycle, how many cycles
     //Start R, Start G, Start B, fR, fG, fB, cycle, how many cycles
   }
   }
 }
 }
 
 
-void setup_random1() {
-  clean_animation_table_1();
-  normal_setup();
-  animation_var_1 = 10; //How many sections
-  animation_step_time = 100;
+void setup_random1(int currentStripDiv) {
+  clean_animation_table_1(currentStripDiv);
+  normal_setup(currentStripDiv);
+  current_animation_table[currentStripDiv][5] = 10; //How many sections
+  current_animation_table[currentStripDiv][3] = 100;
 }
 }
 
 
-void setup_random2() {
-  clean_animation_table_1();
-  normal_setup();
-  animation_var_1 = 5;
-  animation_step_time = 50;
+void setup_random2(int currentStripDiv) {
+  clean_animation_table_1(currentStripDiv);
+  normal_setup(currentStripDiv);
+  current_animation_table[currentStripDiv][5] = 5;
+  current_animation_table[currentStripDiv][3] = 50;
 }
 }

+ 120 - 88
LedThing.ino/Animations.ino

@@ -1,64 +1,93 @@
-void animation_rainbow() {
-  fill_rainbow(leds, NUM_LEDS, animation_i, animation_var_1);
+//0: animation_number
+//1: NUM_LEDS
+//2: led_offset
+//3: speed
+//4: table
+//5: var_1
+//6: i
+//7: lastAnimationMillis
+
+int getVariables(int stripDiv) {
+  return current_animation_table[stripDiv][1], current_animation_table[stripDiv][2], current_animation_table[stripDiv][6], current_animation_table[stripDiv][5];
+}
+
+void saveAnimI(int animI, int stripDiv) {
+  current_animation_table[stripDiv][6] = animI;
+}
+
+void animation_rainbow(int stripDiv) {
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  int h = animI;
+  for (int i = 0; i < numLeds; i++) {
+    h = (h + animVar1) % 256;
+    leds[i + offset] = CHSV(h, 255, 255);
+  }
+  //fill_rainbow(leds, NUM_LEDS, animation_i, animation_var_1);
   FastLED.show();
   FastLED.show();
-  animation_i++;
-  animation_i %= 256;
+  animI++;
+  animI %= 256;
+  saveAnimI(animI, stripDiv);
   //Serial.println(animation_i);
   //Serial.println(animation_i);
   //Serial.println("Animation 1 step");
   //Serial.println("Animation 1 step");
 }
 }
 
 
-void animation_running() {
+void animation_running(int stripDiv) {
   //Serial.println("Animation 2 step");
   //Serial.println("Animation 2 step");
-  leds[animation_i] = CRGB(100, 255, 200);
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  leds[animI] = CRGB(100, 255, 200);
   FastLED.show();
   FastLED.show();
-  animation_i++;
-  if (animation_i >= NUMBER_OF_LEDS) {
-    animation_i = 0;
-    clear_strip();
+  animI++;
+  if (animation_i >= numLeds) {
+    animI = 0;
+    clear_strip(stripDiv);
   }
   }
+  saveAnimI(animI, stripDiv);
 }
 }
 
 
-void animation_chasing() {
+void animation_chasing(int stripDiv) {
   //Serial.println("Animation 2 step");
   //Serial.println("Animation 2 step");
-  clear_strip();
-  leds[animation_i] = CRGB(100, 255, 200);
-  leds[(animation_i + 10) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[(animation_i + 20) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[((NUMBER_OF_LEDS) - animation_i) - 1] = CRGB(0, 255, 255);
-
-  leds[animation_i * 3 + 1] = CRGB(100, 255, 200);
-  leds[(animation_i * 3 + 1 + 10 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[(animation_i * 3 + 1 + 20 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[((NUMBER_OF_LEDS) - animation_i * 3 + 1) - 1 * 3] = CRGB(0, 255, 255);
-
-  leds[animation_i * 3 + 2] = CRGB(100, 255, 200);
-  leds[(animation_i * 3 + 2 + 10 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[(animation_i * 3 + 2 + 20 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
-  leds[((NUMBER_OF_LEDS) - animation_i * 3 + 2) - 1 * 3] = CRGB(0, 255, 255);
-  leds[(50 - animation_i - 10)] = CRGB(0, 255, 255);
-  leds[(50 - animation_i)] = CRGB(0, 255, 255);
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  clear_strip(stripDiv);
+  leds[animI] = CRGB(100, 255, 200);
+  leds[((animI + 10) % numLeds) + offset] = CRGB(100, 255, 200);
+  leds[((animI + 20) % numLeds) + offset] = CRGB(100, 255, 200);
+  leds[((numLeds) - animI) - 1 + offset] = CRGB(0, 255, 255);
+
+//  leds[animation_i * 3 + 1] = CRGB(100, 255, 200);
+//  leds[(animation_i * 3 + 1 + 10 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
+//  leds[(animation_i * 3 + 1 + 20 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
+//  leds[((NUMBER_OF_LEDS) - animation_i * 3 + 1) - 1 * 3] = CRGB(0, 255, 255);
+//
+//  leds[animation_i * 3 + 2] = CRGB(100, 255, 200);
+//  leds[(animation_i * 3 + 2 + 10 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
+//  leds[(animation_i * 3 + 2 + 20 * 3) % (NUMBER_OF_LEDS)] = CRGB(100, 255, 200);
+//  leds[((NUMBER_OF_LEDS) - animation_i * 3 + 2) - 1 * 3] = CRGB(0, 255, 255);
+//  leds[(50 - animation_i - 10)] = CRGB(0, 255, 255);
+//  leds[(50 - animation_i)] = CRGB(0, 255, 255);
   FastLED.show();
   FastLED.show();
-  animation_i++;
-  animation_i %= NUMBER_OF_LEDS;
+  animI++;
+  animI %= numLeds;
+  saveAnimI(animI, stripDiv);
 }
 }
 
 
-void animation_off() {
-  clear_strip();
-  animation_step_time = 10000;
+void animation_off(int stripDiv) {
+  clear_strip(stripDiv);
+  current_animation_table[stripDiv][3] = 10000;
 }
 }
 
 
-void animation_random1() {
-  int difference = NUM_LEDS / animation_var_1;
-
-  for (int i = 0; i < animation_var_1; i++) {
-    int howManyCycles = animation_table_1[i][7];
-    int currentStep = animation_table_1[i][6];
-    uint8_t startRed = animation_table_1[i][0];
-    uint8_t startGreen = animation_table_1[i][1];
-    uint8_t startBlue = animation_table_1[i][2];
-    uint8_t goalRed = animation_table_1[i][3];
-    uint8_t goalGreen = animation_table_1[i][4];
-    uint8_t goalBlue = animation_table_1[i][5];
+void animation_random1(int stripDiv) {
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  int difference = numLeds / animVar1;
+
+  for (int i = 0; i < animVar1; i++) {
+    int howManyCycles = animation_table_1[stripDiv][i][7];
+    int currentStep = animation_table_1[stripDiv][i][6];
+    uint8_t startRed = animation_table_1[stripDiv][i][0];
+    uint8_t startGreen = animation_table_1[stripDiv][i][1];
+    uint8_t startBlue = animation_table_1[stripDiv][i][2];
+    uint8_t goalRed = animation_table_1[stripDiv][i][3];
+    uint8_t goalGreen = animation_table_1[stripDiv][i][4];
+    uint8_t goalBlue = animation_table_1[stripDiv][i][5];
     uint8_t r = (goalRed - startRed) * currentStep / howManyCycles + startRed;
     uint8_t r = (goalRed - startRed) * currentStep / howManyCycles + startRed;
     uint8_t g = (goalGreen - startGreen) * currentStep / howManyCycles + startGreen;
     uint8_t g = (goalGreen - startGreen) * currentStep / howManyCycles + startGreen;
     uint8_t b = (goalBlue - startBlue) * currentStep / howManyCycles + startBlue;
     uint8_t b = (goalBlue - startBlue) * currentStep / howManyCycles + startBlue;
@@ -66,9 +95,9 @@ void animation_random1() {
     //    for (int led = 0; led < 10; led++) {
     //    for (int led = 0; led < 10; led++) {
     //      leds[led + i * 10] = CRGB(r, b, g);
     //      leds[led + i * 10] = CRGB(r, b, g);
     //    }
     //    }
-    leds[i * difference] = CRGB(r, b, g);
+    leds[i * difference + offset] = CRGB(r, b, g);
 
 
-    animation_table_1[i][6] += 1;
+    animation_table_1[stripDiv][i][6] += 1;
 
 
     if (currentStep >= howManyCycles) {
     if (currentStep >= howManyCycles) {
       //      uint8_t newR = (uint8_t) random(0, 255);
       //      uint8_t newR = (uint8_t) random(0, 255);
@@ -80,42 +109,43 @@ void animation_random1() {
       CRGB newColor = CRGB(0, 0, 0);
       CRGB newColor = CRGB(0, 0, 0);
       newColor.setHSV(newH, newS, 255);
       newColor.setHSV(newH, newS, 255);
 
 
-      animation_table_1[i][3] = newColor.r;
-      animation_table_1[i][4] = newColor.g;
-      animation_table_1[i][5] = newColor.b;
+      animation_table_1[stripDiv][i][3] = newColor.r;
+      animation_table_1[stripDiv][i][4] = newColor.g;
+      animation_table_1[stripDiv][i][5] = newColor.b;
 
 
       uint8_t steps = (uint8_t) random(50, 255);
       uint8_t steps = (uint8_t) random(50, 255);
-      animation_table_1[i][0] = r;
-      animation_table_1[i][1] = g;
-      animation_table_1[i][2] = b;
-      animation_table_1[i][7] = steps;
-      animation_table_1[i][6] = 0;
+      animation_table_1[stripDiv][i][0] = r;
+      animation_table_1[stripDiv][i][1] = g;
+      animation_table_1[stripDiv][i][2] = b;
+      animation_table_1[stripDiv][i][7] = steps;
+      animation_table_1[stripDiv][i][6] = 0;
 
 
     }
     }
   }
   }
-  for (int i = 0; i < animation_var_1; i++) {
-    uint8_t startRed = leds[i * difference].r;
-    uint8_t startGreen = leds[i * difference].g;
-    uint8_t startBlue = leds[i * difference].b;
-    uint8_t goalRed = leds[((i + 1) * difference) % NUM_LEDS].r;
-    uint8_t goalGreen = leds[((i + 1) * difference) % NUM_LEDS].g;
-    uint8_t goalBlue = leds[((i + 1) * difference) % NUM_LEDS].b;
+  for (int i = 0; i < animVar1; i++) {
+    uint8_t startRed = leds[i * difference + offset].r;
+    uint8_t startGreen = leds[i * difference + offset].g;
+    uint8_t startBlue = leds[i * difference + offset].b;
+    uint8_t goalRed = leds[((i + 1) * difference) % numLeds + offset].r;
+    uint8_t goalGreen = leds[((i + 1) * difference) % numLeds + offset].g;
+    uint8_t goalBlue = leds[((i + 1) * difference) % numLeds + offset].b;
     for (int currentStep = 1; currentStep < difference; currentStep++) {
     for (int currentStep = 1; currentStep < difference; currentStep++) {
       uint8_t r = (goalRed - startRed) * currentStep / difference + startRed;
       uint8_t r = (goalRed - startRed) * currentStep / difference + startRed;
       uint8_t g = (goalGreen - startGreen) * currentStep / difference + startGreen;
       uint8_t g = (goalGreen - startGreen) * currentStep / difference + startGreen;
       uint8_t b = (goalBlue - startBlue) * currentStep / difference + startBlue;
       uint8_t b = (goalBlue - startBlue) * currentStep / difference + startBlue;
-      leds[currentStep + i * difference] = CRGB(r, g, b);
+      leds[currentStep + i * difference + offset] = CRGB(r, g, b);
     }
     }
   }
   }
   FastLED.show();
   FastLED.show();
 }
 }
 
 
-void animation_rgb_light() {
-  FastLED.clear();
-  for (int i = 0; i < NUM_LEDS / 6; i++) {
-    leds[(i + animation_i) % NUM_LEDS] = CRGB(255, 0, 0);
-    leds[(i + animation_i + NUM_LEDS / 3) % NUM_LEDS] = CRGB(0, 255, 0);
-    leds[(i + animation_i + (NUM_LEDS / 3) * 2) % NUM_LEDS] = CRGB(0, 0, 255);
+void animation_rgb_light(int stripDiv) {
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  clear_strip(stripDiv);
+  for (int i = offset; i < (numLeds + offset) / 6; i++) {
+    leds[(i + animation_i) % numLeds] = CRGB(255, 0, 0);
+    leds[(i + animation_i + numLeds / 3) % numLeds] = CRGB(0, 255, 0);
+    leds[(i + animation_i + (numLeds / 3) * 2) % numLeds] = CRGB(0, 0, 255);
   }
   }
   //  for (int i = 1; i < NUM_LEDS/6; i++) { // Made an animation that already exists, but more complicated (animation_rainbow)
   //  for (int i = 1; i < NUM_LEDS/6; i++) { // Made an animation that already exists, but more complicated (animation_rainbow)
   //    uint8_t r = (0 - 255) * i / 25 + 255;
   //    uint8_t r = (0 - 255) * i / 25 + 255;
@@ -132,28 +162,30 @@ void animation_rgb_light() {
   //    leds[(i + animation_i + 25 + 100) % NUM_LEDS] = CRGB(r, g, b);
   //    leds[(i + animation_i + 25 + 100) % NUM_LEDS] = CRGB(r, g, b);
   //  }
   //  }
   FastLED.show();
   FastLED.show();
-  animation_i++;
-  animation_i %= NUM_LEDS;
+  animI++;
+  animI %= numLeds;
+  saveAnimI(animI, stripDiv);
 }
 }
 
 
-void animation_random2() {
-  if (random(0, animation_var_1) == 0) {
+void animation_random2(int stripDiv) {
+  int numLeds, offset, animI, animVar1 = getVariables(stripDiv);
+  if (random(0, animVar1) == 0) {
     //Serial.println("Stage 1");
     //Serial.println("Stage 1");
     for (int i = 0; i < 10; i++) {
     for (int i = 0; i < 10; i++) {
       //Serial.println("Stage 2");
       //Serial.println("Stage 2");
       //Serial.println(animation_table_1[i][1]);
       //Serial.println(animation_table_1[i][1]);
-      if (animation_table_1[i][1] == 0) {
+      if (animation_table_1[stripDiv][i][1] == 0) {
         //Serial.println("Stage 3");
         //Serial.println("Stage 3");
-        int randomDot = random(0, NUMBER_OF_LEDS);
+        int randomDot = random(0, numLeds);
         //Serial.println(randomDot);
         //Serial.println(randomDot);
         if (!leds[randomDot]) {
         if (!leds[randomDot]) {
           //Serial.println("Stage 4");
           //Serial.println("Stage 4");
-          animation_table_1[i][0] = random(0, 255);
-          animation_table_1[i][1] = 255;
-          animation_table_1[i][2] = randomDot;
-          animation_table_1[i][3] = 1;
+          animation_table_1[stripDiv][i][0] = random(0, 255);
+          animation_table_1[stripDiv][i][1] = 255;
+          animation_table_1[stripDiv][i][2] = randomDot;
+          animation_table_1[stripDiv][i][3] = 1;
           //Serial.println(animation_table_1[i][0]);
           //Serial.println(animation_table_1[i][0]);
-          leds[randomDot] = CHSV(animation_table_1[i][0], 255, 126);
+          leds[randomDot + offset] = CHSV(animation_table_1[stripDiv][i][0], 255, 126);
           break;
           break;
         }
         }
       }
       }
@@ -161,15 +193,15 @@ void animation_random2() {
   }
   }
 
 
   for (int i = 0; i < 10; i++) {
   for (int i = 0; i < 10; i++) {
-    if (animation_table_1[i][3] == 1) {
-      leds[animation_table_1[i][2]] = CHSV(animation_table_1[i][0], 255, 126);
-      animation_table_1[i][3] = 2;
-    } else if (animation_table_1[i][3] == 2) {
-      leds[animation_table_1[i][2]] = CHSV(animation_table_1[i][0], 255, 255);
-      animation_table_1[i][3] = 0;
+    if (animation_table_1[stripDiv][i][3] == 1) {
+      leds[animation_table_1[stripDiv][i][2] + offset] = CHSV(animation_table_1[stripDiv][i][0], 255, 126);
+      animation_table_1[stripDiv][i][3] = 2;
+    } else if (animation_table_1[stripDiv][i][3] == 2) {
+      leds[animation_table_1[stripDiv][i][2] + offset] = CHSV(animation_table_1[stripDiv][i][0], 255, 255);
+      animation_table_1[stripDiv][i][3] = 0;
     } else {
     } else {
-      animation_table_1[i][1] = max(animation_table_1[i][1] - 10, 0);
-      leds[animation_table_1[i][2]] = CHSV(animation_table_1[i][0], 255, animation_table_1[i][1]);
+      animation_table_1[stripDiv][i][1] = max(animation_table_1[stripDiv][i][1] - 10, 0);
+      leds[animation_table_1[stripDiv][i][2] + offset] = CHSV(animation_table_1[stripDiv][i][0], 255, animation_table_1[stripDiv][i][1]);
     }
     }
   }
   }
 
 

+ 128 - 90
LedThing.ino/LedThing.ino.ino

@@ -2,44 +2,52 @@
 #include <SPI.h>
 #include <SPI.h>
 #include <WiFiNINA.h>
 #include <WiFiNINA.h>
 
 
-#define NUM_LEDS 150
-//50
+#define NUM_LEDS 200 //150 //50
+#define NUM_LEDS_WS 150
+#define NUM_LEDS_TM 50
 #define DATA_PIN 9
 #define DATA_PIN 9
+#define DATA_PIN_2 10
 int NUMBER_OF_ANIMATIONS = 7;
 int NUMBER_OF_ANIMATIONS = 7;
-int NUMBER_OF_LEDS = 150;
-char ssid[] = "Telia-E39815";
-char pass[] = "B3C606D8E7";
+int NUMBER_OF_LEDS = 200; //150 //50
+char ssid[] = "Våfflan";
+char pass[] = "HemmaIoT";
 boolean doing_animation = true;
 boolean doing_animation = true;
 
 
 int current_animation = 0;
 int current_animation = 0;
+int current_animation_1 = 0;
 int loops_since_http = 0;
 int loops_since_http = 0;
 
 
 int animation_step_time = 0;
 int animation_step_time = 0;
 int animation_i = 0;
 int animation_i = 0;
 int animation_var_1 = 0;
 int animation_var_1 = 0;
-int animation_table_1[10][8] = {};
+int animation_table_1[2][10][8] = {};
+int number_of_splits = 2;
 
 
 long last_animation_millis = millis();
 long last_animation_millis = millis();
 long latest_animation_change = millis();
 long latest_animation_change = millis();
 
 
+int current_animation_table[2][8]; //animation_number, NUM_LEDS, led_offset, speed, table, var_1, i, lastAnimationMillis;
+
+bool split_animations = false;
+
 //typedef enum {STATE_A = 0, STATE_B = 1} State_type;
 //typedef enum {STATE_A = 0, STATE_B = 1} State_type;
-extern void animation_rainbow(); // forward declaration
-extern void animation_running(); // forward declaration
-extern void animation_chasing();
-extern void animation_off();
-extern void animation_random1();
-extern void animation_rgb_light();
-extern void animation_random2();
-
-void (*animation_table[])() = {animation_off, animation_rainbow, animation_running, animation_chasing, animation_random1, animation_rgb_light, animation_random2};
-
-extern void setup_rainbow(); // forward declaration
-extern void setup_random1();
-extern void normal_setup();
+extern void animation_rainbow(int); // forward declaration
+extern void animation_running(int); // forward declaration
+extern void animation_chasing(int);
+extern void animation_off(int);
+extern void animation_random1(int);
+extern void animation_rgb_light(int);
+extern void animation_random2(int);
+
+void (*animation_table[])(int) = {animation_off, animation_rainbow, animation_running, animation_chasing, animation_random1, animation_rgb_light, animation_random2};
+
+extern void setup_rainbow(int); // forward declaration
+extern void setup_random1(int);
+extern void normal_setup(int);
 extern void setup_chosen(int, int, CRGB, boolean, int, int);
 extern void setup_chosen(int, int, CRGB, boolean, int, int);
-extern void setup_random2();
+extern void setup_random2(int);
 
 
-void (*setup_table[])() = {animation_off, setup_rainbow, normal_setup, normal_setup, setup_random1, normal_setup, setup_random2};
+void (*setup_table[])(int) = {animation_off, setup_rainbow, normal_setup, normal_setup, setup_random1, normal_setup, setup_random2};
 
 
 CRGB leds[NUM_LEDS];
 CRGB leds[NUM_LEDS];
 
 
@@ -48,7 +56,12 @@ int status = WL_IDLE_STATUS;
 WiFiServer server(80);
 WiFiServer server(80);
 
 
 void setup() {
 void setup() {
-  setup_random1();
+  current_animation_table[0][0] = 0;
+  current_animation_table[0][1] = 150;
+  current_animation_table[0][2] = 0;
+  current_animation_table[1][1] = 50;
+  current_animation_table[1][2] = 150;
+  setup_random1(0);
   // put your setup code here, to run once:
   // put your setup code here, to run once:
   //Serial.begin(9600);
   //Serial.begin(9600);
   Serial.begin(9600);
   Serial.begin(9600);
@@ -57,7 +70,8 @@ void setup() {
   }
   }
   Serial.println("Starting");
   Serial.println("Starting");
 
 
-  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip ); //TM1804 BRG
+  FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS_WS).setCorrection( TypicalLEDStrip ); //TM1804 BRG //WS2812 GRB
+  FastLED.addLeds<TM1804, DATA_PIN_2, BRG>(leds, NUM_LEDS_TM).setCorrection( TypicalLEDStrip ); //TM1804 BRG //WS2812 GRB
   FastLED.setBrightness(255);
   FastLED.setBrightness(255);
   FastLED.clear();
   FastLED.clear();
   FastLED.show();
   FastLED.show();
@@ -121,24 +135,32 @@ void setup() {
   //  }
   //  }
   delay(1000);
   delay(1000);
   current_animation = 0;
   current_animation = 0;
-  setup_table[current_animation]();
+  setup_table[current_animation](0);
   Serial.println("Started");
   Serial.println("Started");
 }
 }
 
 
 void loop() {
 void loop() {
   loops_since_http += 1;
   loops_since_http += 1;
-  long current_millis = millis();
-  if (current_millis - last_animation_millis >= animation_step_time && loops_since_http < 100) {
-    if (doing_animation) {
-      animation_table[current_animation]();
-    } else {
-      if (animation_var_1 == 1) {
-        animation_fade_help();
-      } else {
-        delay(5);
+  if (loops_since_http < 100) {
+    for (int i = 0; i < number_of_splits; i++) {
+      long current_millis = millis();
+      if (current_millis - current_animation_table[i][7] >= animation_step_time) {
+        animation_table[current_animation_table[i][1]](i);
+        current_animation_table[i][7] = current_millis;
       }
       }
     }
     }
-    last_animation_millis = current_millis;
+  
+//    if (doing_animation) {
+//      animation_table[current_animation]();
+//    } else {
+//      if (animation_var_1 == 1) {
+//        animation_fade_help();
+//      } else {
+//        delay(5);
+//      }
+//    }
+//    last_animation_millis = current_millis;
+  
   } else {
   } else {
     loops_since_http = 0;
     loops_since_http = 0;
     //Serial.println("Waiting for animation");
     //Serial.println("Waiting for animation");
@@ -189,6 +211,8 @@ void process_HTTP() {
     int currentLoop = 0;
     int currentLoop = 0;
     int setting = 0;
     int setting = 0;
     int value = 0;
     int value = 0;
+    int modify_animation = current_animation_table[1][0];
+    byte current_strip_half = 0;
     String fullArguments = "";
     String fullArguments = "";
     while (client.connected()) {
     while (client.connected()) {
       if (client.available()) {
       if (client.available()) {
@@ -249,19 +273,29 @@ void process_HTTP() {
             Serial.println(fullArguments);
             Serial.println(fullArguments);
           }
           }
         } else if (readingState != 0) {
         } else if (readingState != 0) {
+          if (c == '0' || c == '1') {
+            readingState = 1;
+            split_animations = true;
+            current_strip_half = (byte) c;
+            if (c == '1') {
+              modify_animation = current_animation_table[1][0];
+            }
+          } else {
+            split_animations = false;
+          }
           if (c == 'y') {
           if (c == 'y') {
             readingState = 3;
             readingState = 3;
             continue;
             continue;
           } if (c == 'z') {
           } if (c == 'z') {
             readingState = 2;
             readingState = 2;
             continue;
             continue;
-          } else if (c == '(') {
-            anim = current_animation - 1;
+          } if (c == '(') {
+            anim = modify_animation - 1;
             if (anim < 0) {
             if (anim < 0) {
               anim = NUMBER_OF_ANIMATIONS - 1;
               anim = NUMBER_OF_ANIMATIONS - 1;
             }
             }
           } else if (c == ')') {
           } else if (c == ')') {
-            anim = current_animation + 1;
+            anim = modify_animation + 1;
           } else {
           } else {
             anim = c - 'A';
             anim = c - 'A';
           }
           }
@@ -290,17 +324,19 @@ void process_HTTP() {
     //Serial.println("client disconnected");
     //Serial.println("client disconnected");
     if (readingState == 1) {
     if (readingState == 1) {
       doing_animation = true;
       doing_animation = true;
-      setup_table[anim]();
-      current_animation = anim;
+      setup_table[anim](current_strip_half);
+      current_animation_table[current_strip_half][0] = anim;
       latest_animation_change = millis();
       latest_animation_change = millis();
 
 
     } else if (readingState == 3) {
     } else if (readingState == 3) {
       Serial.println(setting);
       Serial.println(setting);
       Serial.println(value);
       Serial.println(value);
       if (setting == 1) {
       if (setting == 1) {
-        animation_step_time = value;
+        current_animation_table[current_strip_half][3] = value;
+        //animation_step_time = value;
       } else if (setting == 2) {
       } else if (setting == 2) {
-        animation_var_1 = value;
+        //animation_var_1 = value;
+        current_animation_table[current_strip_half][5] = value;
       }
       }
     } else if (readingState == 2) {
     } else if (readingState == 2) {
       doing_animation = false;
       doing_animation = false;
@@ -315,58 +351,60 @@ void process_HTTP() {
   }
   }
 }
 }
 
 
-void clear_strip() {
-  FastLED.clear();
+void clear_strip(int stripDiv) {
+  for (int i = 0; i < current_animation_table[stripDiv][1]; i++) {
+    leds[i + current_animation_table[stripDiv][2]] = CRGB(0, 0, 0);
+  }
   FastLED.show();
   FastLED.show();
 }
 }
 
 
-void animation_fade_help() {
-  int leds1 = animation_table_1[0][0];
-  int leds2 = animation_table_1[0][1];
-  int finnishR = animation_table_1[0][2];
-  int finnishG = animation_table_1[0][3];
-  int finnishB = animation_table_1[0][4];
-  int cycles = animation_table_1[0][5];
-  int startR = animation_table_1[0][6];
-  int startG = animation_table_1[0][7];
-  int startB = animation_table_1[1][0];
-
-  uint8_t r = (finnishR - startR) * animation_i / cycles + startR;
-  uint8_t g = (finnishG - startG) * animation_i / cycles + startG;
-  uint8_t b = (finnishB - startB) * animation_i / cycles + startB;
-
-  for (int i = leds1; i <= leds2; i++) {
-    leds[i] = CRGB(r, g, b);
-  }
-  animation_i++;
-  if (animation_i >= cycles) {
-    for (int i = leds1; i < leds2; i++) {
-      leds[i] = CRGB(finnishR, finnishG, finnishB);
-    }
-    animation_var_1 = 0;
-  }
-  FastLED.show();
+void animation_fade_help() {//TODO MAKE WORKABLE FOR SPLIT STRIP-------------------------------------------------------------------------------------------------------------------------------------------------------------
+//  int leds1 = animation_table_1[0][0];
+//  int leds2 = animation_table_1[0][1];
+//  int finnishR = animation_table_1[0][2];
+//  int finnishG = animation_table_1[0][3];
+//  int finnishB = animation_table_1[0][4];
+//  int cycles = animation_table_1[0][5];
+//  int startR = animation_table_1[0][6];
+//  int startG = animation_table_1[0][7];
+//  int startB = animation_table_1[1][0];
+//
+//  uint8_t r = (finnishR - startR) * animation_i / cycles + startR;
+//  uint8_t g = (finnishG - startG) * animation_i / cycles + startG;
+//  uint8_t b = (finnishB - startB) * animation_i / cycles + startB;
+//
+//  for (int i = leds1; i <= leds2; i++) {
+//    leds[i] = CRGB(r, g, b);
+//  }
+//  animation_i++;
+//  if (animation_i >= cycles) {
+//    for (int i = leds1; i < leds2; i++) {
+//      leds[i] = CRGB(finnishR, finnishG, finnishB);
+//    }
+//    animation_var_1 = 0;
+//  }
+//  FastLED.show();
 }
 }
 
 
-void setup_chosen(int lamps1, int lamps2, CRGB newColor, boolean doFade = false, int cycles = 20, int cycleLength = 100) {
-  animation_step_time = cycleLength;
-  animation_var_1 = (int) doFade;
-  animation_i = 0;
-  doing_animation = false;
-  if (doFade) {
-    animation_table_1[0][0] = lamps1;
-    animation_table_1[0][1] = lamps2;
-    animation_table_1[0][2] = newColor.r;
-    animation_table_1[0][3] = newColor.g;
-    animation_table_1[0][4] = newColor.b;
-    animation_table_1[0][5] = cycles;
-    animation_table_1[0][6] = leds[lamps1].r;
-    animation_table_1[0][7] = leds[lamps1].g;
-    animation_table_1[1][0] = leds[lamps1].b;
-  } else {
-    for (int i = lamps1; i <= lamps2; i++) {
-      leds[i] = newColor;
-    }
-    FastLED.show();
-  }
+void setup_chosen(int lamps1, int lamps2, CRGB newColor, boolean doFade = false, int cycles = 20, int cycleLength = 100) { //TODO-------------------------------------------------------------------------------------------------------------------------------------------------------------
+//  animation_step_time = cycleLength;
+//  animation_var_1 = (int) doFade;
+//  animation_i = 0;
+//  doing_animation = false;
+//  if (doFade) {
+//    animation_table_1[0][0] = lamps1;
+//    animation_table_1[0][1] = lamps2;
+//    animation_table_1[0][2] = newColor.r;
+//    animation_table_1[0][3] = newColor.g;
+//    animation_table_1[0][4] = newColor.b;
+//    animation_table_1[0][5] = cycles;
+//    animation_table_1[0][6] = leds[lamps1].r;
+//    animation_table_1[0][7] = leds[lamps1].g;
+//    animation_table_1[1][0] = leds[lamps1].b;
+//  } else {
+//    for (int i = lamps1; i <= lamps2; i++) {
+//      leds[i] = newColor;
+//    }
+//    FastLED.show();
+//  }
 }
 }