Vishay VEML6040 Color RGB sensor I2C driver library

Dependents:   test_VEML6040 testSensor

Revision:
5:a4dcc19d057e
Parent:
4:f5b142e3fe79
--- a/VEML6040.cpp	Mon Jun 05 02:02:20 2017 +0000
+++ b/VEML6040.cpp	Mon Nov 06 01:18:56 2017 +0000
@@ -46,6 +46,21 @@
 #define CCT_CONST  (4278.6)
 #define OFFSET_OPEN_AIR  (0.5)
 
+/* integration time depending on the IT
+ * field in the REG_COLOR_CONF[6:4]
+ * According to Vishay error could be up to 20%
+ */
+int IT_TIME[] = {
+      50,   /* 000:   40ms */
+     100,   /* 001:   80ms */
+     200,   /* 010:  160ms */
+     400,   /* 011:  320ms */
+     800,   /* 100:  640ms */
+    1600,   /* 101: 1280ms */
+    1600,   /* 110: 1280ms <- place holder */
+    1600    /* 111: 1280ms <- place holder */
+} ;
+
 VEML6040::VEML6040(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr<<1) {
     // activate the peripheral
 }
@@ -95,6 +110,30 @@
      writeRegs(data, 3) ;
 }
 
+int VEML6040::getIT(void)
+{
+    uint8_t colorconf ;
+    int IntegrationTime ;
+    getCOLORConf(&colorconf) ;
+    IntegrationTime = (colorconf >> 4) & 0x07 ;
+    return( IntegrationTime ) ;
+}
+
+/*
+#define IT_40MS   0x00
+#define IT_80MS   0x10
+#define IT_160MS  0x20
+#define IT_320MS  0x30
+#define IT_640MS  0x40
+#define IT_1280MS 0x50
+*/
+void VEML6040::setIT(uint8_t it_value)
+{
+    uint8_t colorconf ;
+    getCOLORConf(&colorconf) ;
+    colorconf = it_value | (colorconf & 0x0F) ;
+    setCOLORConf(colorconf) ;
+}
 
 int VEML6040::getRData(uint16_t *rdata)
 {