Light Show library for organic, calm, light display.
Dependencies: BLE_API mbed nRF51822
Fork of mbed_blinky by
light_show.cpp
- Committer:
- nargetdev
- Date:
- 2016-01-30
- Revision:
- 24:52319c0a14b8
- Child:
- 25:d48f46d753fd
File content as of revision 24:52319c0a14b8:
#include "light_show.h" void Light_show::drive () { // printf("Updating RGB values...\r\n"); for (i=0; i<3; i++) { if (!(rgb & (0x1 << i) )) { if ( in > WAIT[i]) { // printf("%d, %d, result: %d\r\n", rgb, (0x1 << i), (!(rgb & (0x1 << i)) ) ); rgb_c[i] = -cos((in - WAIT[i])*SCALE[i]) + 1; } else { rgb_c[i] = 0.0; } } else rgb_c[i] = 0.0; pc->printf("%f\t",rgb_c[i]); } pc->printf("\n\r"); // exit(0); } void Light_show::randomize_params() { float rand_seed = t.read(); pc->printf("%f\n\r", rand_seed); int rand_int = t.read() * 7919; time_t seconds = time(NULL); pc->printf("Time as seconds since January 1, 1970 = %d\n\r", seconds); srand(rand_int); pc->printf("A random %d\r\n", rand() ); // generate random values in 0.0 - 1.0 uint8_t blah; for (int j = 0; j < 3; j++) { srand(rand_int+j); blah = rand(); SCALE[j] = (float) blah; SCALE[j] /= (float) 0xff; SCALE[j] = SCALE[j]*HPI + 1; pc->printf("scale %d, %f\n\r", i, SCALE[i]); srand(blah+j % 17 + 7); blah = rand(); WAIT[j] = (float) blah; WAIT[j] /= (float) 0xff; WAIT[j] *= HPI; pc->printf("wait %d, %f\n\r", i, WAIT[i]); } rgb = 0x0; printf("Params Initialized\r\n"); }