si1145 library

Dependents:   FRDM_ApplicationShield_GroveSensors

Files at this revision

API Documentation at this revision

Comitter:
caseyquinn
Date:
Fri May 29 13:52:22 2015 +0000
Parent:
0:0490a77adbc5
Child:
2:4d89a48e6174
Commit message:
changed outputs from float values to uint16_t

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	Wed May 20 03:49:03 2015 +0000
+++ b/SI1145.cpp	Fri May 29 13:52:22 2015 +0000
@@ -167,10 +167,10 @@
     i2c.write(address, REG_COMMAND, 2);
 }
 
-float SI1145::getUV()
+uint16_t SI1145::getUV()
 {
     // Variables
-    float valf;                          // uv value
+    //float valf;                          // uv value
     char reg[1];                         // register
     char data[2] = {0,0};                // data 2 x 8 bits
     uint16_t vali;                       // uv value
@@ -181,15 +181,15 @@
     i2c.read(address, data, 2);
     // Merge bytes
     vali = data[0] | (data[1] << 8);    // int
-    valf = (float)vali;                 // convert to float
+    //valf = (float)vali;                 // convert to float
     // Return value
-    return valf;
+    return vali;
 }
 
-float SI1145::getVIS()
+uint16_t 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,15 +200,15 @@
     i2c.read(address, data, 2);
     // Merge bytes
     vali = data[0] | (data[1] << 8);    // int
-    valf = (float)vali;                 // convert to float
+    //valf = (float)vali;                 // convert to float
     // Return value
-    return valf;
+    return vali;
 }
 
-float SI1145::getIR()
+uint16_t SI1145::getIR()
 {
     // Variables
-    float valf;                          // ir value
+    //float valf;                          // ir value
     char reg[1];                         // register
     char data[2] = {0,0};                // data 2 x 8 bits
     uint16_t vali;                       // ir value
@@ -219,15 +219,15 @@
     i2c.read(address, data, 2);
     // Merge bytes
     vali = data[0] | (data[1] << 8);    // int
-    valf = (float)vali;                 // convert to float
+    //valf = (float)vali;                 // convert to float
     // Return value
-    return valf;
+    return vali;
 }
 
-float SI1145::getPROX()
+uint16_t SI1145::getPROX()
 {
     // Variables
-    float valf;                          // prox value
+    //float valf;                          // prox value
     char reg[1];                         // register
     char data[2] = {0,0};                // data 2 x 8 bits
     uint16_t vali;                       // prox value
@@ -238,8 +238,8 @@
     i2c.read(address, data, 2);
     // Merge bytes
     vali = data[0] | (data[1] << 8);    // int
-    valf = (float)vali;                 // convert to float
+    //valf = (float)vali;                 // convert to float
     // Return value
-    return valf;
+    return vali;
 }
 
--- a/SI1145.h	Wed May 20 03:49:03 2015 +0000
+++ b/SI1145.h	Fri May 29 13:52:22 2015 +0000
@@ -41,18 +41,18 @@
    /** Begin Initialization SI1145 sensor
      *  Configure sensor setting and read parameters for calibration
      */
-    float getUV(void);
+    uint16_t getUV(void);
     /** Read the current VIS value from SI1145 sensor
      */
-    float getVIS(void);
+    uint16_t getVIS(void);
     float getUVlsb(void);
     float getUVmsb(void);
     /** Read the current IR value from SI1145 sensor
      */
-    float getIR(void);
+    uint16_t getIR(void);
     /** Read the current PROX value from SI1145 sensor
      */
-    float getPROX(void);
+    uint16_t getPROX(void);
 
 private: