si1145 library

Dependents:   FRDM_ApplicationShield_GroveSensors

SI1145.h

Committer:
caseyquinn
Date:
2015-06-12
Revision:
3:efef49daeb13
Parent:
2:4d89a48e6174
Child:
6:642ece0fad39

File content as of revision 3:efef49daeb13:

/**
 *  SI1145 Digital UV Index / IR / Visible Light Sensor library
 *  @author  N Good
 *  @date    5-May-2015
 *  Library for "SI1145 Digital UV Index / IR / Visible Light Sensor" from adafruit
 *  https://www.adafruit.com/products/1777
 */

#include "mbed.h"
#define SI1145_ADDRESS (0x60 << 1)
extern Serial pc;

/** SI1145 class
 *  SI1145: A library to correct environmental data using adafruit SI1145 device
 */
 
class SI1145
{
public:

    /** Create a SI1145 instance
     *  which is connected to specified I2C pins with specified address
     * @param sda I2C-bus SDA pin
     * @param scl I2C-bus SCL pin
     * @param slave_adr (option) I2C-bus address (default: 0x60)
     */
    SI1145(PinName sda, PinName sck, char slave_adr = SI1145_ADDRESS);
    /** Create a SI1145 instance
     *  which is connected to specified I2C pins with specified address
     * @param i2c_obj I2C object (instance)
     * @param slave_adr (option) I2C-bus address (default: 0x60)
     */
    SI1145(I2C &i2c_obj, char slave_adr = SI1145_ADDRESS);
    /** Destructor of SI1145
     */
    //virtual ~SI1145();
    /** Initialize SI1145 sensor
     *  Configure sensor setting and read parameters for calibration
     */
    void initalize(void);
   /** Begin Initialization SI1145 sensor
     *  Configure sensor setting and read parameters for calibration
     */
    float getUV(void);
    /** Read the current VIS value from SI1145 sensor
     */
    uint16_t getVIS(void);
    float getUVlsb(void);
    float getUVmsb(void);
    /** Read the current IR value from SI1145 sensor
     */
    uint16_t getIR(void);
    /** Read the current PROX value from SI1145 sensor
     */
    uint16_t getPROX(void);

private:

    I2C         *i2c_p;
    I2C         &i2c;
    char        address;
    int32_t     t_fine;
};