altb_pmic / Mbed 2 deprecated Grove-Barometric_Pressure_Sensor_Example

Dependencies:   HP206C mbed

Files at this revision

API Documentation at this revision

Comitter:
pmic
Date:
Wed Jun 26 09:51:41 2019 +0000
Parent:
7:3f4048c1cc81
Commit message:
commit before holiday

Changed in this revision

HP206C.lib 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/HP206C.lib	Tue Jun 25 15:23:40 2019 +0000
+++ b/HP206C.lib	Wed Jun 26 09:51:41 2019 +0000
@@ -1,1 +1,1 @@
-https://os.mbed.com/teams/altb_pmic/code/HP206C/#623379b867e0
+https://os.mbed.com/teams/altb_pmic/code/HP206C/#470f31efa042
--- a/main.cpp	Tue Jun 25 15:23:40 2019 +0000
+++ b/main.cpp	Wed Jun 26 09:51:41 2019 +0000
@@ -21,10 +21,11 @@
 InterruptIn Button(USER_BUTTON);  // User Button
 Ticker  LoopTimer;                // interrupt for control loop
 Timer t;                          // timer to analyse Button
+Timer twhile;                     // timer for time measurement (usage in while(1), without timer attached)
 
 int   k;
 bool  doRun = false;
-float Ts = 1.0f;                 // sample time of main loop, 20 Hz
+float Ts = 0.05f;                 // sample time of main loop, 20 Hz
 
 IIR_filter pt1(0.2f, Ts, 1.0f);
 float altitudef = 0.0f;
@@ -38,24 +39,27 @@
 // -----------------------------------------------------------------------------
 int main()
 {
-    pc.baud(115200);                   // for serial comm.
-    // LoopTimer.attach(&updateLoop, Ts); // attach loop to timer interrupt
+    pc.baud(2000000);                   // for serial comm.
     Button.fall(&pressed);             // attach key pressed function
     Button.rise(&released);            // attach key pressed function
     k = 0;
     pt1.reset(0.0f);
     barometer.reset();
+    wait(1.0f);
+    // LoopTimer.attach(&updateLoop, Ts); // attach loop to timer interrupt
     ///*
+    twhile.start(); // timer for time measurement (usage in while(1), without timer attached)
     while(1) {
         altitude = barometer();
         altitudef = pt1(altitude);
         if(doRun) {
             // use this section to do dynamical measurements
-            if(doRun && k++ < 4000) {
-                pc.printf("%10i %10.9e\r\n", k, altitude);
+            if(doRun && k++ < 2000) {
+            // if(doRun) {
+            //     k++;
+                pc.printf("%10i %10.6e %10.6e\r\n", k, twhile.read(), altitude);
             }
         }
-        wait_us(16000);
     }
     //*/
 }
@@ -79,8 +83,8 @@
     if(doRun) {
         ///*
         // use this section to do dynamical measurements
-        if(doRun && k++ < 4000) {
-            pc.printf("%10i %10.9e\r\n", k, altitude);
+        if(doRun && k++ < 2000) {
+            pc.printf("%10i %10.6e\r\n", k, altitude);
         }
         //*/
         /*
@@ -107,6 +111,7 @@
     if(doRun) {
         k = 0;
         pt1.reset(0.0f);
+        twhile.reset(); // timer for time measurement (usage in while(1), without timer attached)
     }
     doRun = !doRun;
     t.stop();