Library for using the AMS TSL45315 Ambient Light Sensor

Revision:
1:303c95402cdc
Parent:
0:cafc6c4ed875
Child:
2:2946a5d334a0
--- a/tsl45315.hpp	Mon Mar 24 17:00:33 2014 +0000
+++ b/tsl45315.hpp	Tue Mar 25 10:54:56 2014 +0000
@@ -32,19 +32,23 @@
  *
  * Example:
  * @code
+ * #include "mbed.h"
+ * #include "tsl45315.h"
  * Serial pc(USBTX, USBRX);
- * TSL45x::TSL45315 sensor(p9, p10);
+ * //TSL45x::TSL45315 sensor(p9, p10);
+ * //TSL45x::TSL45315 sensor(p9, p10, M1);
+ * TSL45x::TSL45315 sensor(p9, p10, I2C_FREQ, 0.5);
+ * //TSL45x::TSL45315 sensor(p9, p10, I2C_FREQ, 1.0, M1);
  *
- * int main()
+ * int main( void )
  * {
  *   pc.printf("TSL45315 Illumination Sensor\n");
  *
  *   pc.printf("ID:\t%x\n", sensor.getID());
- *   pc.printf("M:\t%x\n", M1);
  *   pc.printf("Multiplier:\t%x\n", sensor.getMultiplier());
  *
  *   while(1) {
- *
+ *        //sensor.getLuxData();
  *        pc.printf("Illumination: %u lux\n",sensor.getLux());
  *
  *        wait(1);
@@ -65,23 +69,44 @@
     uint8_t multiplier;
 
 public:
-    /** Create a TSL45315 instance
+    /** Create a TSL45315 instance without variable integration time ( set to M1)
+    *   with integrated ticker to repeatedly update the illumination value. 
     * @param sda - I2C Dataline pin
     * @param scl - I2C Clockline pin
+    * @param i2c_freq - choose the i2c frequency
+    * @param t - ticker interval in seconds
     */
-    TSL45315(PinName sda, PinName scl);
+    TSL45315(PinName sda, PinName scl, int i2c_freq, float t);
     
-    /** Create a TSL45315 instance with variable integration time
+    /** Create a TSL45315 instance with variable integration time (M1,M2,M4)  
+    *   and with integrated ticker to repeatedly update the illumination value. 
+    * @param sda - I2C Dataline pin
+    * @param scl - I2C Clockline pin
+    * @param i2c_freq - choose the i2c frequency
+    * @param mult - Multiplier with corresponding integration time (M1 = 400ms, M2 = 200ms, M4 = 100ms)
+    * @param t - ticker interval in seconds
+    */
+    TSL45315(PinName sda, PinName scl, int i2c_freq, float t, uint8_t mult);
+    
+    /** Create a TSL45315 instance with variable integration time (M1,M2,M4)  
+    *   without integrated ticker to repeatedly update the illumination value. 
+    *   For use with seperate ticker or RtosTimer.
     * @param sda - I2C Dataline pin
     * @param scl - I2C Clockline pin
     * @param mult - Multiplier with corresponding integration time (M1 = 400ms, M2 = 200ms, M4 = 100ms)
     */
     TSL45315(PinName sda, PinName scl, uint8_t mult);
     
-    /**
-    *   sets the address in the command register of the
+    /** Create a TSL45315 instance without variable integration time ( set to M1) 
+    *   and without integrated ticker to repeatedly update the illumination value. 
+    *   For use with seperate ticker or RtosTimer.
+    * @param sda - I2C Dataline pin
+    * @param scl - I2C Clockline pin
+    */
+    TSL45315(PinName sda, PinName scl);
+    
+    /** sets the address in the command register of the
     *   target register for future write operations
-    *
     * @param reg - specific register to write to (control or config)
     * @param arg - argument of function in the control or config register
     */
@@ -89,46 +114,38 @@
 
 
 
-    /**
-    *   reads out datalow and datahigh registers and
+    /** reads out datalow and datahigh registers and
     *   calculates the resulting illumination value
     *   in lux which is saved in the variable lux
-    *
     * @param reg - specific register to write to
     * @param arg - argument of function in the control or config register
     */
     void getLuxData( );
 
-    /** 
-    *  @returns  returns the actual illumination value in lux which was previously calculated in the getLuxData routine
+    /** @returns  returns the actual illumination value in lux which was previously calculated in the getLuxData routine
     */
     uint32_t getLux( ) {
         return lux;
     };
 
-    /** 
-    *   reads out the ID register and saves the id in the variable devID
+    /** reads out the ID register and saves the id in the variable devID
     */
     void getIDdata();
     
-    /** 
-    *   @returns the ID of the device
+    /** @returns the ID of the device
     */
     uint8_t getID( ) {
         return devID;
     };
     
-    /**
-    *   reads out datalow and datahigh registers and
+    /** reads out datalow and datahigh registers and
     *   calculates the resulting illumination value
     *   in lux which is saved in the variable lux
-    *
     * @param mult - Multiplier (1,2,4) defined by M1, M2, M4
     */
     void setMultiplier( uint8_t mult);
     
-    /**
-    *   @returns the multiplier according to the choosen integration time 
+    /** @returns the multiplier according to the choosen integration time 
     */
     int getMultiplier( ) {
         return multiplier;