Vishay VEML6040 Color RGB sensor I2C driver library

Dependents:   test_VEML6040 testSensor

Committer:
Rhyme
Date:
Mon Jun 05 02:02:20 2017 +0000
Revision:
4:f5b142e3fe79
Parent:
3:c6614597c135
Child:
5:a4dcc19d057e
readRegs/writeRegs now return I2C result

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shockey 0:e6e6107c659e 1 /*
shockey 0:e6e6107c659e 2 * File description
shockey 0:e6e6107c659e 3 *
shockey 0:e6e6107c659e 4 */
shockey 0:e6e6107c659e 5
shockey 0:e6e6107c659e 6 #ifndef _VEML6040_H_
shockey 0:e6e6107c659e 7 #define _VEML6040_H_
shockey 0:e6e6107c659e 8
shockey 0:e6e6107c659e 9 #include "mbed.h"
shockey 0:e6e6107c659e 10
shockey 0:e6e6107c659e 11 /**
shockey 0:e6e6107c659e 12 * RGBW Color Sensor with I2C Interface
shockey 0:e6e6107c659e 13 * I2C 7bit address: 0x10
shockey 0:e6e6107c659e 14 *
shockey 0:e6e6107c659e 15 */
shockey 0:e6e6107c659e 16
shockey 0:e6e6107c659e 17 class VEML6040
shockey 0:e6e6107c659e 18 {
shockey 0:e6e6107c659e 19 public:
shockey 0:e6e6107c659e 20 /**
shockey 0:e6e6107c659e 21 * constructor
shockey 0:e6e6107c659e 22 *
shockey 0:e6e6107c659e 23 * @param sda SDA pin
shockey 0:e6e6107c659e 24 * @param scl SCL pin
shockey 0:e6e6107c659e 25 * @param addr address of the I2C peripheral
shockey 0:e6e6107c659e 26 */
shockey 0:e6e6107c659e 27 VEML6040(PinName sda, PinName scl, int addr) ;
shockey 0:e6e6107c659e 28
shockey 0:e6e6107c659e 29 ~VEML6040() ;
shockey 0:e6e6107c659e 30
shockey 0:e6e6107c659e 31 /*
shockey 0:e6e6107c659e 32 * some member functions here (yet to be written)
shockey 0:e6e6107c659e 33 */
Rhyme 3:c6614597c135 34 /**
Rhyme 3:c6614597c135 35 * get Red
Rhyme 3:c6614597c135 36 * @param none
Rhyme 3:c6614597c135 37 * @returns float value of Red
Rhyme 3:c6614597c135 38 */
shockey 0:e6e6107c659e 39 float getR(void) ; // return float value of Red
Rhyme 3:c6614597c135 40
Rhyme 3:c6614597c135 41 /**
Rhyme 3:c6614597c135 42 * get Green
Rhyme 3:c6614597c135 43 * @param none
Rhyme 3:c6614597c135 44 * @returns float value of Green
Rhyme 3:c6614597c135 45 */
shockey 0:e6e6107c659e 46 float getG(void) ; // return float value of Green
Rhyme 3:c6614597c135 47
Rhyme 3:c6614597c135 48 /**
Rhyme 3:c6614597c135 49 * get Blue
Rhyme 3:c6614597c135 50 * @param none
Rhyme 3:c6614597c135 51 * @returns float value of Blue
Rhyme 3:c6614597c135 52 */
shockey 0:e6e6107c659e 53 float getB(void) ; // return float value of Blue
Rhyme 3:c6614597c135 54
Rhyme 3:c6614597c135 55 /**
Rhyme 3:c6614597c135 56 * get White
Rhyme 3:c6614597c135 57 * @param none
Rhyme 3:c6614597c135 58 * @returns float value of White
Rhyme 3:c6614597c135 59 */
shockey 0:e6e6107c659e 60 float getW(void) ; // return float value of White
Rhyme 3:c6614597c135 61
Rhyme 3:c6614597c135 62 /**
Rhyme 3:c6614597c135 63 * get CCT(McCAMY FORMULA) value X
Rhyme 3:c6614597c135 64 * @param none
Rhyme 3:c6614597c135 65 * @returns float CCT value X
Rhyme 3:c6614597c135 66 */
shockey 1:5540b216acfc 67 float getX(void) ; // return float value of X
Rhyme 3:c6614597c135 68
Rhyme 3:c6614597c135 69 /**
Rhyme 3:c6614597c135 70 * get CCT(McCAMY FOMULA) value Y
Rhyme 3:c6614597c135 71 * @param none
Rhyme 3:c6614597c135 72 * @returns float CCT value Y
Rhyme 3:c6614597c135 73 */
shockey 1:5540b216acfc 74 float getY(void) ; // return float value of Y
Rhyme 3:c6614597c135 75
Rhyme 3:c6614597c135 76 /**
Rhyme 3:c6614597c135 77 * get CCT(McCAMY FOMULA) value Z
Rhyme 3:c6614597c135 78 * @param none
Rhyme 3:c6614597c135 79 * @returns float CCT value Z
Rhyme 3:c6614597c135 80 */
shockey 1:5540b216acfc 81 float getZ(void) ; // return float value of Z
Rhyme 3:c6614597c135 82
Rhyme 3:c6614597c135 83 /**
Rhyme 3:c6614597c135 84 * get CIE1931 X
Rhyme 3:c6614597c135 85 * @param none
Rhyme 3:c6614597c135 86 * @returns float CIE1931 X
Rhyme 3:c6614597c135 87 */
shockey 1:5540b216acfc 88 float getCIEX(void) ; // return float value of CIE1931_x
Rhyme 3:c6614597c135 89
Rhyme 3:c6614597c135 90 /**
Rhyme 3:c6614597c135 91 * get CIE1931 Y
Rhyme 3:c6614597c135 92 * @param none
Rhyme 3:c6614597c135 93 * @returns float CIE1931 Y
Rhyme 3:c6614597c135 94 */
shockey 1:5540b216acfc 95 float getCIEY(void) ; // return float value of CIE1931_y
shockey 1:5540b216acfc 96
shockey 0:e6e6107c659e 97 void getCOLORConf(uint8_t *colorconf) ;
shockey 0:e6e6107c659e 98 void setCOLORConf(uint8_t colorconf) ;
shockey 1:5540b216acfc 99 // void getX(uint8_t *X) ;
shockey 1:5540b216acfc 100 // void getY(uint8_t *Y) ;
shockey 1:5540b216acfc 101 // void getZ(uint8_t *Z) ;
Rhyme 3:c6614597c135 102 /**
Rhyme 3:c6614597c135 103 * get raw Red data
Rhyme 3:c6614597c135 104 * @param uint16_t *rdata
Rhyme 4:f5b142e3fe79 105 * @returns i2c status 0: success non-0: failure
Rhyme 3:c6614597c135 106 */
Rhyme 4:f5b142e3fe79 107 int getRData(uint16_t *rdata) ;
Rhyme 3:c6614597c135 108
Rhyme 3:c6614597c135 109 /**
Rhyme 3:c6614597c135 110 * get raw Green data
Rhyme 3:c6614597c135 111 * @param uint16_t *gdata
Rhyme 4:f5b142e3fe79 112 * @returns i2c status 0: success non-0: failure
Rhyme 3:c6614597c135 113 */
Rhyme 4:f5b142e3fe79 114 int getGData(uint16_t *gdata) ;
Rhyme 3:c6614597c135 115
Rhyme 3:c6614597c135 116 /**
Rhyme 3:c6614597c135 117 * get raw Blue data
Rhyme 3:c6614597c135 118 * @param uint16_t *bdata
Rhyme 4:f5b142e3fe79 119 * @returns i2c status 0: success non-0: failure
Rhyme 3:c6614597c135 120 */
Rhyme 4:f5b142e3fe79 121 int getBData(uint16_t *bdata) ;
Rhyme 3:c6614597c135 122
Rhyme 3:c6614597c135 123 /**
Rhyme 3:c6614597c135 124 * get raw White data
Rhyme 3:c6614597c135 125 * @param uint16_t *wdata
Rhyme 4:f5b142e3fe79 126 * @returns i2c status 0: success non-0: failure
Rhyme 3:c6614597c135 127 */
Rhyme 4:f5b142e3fe79 128 int getWData(uint16_t *wdata) ;
Rhyme 3:c6614597c135 129
shockey 1:5540b216acfc 130 // void getCCTiData(uint16_t *cctidata) ;
Rhyme 3:c6614597c135 131 /**
Rhyme 3:c6614597c135 132 * get CCTi data for CCT (EMPIRICAL APPROACH)
Rhyme 3:c6614597c135 133 * @param none
Rhyme 3:c6614597c135 134 * @returns float CCTi data
Rhyme 3:c6614597c135 135 */
shockey 1:5540b216acfc 136 float getCCTiData(void) ;
shockey 1:5540b216acfc 137 // void getCCTData(uint16_t *cctdata) ;
Rhyme 3:c6614597c135 138
Rhyme 3:c6614597c135 139 /**
Rhyme 3:c6614597c135 140 * get CCT data (EMPIRICAL APPROACH)
Rhyme 3:c6614597c135 141 * @param none
Rhyme 3:c6614597c135 142 * @returns float CCD data
Rhyme 3:c6614597c135 143 */
shockey 1:5540b216acfc 144 float getCCTData(void) ;
shockey 0:e6e6107c659e 145 // void cmdRead(uint8_t cmd, uint8_t *data, uint8_t numdata = 2) ;
shockey 0:e6e6107c659e 146 // void cmdWrite(uint8_t cmd, uint8_t *data, uint8_t numdata = 2) ;
shockey 0:e6e6107c659e 147
shockey 0:e6e6107c659e 148 private:
shockey 0:e6e6107c659e 149 I2C m_i2c;
shockey 0:e6e6107c659e 150 int m_addr;
Rhyme 4:f5b142e3fe79 151 int readRegs(int addr, uint8_t * data, int len);
Rhyme 4:f5b142e3fe79 152 int writeRegs(uint8_t * data, int len);
shockey 0:e6e6107c659e 153 } ;
shockey 0:e6e6107c659e 154 #endif /* _VEML6040_H_ */