Light Show library for organic, calm, light display.

Dependencies:   BLE_API mbed nRF51822

Fork of mbed_blinky by Mbed

Revision:
20:fa23847fbfef
Parent:
19:fabe9521b0a1
Child:
21:3960e3b8ca7b
--- a/main.cpp	Fri Dec 04 21:01:55 2015 +0000
+++ b/main.cpp	Fri Dec 04 21:29:49 2015 +0000
@@ -147,11 +147,30 @@
     bool mov;
     
     void random_init() {
+        random_init();
         float rand_seed = t.read();
         pc.printf("%f\n", rand_seed);
         
-        time_t seconds = time(NULL);
-        printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+        unsigned int seconds = time(NULL);
+        pc.printf("Time as seconds since January 1, 1970 = %d\n", seconds);
+        
+        srand(seconds);
+        pc.printf("A random %i", rand() );
+        
+        // generate random values in 0.0 - 1.0
+        uint8_t blah;
+        for (int j = 0; j < 3; j++) {
+            srand(seconds+j);
+            blah = rand();
+            SCALE[i] = (float) blah;
+            SCALE[i] /= (float) 0xff;
+            pc.printf("scale %d, %f\n", i, SCALE[i]);
+            srand(blah+j % 17 + 7);
+            blah = rand();
+            WAIT[i] = (float) blah;
+            WAIT[i] /= (float) 0xff;
+            pc.printf("scale %d, %f\n", i, WAIT[i]);
+        }
     }
     
     void update_rgb_values () {
@@ -187,6 +206,7 @@
 
 
 void show() {
+    // randomize the delay and scale values
     random_init();
     for (in = 0; in < hysteresis || rgb != 0x7; in = in + INCREMENT){
         #ifdef MKIT