Vishay VEML6040 Color RGB sensor I2C driver library
Dependents: test_VEML6040 testSensor
VEML6040.h@0:e6e6107c659e, 2016-02-05 (annotated)
- Committer:
- shockey
- Date:
- Fri Feb 05 02:21:10 2016 +0000
- Revision:
- 0:e6e6107c659e
- Child:
- 1:5540b216acfc
First working version
Who changed what in which revision?
User | Revision | Line number | New 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 | */ |
shockey | 0:e6e6107c659e | 34 | float getR(void) ; // return float value of Red |
shockey | 0:e6e6107c659e | 35 | float getG(void) ; // return float value of Green |
shockey | 0:e6e6107c659e | 36 | float getB(void) ; // return float value of Blue |
shockey | 0:e6e6107c659e | 37 | float getW(void) ; // return float value of White |
shockey | 0:e6e6107c659e | 38 | void getCOLORConf(uint8_t *colorconf) ; |
shockey | 0:e6e6107c659e | 39 | void setCOLORConf(uint8_t colorconf) ; |
shockey | 0:e6e6107c659e | 40 | void getRData(uint16_t *rdata) ; |
shockey | 0:e6e6107c659e | 41 | void getGData(uint16_t *gdata) ; |
shockey | 0:e6e6107c659e | 42 | void getBData(uint16_t *bdata) ; |
shockey | 0:e6e6107c659e | 43 | void getWData(uint16_t *wdata) ; |
shockey | 0:e6e6107c659e | 44 | // void cmdRead(uint8_t cmd, uint8_t *data, uint8_t numdata = 2) ; |
shockey | 0:e6e6107c659e | 45 | // void cmdWrite(uint8_t cmd, uint8_t *data, uint8_t numdata = 2) ; |
shockey | 0:e6e6107c659e | 46 | |
shockey | 0:e6e6107c659e | 47 | private: |
shockey | 0:e6e6107c659e | 48 | I2C m_i2c; |
shockey | 0:e6e6107c659e | 49 | int m_addr; |
shockey | 0:e6e6107c659e | 50 | void readRegs(int addr, uint8_t * data, int len); |
shockey | 0:e6e6107c659e | 51 | void writeRegs(uint8_t * data, int len); |
shockey | 0:e6e6107c659e | 52 | } ; |
shockey | 0:e6e6107c659e | 53 | #endif /* _VEML6040_H_ */ |