Browse Source

Fixed hsv error and made random1 use hsv

jediemil 5 years ago
parent
commit
6ddf913817
1 changed files with 18 additions and 12 deletions
  1. 18 12
      LedThing.ino/LedThing.ino.ino

+ 18 - 12
LedThing.ino/LedThing.ino.ino

@@ -166,7 +166,7 @@ void animation_rainbow() {
   fill_rainbow(leds, NUM_LEDS, animation_i, animation_var_1);
   FastLED.show();
   animation_i++;
-  animation_i %= 260;
+  animation_i %= 256;
   //Serial.println(animation_i);
   //Serial.println("Animation 1 step");
 }
@@ -222,12 +222,22 @@ void animation_random1() {
     animation_table_1[i][6] += 1;
     
     if (currentStep >= howManyCycles) {
-      uint8_t newR = (uint8_t) random(0, 255);
-      uint8_t newG = (uint8_t) random(0, 255);
-      uint8_t newB = (uint8_t) random(0, 255);
-      animation_table_1[i][3] = newR;
-      animation_table_1[i][4] = newG;
-      animation_table_1[i][5] = newB;
+//      uint8_t newR = (uint8_t) random(0, 255);
+//      uint8_t newG = (uint8_t) random(0, 255);
+//      uint8_t newB = (uint8_t) random(0, 255);
+
+      uint8_t newH = (uint8_t) random(0, 255);
+      uint8_t newS = (uint8_t) random(200, 255);
+      CRGB newColor = CRGB(0, 0, 0);
+      newColor.setHSV(newH, newS, 255);
+
+      Serial.println(newColor.r);
+      Serial.println(newColor.g);
+      Serial.println(newColor.b);
+      
+      animation_table_1[i][3] = newColor.r;
+      animation_table_1[i][4] = newColor.g;
+      animation_table_1[i][5] = newColor.b;
       
       uint8_t steps = (uint8_t) random(10, 50);
       animation_table_1[i][0] = r;
@@ -235,11 +245,7 @@ void animation_random1() {
       animation_table_1[i][2] = b;
       animation_table_1[i][7] = steps;
       animation_table_1[i][6] = 0;
-      if (i == 0) {
-      Serial.println(newR);
-      Serial.println(newG);
-      Serial.println(newB);
-    }
+      
     }
 //    uint8_t r = leds[i*5].r + animation_table_1[i][0];
 //    uint8_t g = leds[i*5].g + animation_table_1[i][1];