Initial (buggy) version

Dependencies:   BLE_API mbed nRF51822

Fork of nRF51822_SimpleControls by RedBearLab

Revision:
6:074f5ec7428c
Parent:
5:1f6311e0fc14
Child:
7:0db51a3107fc
diff -r 1f6311e0fc14 -r 074f5ec7428c patterns.cpp
--- a/patterns.cpp	Fri Dec 02 14:33:16 2016 +0000
+++ b/patterns.cpp	Fri Dec 09 15:50:13 2016 +0000
@@ -38,78 +38,59 @@
 }
 
 void candyChase(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
-    for (int q=0; q < 3; q++) {
-      for (uint16_t i=0; i < numLEDs; i++) {
-        neopixel_set_color(&m_strip, i, 255,255,255);    //turn every pixel white
-      }
-      for (uint16_t i=0; i < numLEDs; i=i+3) {
-        neopixel_set_color(&m_strip, i, 255,0,0);    //turn every third pixel red
-      }
-      neopixel_show(&m_strip);
-
-      wait_ms(delay);
-
-      for (uint16_t i=0; i < numLEDs; i=i+3) {
-        neopixel_set_color(&m_strip, i, 0,0,0);        //turn every third pixel off
-      }
+    
+    for (int i=0; i < numLEDs; i++) 
+        neopixel_set_color(&m_strip, i, 255,255,255);  //turn every pixel white
+  
+    for (int i=0; i < numLEDs-1; i++) {
+        neopixel_set_color(&m_strip, i, 255,255,255);
+        neopixel_set_color(&m_strip, i+1, 255,0,0);    //turn on a red pixel and move it
+        neopixel_show(&m_strip);
+        wait_ms(delay); 
     }
-  }
+    wait_ms(delay);
+    
+    for (int i=0; i < numLEDs; i++) 
+        neopixel_set_color(&m_strip, i, 255,0,0);  //turn every pixel red
+  
+    for (int i=0; i < numLEDs-1; i++) {
+        neopixel_set_color(&m_strip, i, 255,0,0);
+        neopixel_set_color(&m_strip, i+1, 255,255,255);    //turn on a white pixel and move it
+        neopixel_show(&m_strip);
+        wait_ms(delay); 
+    }
 }
 
 void snowflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
 
-    // Setup the pixel array
-    int pixel[numLEDs];
-    for(int p=0; p<numLEDs; p++)
-      pixel[p] = rand()%255; 
-    
-
-    // Run some snowflake cycles
-    for (int j=0; j<20; j++) {
-        // Every five cycles, light a new pixel
-        if((j%5)==0)
-          neopixel_set_color(&m_strip, rand()%numLEDs, 255,255,255);
-        
-        // Dim all pixels by 10
-        for(int p=0; p<numLEDs; p++){
-          neopixel_set_color(&m_strip, p, pixel[p],pixel[p],pixel[p] );
-          pixel[p] =  pixel[p] - 10;
-        }
+    for (int i=0; i < numLEDs; i++) 
+        neopixel_set_color(&m_strip, i, 0,0,235);  //turn every pixel blue
+  
+    for (int i=0; i < numLEDs-1; i++) {
+        neopixel_set_color(&m_strip, i, 0,0,235);
+        neopixel_set_color(&m_strip, i+1, 255,255,255);    //turn on a white pixel and move it
         neopixel_show(&m_strip);
-        wait_ms(delay);
+        wait_ms(delay); 
     }
 }
 
 void iceflakes(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
-
-    // Setup the pixel array
-    int pixel[numLEDs];
-    for(int p=0; p<numLEDs; p++)
-      pixel[p] = rand()%255; 
     
-    // Run some snowflake cycles
-    for (int j=0; j<20; j++) {
-        // Every five cycles, light a new pixel
-        if((j%5)==0)
-          neopixel_set_color(&m_strip, rand()%numLEDs, 0,0,255);
-        
-        // Dim all pixels by 10
-        for(int p=0; p<numLEDs; p++){
-          neopixel_set_color(&m_strip, p, 0,0,pixel[p] );
-          pixel[p] =  pixel[p] - 10;
-        }
-       neopixel_show(&m_strip);
-       wait_ms(delay);
-    }
-}
+    for (int i=0; i < numLEDs; i++) 
+        neopixel_set_color(&m_strip, i, 235,235,235);  //turn every pixel white
+  
+    int led_to_enable = rand()%numLEDs;
+    neopixel_set_color(&m_strip, led_to_enable, 0, 0, 235); // set random blue
+    neopixel_show(&m_strip);
+    wait_ms(delay); 
+}  
 
 void xmas(int delay, uint8_t numLEDs, neopixel_strip_t m_strip) {
     //All green
     for (int j=0; j<numLEDs; j++) 
         neopixel_set_color(&m_strip, j, 0,255,0);
     neopixel_show(&m_strip);
-    wait_ms(delay);
+    wait_ms(500);
     //All red
     for (int j=0; j<numLEDs; j++) 
         neopixel_set_color(&m_strip, j, 255,0,0);
@@ -119,7 +100,7 @@
     for (int j=0; j<numLEDs; j++) 
         neopixel_set_color(&m_strip, j, 0,255,0);
     neopixel_show(&m_strip);
-    wait_ms(delay);
+    wait_ms(500);
     for (int j=0; j<numLEDs; j++) 
     {
         neopixel_set_color(&m_strip, j, 255,0,0);