Neil Hardy / Mbed 2 deprecated Gas_Sensor_Array

Dependencies:   4DGL-uLCD-SE mbed

Fork of Gas_Sensor_best_copy by Neil Hardy

Files at this revision

API Documentation at this revision

Comitter:
nhardy6
Date:
Tue Jun 28 18:58:40 2016 +0000
Parent:
0:bd3708b85a8b
Commit message:
finished tare button

Changed in this revision

GasArray.cpp Show annotated file Show diff for this revision Revisions of this file
GasArray.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/GasArray.cpp	Thu Jun 16 21:59:31 2016 +0000
+++ b/GasArray.cpp	Tue Jun 28 18:58:40 2016 +0000
@@ -73,4 +73,12 @@
         uLCD -> locate(10,2*i+1+3*number);
         uLCD -> printf("%2.03f", percentages[i]);
     }
+}
+
+void GasArray::tare()
+{
+    for(int i=0; i<number; i++)
+    {
+        baseR[i]=(responseV[i]*dividerR[i])/(pwrV-responseV[i]);
+    }
 }
\ No newline at end of file
--- a/GasArray.h	Thu Jun 16 21:59:31 2016 +0000
+++ b/GasArray.h	Tue Jun 28 18:58:40 2016 +0000
@@ -9,6 +9,7 @@
         void read();                        // Returns voltage values
         void display_init(uLCD_4DGL *uLCD); // Prints sensor types and gases
         void display_cont(uLCD_4DGL *uLCD); // Prints response and gas percentages
+        void tare();                        // Adjusts base resistances for no gas
     private:
         int number;                         // Number of sensors
         float * baseR;                      // Base resistance of sensors
--- a/main.cpp	Thu Jun 16 21:59:31 2016 +0000
+++ b/main.cpp	Tue Jun 28 18:58:40 2016 +0000
@@ -27,7 +27,7 @@
 string gas[] = {"NO", "NO2"};
 
 //tare button
-DigitalIn tareButton(p5);
+InterruptIn tareButton(p5);
 
 //initialize screen
 uLCD_4DGL uLCD(p28, p27, p29);
@@ -35,6 +35,11 @@
 //establish sensor array
 GasArray Device(number, baseR, pwrV, dividerR, places, ISensitivityM, type, gas);
 
+void zero()
+{
+    Device.tare();
+}
+
 int main()
 {
     //setup button
@@ -58,9 +63,4 @@
         //display percentages
         Device.display_cont(&uLCD);
     }
-}
-
-void zero()
-{
-    //take voltage, use it to reform base resistances
 }
\ No newline at end of file