si1145 library

Dependents:   FRDM_ApplicationShield_GroveSensors

Files at this revision

API Documentation at this revision

Comitter:
caseyquinn
Date:
Fri Jun 12 22:08:12 2015 +0000
Parent:
2:4d89a48e6174
Child:
4:27844262d40f
Commit message:
Changed UV value from an int to a float and divided by 100 to give the actual UV index value.

Changed in this revision

SI1145.cpp Show annotated file Show diff for this revision Revisions of this file
SI1145.h Show annotated file Show diff for this revision Revisions of this file
--- a/SI1145.cpp	Sat May 30 00:02:00 2015 +0000
+++ b/SI1145.cpp	Fri Jun 12 22:08:12 2015 +0000
@@ -186,10 +186,10 @@
     return vali;
 }
 
-uint16_t SI1145::getVIS()
+float SI1145::getVIS()
 {
     // Variables
-    //float valf;                          // vis (IR+UV) value
+    float valf;                          // vis (IR+UV) value
     char reg[1];                         // register
     char data[2] = {0,0};                // data 2 x 8 bits
     uint16_t vali;                       // vis value
@@ -200,9 +200,9 @@
     i2c.read(address, data, 2);
     // Merge bytes
     vali = data[0] | (data[1] << 8);    // int
-    //valf = (float)vali;                 // convert to float
+    valf = (float)vali/100;                 // convert to float
     // Return value
-    return vali;
+    return valf;
 }
 
 uint16_t SI1145::getIR()
--- a/SI1145.h	Sat May 30 00:02:00 2015 +0000
+++ b/SI1145.h	Fri Jun 12 22:08:12 2015 +0000
@@ -41,7 +41,7 @@
    /** Begin Initialization SI1145 sensor
      *  Configure sensor setting and read parameters for calibration
      */
-    uint16_t getUV(void);
+    float getUV(void);
     /** Read the current VIS value from SI1145 sensor
      */
     uint16_t getVIS(void);