example for using the rgb_color_sensor class

Dependencies:   mbed rgb_sensor

Revision:
4:fbbc729f4152
Parent:
3:3649eaf4f954
Child:
5:1b0f9427be32
--- a/main.cpp	Fri Jun 27 11:37:25 2014 +0000
+++ b/main.cpp	Fri Jun 27 12:15:32 2014 +0000
@@ -50,7 +50,8 @@
 }
 
 int main() {
-    TRGB color;
+    int i,j;
+    TRGB color, *p;
 
     console.baud(115200);
 
@@ -80,8 +81,18 @@
         /* stop time measurement */
         timer.stop();
 
-        console.printf("Captured %i values per %i ms\n\r", g_buffer_pos, timer.read_ms());
+        console.printf("// captured %i values in %i ms\n\rvar test = [\n\r", g_buffer_pos, timer.read_ms());
+        for(j=0; j<RGB_VALUES; j++)
+        {
+            p = &g_buffer[j];
+            for(i=0; i<COUNT(color.data); i++)
+                console.printf("%s%+04i", i?",":"\t[", p->data[i] / RGB_OVERSAMPLING);
+            if(j<(RGB_VALUES-1))
+                console.printf("],\n\r");
+        }
+        console.printf("]];\n\r\n\r");
 
-        delay_ms(250);
+        /* visible intersection between captures */
+        wait_ms(100);
     }
 }
\ No newline at end of file