Color sensor reset at the end of calibration added. sensor id auto assignment was changed to be a fixed value assignment to avoid sensor id shift when some sensor is absent.

Dependencies:   UniGraphic mbed vt100

Committer:
Rhyme
Date:
Fri Feb 23 07:51:55 2018 +0000
Revision:
1:8818b793d147
Parent:
0:ce97f6d34336
Wrong behavior when one of color sensor is missing has been fixed.

Who changed what in which revision?

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