Interfaçage NeoPixel Ring 12, LPRO MECSE, Arnaud A.

Revision:
1:76fb4b762ab1
Parent:
0:754bf033bd47
Child:
2:327eb27271b0
--- a/neoPixelRing12.cpp	Wed Jun 17 16:33:48 2020 +0000
+++ b/neoPixelRing12.cpp	Mon Jun 22 20:58:34 2020 +0000
@@ -174,6 +174,116 @@
 }
 
 bool NeoPixelRing12::setLights(int nbOfLeds, char* rgbCode){
+    initLights();
+    rgbToDataStructure(rgbCode);
+    for(int i=0; i<nbOfLeds; i++){
+        for(int y=0; y<24; y++){
+            bit(rgbDataStructure[y]);
+        }
+    }
+    rst();
+    return true;
+}
+
+bool NeoPixelRing12::setLights(char RGBmap[12][7]){
+    char* buffer; 
+    initLights();
+    for(int i=0; i<12; i++){      
+        buffer=&RGBmap[i][0];
+        rgbToDataStructure(buffer);
+        for(int y=0; y<24; y++){
+            bit(rgbDataStructure[y]);
+        }
+    }
+    rst();
+    return true;
+}
+
+
+bool NeoPixelRing12::initLights(){
+    for(int y=0; y<24; y++){
+        bit(0);
+    }
+    rst();
+    return true;
+}
+
+bool NeoPixelRing12::circleUpAnimations(){
+    char buffer=0;
+    uint32_t rgb=0;
+    char str[7];
+    char redBuffer[255][7], greenBuffer[255][7], blueBuffer[255][7];
+    int i, y, z, x;
+     for(i=0; i<36; i++){
+        buffer+=7;
+        rgb = (buffer<<16);
+        sprintf(str, "%06x", rgb & 0xffffff);
+        strcpy(redBuffer[i], str);
+        rgb = (buffer<<8);
+        sprintf(str, "%06x", rgb & 0xffffff);
+        strcpy(greenBuffer[i], str);
+        rgb = buffer;
+        sprintf(str, "%06x", rgb & 0xffffff);
+        strcpy(blueBuffer[i], str);
+    } 
+    x=0;
+    for(y=0; y<3; y++){
+        for(i=0; i<12; i++){
+            x++;
+            initLights();
+            for(z=0; z<i; z++)
+                setLightsNoReset(1, redBuffer[x-z]);
+            setLightsNoReset(1, redBuffer[x]);
+            rst();
+            wait(0.07); 
+        }
+        for(i=1; i<=12; i++){
+            initLights();
+            setLightsNoReset(i, "000000");
+            rst();
+            wait(0.07); 
+        }
+    } 
+    x=0;
+    for(y=0; y<3; y++){
+        for(i=0; i<12; i++){
+            x++;
+            initLights();
+            for(z=0; z<i; z++)
+                setLightsNoReset(1, greenBuffer[x-z]);
+            setLightsNoReset(1, greenBuffer[x]);
+            rst();
+            wait(0.07); 
+        }
+        for(i=1; i<=12; i++){
+            initLights();
+            setLightsNoReset(i, "000000");
+            rst();
+            wait(0.07); 
+        }
+    } 
+    x=0;
+    for(y=0; y<3; y++){
+        for(i=0; i<12; i++){
+            x++;
+            initLights();
+            for(z=0; z<i; z++)
+                setLightsNoReset(1, blueBuffer[x-z]);
+            setLightsNoReset(1, blueBuffer[x]);
+            rst();
+            wait(0.07); 
+        }
+        for(i=1; i<=12; i++){
+            initLights();
+            setLightsNoReset(i, "000000");
+            rst();
+            wait(0.07); 
+        }
+    }   
+    return true;
+}
+
+bool NeoPixelRing12::setLightsNoReset(int nbOfLeds, char* rgbCode){
     rgbToDataStructure(rgbCode);
     for(int i=0; i<nbOfLeds; i++){
         for(int y=0; y<24; y++){