TSGames1 3 жил өмнө
parent
commit
ccb08e8433
1 өөрчлөгдсөн 13 нэмэгдсэн , 3 устгасан
  1. 13 3
      Digispark_Test.ino

+ 13 - 3
Digispark_Test.ino

@@ -55,13 +55,23 @@ double hue = 0.0;
     
    for(int i=0;i<NUMPIXELS;i++){
     int r,g,b;
-    int hueOffset = (abs(CENTER-i)/(float)CENTER) * 75;
-    HSVtoRGB(hue + hueOffset, 100, 15,r,g,b);   
+    int hueOffset = (abs(CENTER-i)/(float)CENTER) * 150;
+    double h = (hue + hueOffset)/360.,y;
+    if(h>1) h -= (int)h;
+    if(h<=0.5)
+      y = pow(h,2)*2;
+    else 
+      y = 1-pow(1-h,2)*2;
+
+    HSVtoRGB(y*360, 100, 15,r,g,b);   
     pixels.setPixelColor(i, pixels.Color(r,g,b)); // Moderately bright green color.
    }
-   hue += 0.5;
+   hue -= 0.25;
    if(hue>=360) {
     hue -= 360;
+   }
+   if(hue<=0) {
+    hue = 360 + hue;
    }
      pixels.show(); // This sends the updated pixel color to the hardware.
     delay(15); // Delay for a period of time (in milliseconds).