MAX44009 Ambient Light Sensor with ADC library

Fork of MAX44009 by Davy Van Belle

Files at this revision

API Documentation at this revision

Comitter:
lucian@192-168-0-103.rdsnet.ro
Date:
Mon Feb 19 18:35:44 2018 +0200
Parent:
2:7aa4718b2e2b
Child:
4:1799f106738d
Commit message:
Fix raw reading method

Changed in this revision

MAX44009.cpp Show annotated file Show diff for this revision Revisions of this file
MAX44009.h Show annotated file Show diff for this revision Revisions of this file
--- a/MAX44009.cpp	Tue Feb 13 00:54:47 2018 +0200
+++ b/MAX44009.cpp	Mon Feb 19 18:35:44 2018 +0200
@@ -71,16 +71,15 @@
 void MAX44009::setIntEnable(bool Enable) {
     char cmd[2];
     cmd[0] = INT_ENABLE;
-    cmd[1] = 0x00 | Enable;
+    cmd[1] = (char) 0x00 | Enable;
     _i2c->write(_addr, cmd, 2);
 }
 
 /**
  * Get raw reading over I2C
- * @return the reading buffer
+ * @param buff raw reading buffer
  */
-char *MAX44009::getRawReading() {
-    char buff[2];
+void MAX44009::getRawReading(char buff[2]) {
     char cmd[2];
 
     cmd[0] = LUX_HIGH_B;
@@ -90,15 +89,15 @@
     _i2c->read(_addr + 1, &buff[0], 1, true);
     _i2c->write(_addr, &cmd[1], 1, true);
     _i2c->read(_addr + 1, &buff[1], 1);
-
-    return buff;
 }
 
 /**
  * Get LUX reading from ADC
  */
 double MAX44009::getLUXReading() {
-    char *buff = getRawReading();
+    char buff[2];
+
+    this->getRawReading(buff);
     return this->getLuxFromBuffReading(buff);
 }
 
--- a/MAX44009.h	Tue Feb 13 00:54:47 2018 +0200
+++ b/MAX44009.h	Mon Feb 19 18:35:44 2018 +0200
@@ -55,7 +55,7 @@
 
     void setIntEnable(bool Enable);
 
-    char *getRawReading();
+    void getRawReading(char buff[2]);
 
     double getLUXReading();