MAX44008 RGB Color, Infrared, and Temperature Sensor

Dependents:   test_MAX44008 testSensor

Files at this revision

API Documentation at this revision

Comitter:
Rhyme
Date:
Wed Dec 07 05:13:02 2016 +0000
Parent:
1:45b23a5fff8e
Commit message:
Initial commit, skeleton is working

Changed in this revision

MAX44008.cpp Show annotated file Show diff for this revision Revisions of this file
MAX44008.h Show annotated file Show diff for this revision Revisions of this file
diff -r 45b23a5fff8e -r e4631b2273f8 MAX44008.cpp
--- a/MAX44008.cpp	Tue Dec 22 06:02:58 2015 +0000
+++ b/MAX44008.cpp	Wed Dec 07 05:13:02 2016 +0000
@@ -64,9 +64,13 @@
 
 void MAX44008::readRegs(int addr, uint8_t *data, int len)
 {
+    int i ;
     char t[1] = {addr} ;
-    m_i2c.write(m_addr, t, 1, true) ;
-    m_i2c.read(m_addr, (char*)data, len) ;
+    for (i = 0 ; i < len ; i++) {
+        t[0] = addr + i ;
+        m_i2c.write(m_addr, t, 1, true) ;
+        m_i2c.read(m_addr, (char *)(&data[i]), 1) ;
+    }
 }
 
 void MAX44008::writeRegs(uint8_t *data, int len)
@@ -501,6 +505,15 @@
     res[1] |= ((newChannel & 0x03) << 2) ;
     writeRegs(res, 2) ;
 }
+
+void MAX44008::setRawMode(uint8_t newMode)
+{
+    uint8_t res[2] ;
+    res[0] = REG_MAIN_CONFIG ;
+    res[1] = newMode ;
+    writeRegs(res, 2) ;
+}
+
 void MAX44008::setMode(uint8_t newMode)
 {
     uint8_t res[2] ;
diff -r 45b23a5fff8e -r e4631b2273f8 MAX44008.h
--- a/MAX44008.h	Tue Dec 22 06:02:58 2015 +0000
+++ b/MAX44008.h	Wed Dec 07 05:13:02 2016 +0000
@@ -67,6 +67,7 @@
  void    disableAMBINT(void) ;
  void    selectAMBINT(uint8_t newChannel) ;
  void    setMode(uint8_t newMode) ;
+ void    setRawMode(uint8_t newMode) ;
  
 private:
   I2C m_i2c;