TSL2561_demo_program

Dependencies:   TSL2561 mbed

Fork of TSL2561_Townsend by Tuan Anh Nguyen

Revision:
1:0f3c4d6b818a
Parent:
0:9ab53ff6cf89
diff -r 9ab53ff6cf89 -r 0f3c4d6b818a main.cpp
--- a/main.cpp	Tue Sep 10 15:15:20 2013 +0000
+++ b/main.cpp	Thu Jan 09 10:18:58 2014 +0000
@@ -1,7 +1,6 @@
 #include "mbed.h"
 #include "TSL2561.h"
 
-
 Serial PC(USBTX, USBRX);
 
 #define PC_PRINTX(z,x)             if(z==1) PC.printf(x);
@@ -12,6 +11,9 @@
 DigitalOut myled(LED1);
 TSL2561 tsl2561(TSL2561_ADDR_FLOAT);
 
+Timer setuptimer;
+Timer executetimer;
+
 void setup(void){
 
     if (tsl2561.begin()) {    
@@ -36,8 +38,11 @@
 int main() {  
     
     PC_PRINTLNX(1,"----------START-------------");
-    
+    setuptimer.start();
     setup();    
+    setuptimer.stop();
+    PC_PRINTLNXY(1,"Setup time: %f",setuptimer.read());
+    setuptimer.reset();
     
     uint16_t x,y,z;
       
@@ -47,13 +52,18 @@
         // Simple data read example. Just read the infrared, fullspecrtrum diode 
         // or 'visible' (difference between the two) channels.
         // This can take 13-402 milliseconds! Uncomment whichever of the following you want to read
+        
+        executetimer.start();
         x = tsl2561.getLuminosity(TSL2561_VISIBLE);     
         y = tsl2561.getLuminosity(TSL2561_FULLSPECTRUM);
         z = tsl2561.getLuminosity(TSL2561_INFRARED);
+        executetimer.stop();
         
         PC_PRINTLNXY(1,"Visible: %d",x);
         PC_PRINTLNXY(1,"Full Spectrum: %d",y);
         PC_PRINTLNXY(1,"Infrared: %d",z);
+        PC_PRINTLNXY(1,"Execution Time: %f",executetimer.read());
+        executetimer.reset();
         
         //More advanced data read example. Read 32 bits with top 16 bits IR, bottom 16 bits full spectrum
         //That way you can do whatever math and comparisons you want!