Library to read from Keller Druck I2C Pressure sensors. Inputs are I2C object and address.

Dependents:   TestBenchSerenity-proto_F429ZI TestBenchFlow HSPFLOW1 TestBenchFlow1 ... more

Files at this revision

API Documentation at this revision

Comitter:
dmwahl
Date:
Mon May 06 21:19:33 2019 +0000
Parent:
8:0d45e94faf0f
Commit message:
6-MAY-2019 Added check on startup to detect whether or not a sensor is plugged in (initFailed bool)

Changed in this revision

keller_pressure.cpp Show annotated file Show diff for this revision Revisions of this file
keller_pressure.h Show annotated file Show diff for this revision Revisions of this file
diff -r 0d45e94faf0f -r 8df18eb9c0af keller_pressure.cpp
--- a/keller_pressure.cpp	Thu Apr 05 16:06:26 2018 +0000
+++ b/keller_pressure.cpp	Mon May 06 21:19:33 2019 +0000
@@ -5,7 +5,8 @@
 ///   Notes:            Added readP function
 ///
 ///   Revision History:
-///   Name:           Date:        Description:
+///   Name:         Date:           Description:
+///                 6-MAY-2019      Added check on startup to detect whether or not a sensor is plugged in (initFailed bool)
 ///-----------------------------------------------------------------
 
 
@@ -64,7 +65,17 @@
 KELLER_PRESSURE::KELLER_PRESSURE(I2C &i2c, int i2cAddress) : i2c(i2c), mi2cAddress(i2cAddress << 1)
 //===========================================================================
 {
-    readUserInfo();
+    // Read scaling factors from sensor. If the sensor doesn't respond, set all outputs to unobtanium values
+    if (readUserInfo() != 0) {
+        initFailed = true;
+        pressureBAR = -1;
+        pressurePSI = -1;
+        pressureKPA = -1;
+        temperatureC = -273.15;
+        temperatureF = -459.67;
+    } else {
+        initFailed = false;
+    }
 };
 
 //===========================================================================
diff -r 0d45e94faf0f -r 8df18eb9c0af keller_pressure.h
--- a/keller_pressure.h	Thu Apr 05 16:06:26 2018 +0000
+++ b/keller_pressure.h	Mon May 06 21:19:33 2019 +0000
@@ -5,7 +5,8 @@
 ///   Notes:            Added readP function
 ///
 ///   Revision History:
-///   Name:           Date:        Description:
+///   Name:         Date:           Description:
+///                 6-MAY-2019      Added check on startup to detect whether or not a sensor is plugged in (initFailed bool)
 ///-----------------------------------------------------------------
 
 
@@ -48,7 +49,7 @@
     KELLER_PRESSURE(I2C &i2c, int addr);
     ~KELLER_PRESSURE();
     char getStatus();
-
+    bool initFailed;
     uint16_t Cust_ID0, Cust_ID1, Scaling0, Scaling1, Scaling2, Scaling3, Scaling4;
 
 // Date of manufacture info