3 Temperature sensors + GUI

Dependencies:   F746_GUI mbed BME280

Files at this revision

API Documentation at this revision

Comitter:
pay0ee
Date:
Fri Jan 17 14:45:03 2020 +0000
Parent:
0:80304e80a329
Commit message:
Nothing

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jan 15 14:35:49 2020 +0000
+++ b/main.cpp	Fri Jan 17 14:45:03 2020 +0000
@@ -13,6 +13,8 @@
 #endif
 TS_StateTypeDef TS_State;
 
+PwmOut        ena(D0);
+
 DigitalOut    MUX0(D7); // low-active
 DigitalOut    MUX1(D4); 
 DigitalOut    MUX2(D1); 
@@ -29,6 +31,11 @@
  
 int main()
 {
+    float val;
+    float percentage;
+    
+    ena.period(1.0/5000.0);// 4Khz period
+        
     Label label1(350, 40, "Temp. microcontroller (C): ", Label::RIGHT, Font16);
     Label label2(285, 70, "Temp. batteries (C): ", Label::RIGHT, Font16);
     Label label3(240, 100, "Temp. motor (C): ", Label::RIGHT, Font16);                 
@@ -42,7 +49,7 @@
     
     ButtonGroup bG(420, 196, 50, 36, 2, (string[]){"ON", "OFF"},0, 5, 1, 0);
     
-    float val;
+        
     
     while (1) {    
         
@@ -67,12 +74,10 @@
 
         
         x1 = sensor.getTemperature();
-        if(x1< val and x1>10){
+        if(x1< 100 and x1>10){
         Temp1.Draw(x1);
         }
-
-        HAL_Delay(10);
-                
+               
         MUX0 = 1;
         MUX1 = 0;
         MUX2 = 0;
@@ -81,12 +86,10 @@
         
         
         y1 = sensor1.getTemperature();
-        if(y1<val and y1>10){
+        if(y1<100 and y1>10){
         Temp2.Draw(y1);
         }
         
-        HAL_Delay(10);
-        
         MUX0 = 0;
         MUX1 = 1;
         MUX2 = 0;
@@ -94,11 +97,18 @@
         BME280 sensor2(I2C_SDA, I2C_SCL); 
         
         z1 = sensor2.getTemperature();
-        if(z1<val and z1>10){
+        
+        if(z1<100 and z1>10){
         Temp3.Draw(z1);
         }
-        
-        HAL_Delay(10); 
+                
+        if ( x1 > val){
+             percentage= x1*0.01f;        
+             ena.write(percentage);
+        }
+        else if (x1< val){
+            ena.write(0.00f);
+        }       
         
     }
-}
+}
\ No newline at end of file
--- a/mbed.bld	Wed Jan 15 14:35:49 2020 +0000
+++ b/mbed.bld	Fri Jan 17 14:45:03 2020 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/users/mbed_official/code/mbed/builds/aa5281ff4a02
\ No newline at end of file
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file