Michael Ernst Peter / Mbed OS Test_GPS

Dependencies:   Eigen

Revision:
57:6c87f4989616
Parent:
55:fbd59767e175
Child:
58:f1b47b30f7c4
--- a/main.cpp	Fri Jun 03 16:52:38 2022 +0200
+++ b/main.cpp	Fri Jun 03 18:20:08 2022 +0200
@@ -21,6 +21,10 @@
     // while loop gets executed every main_task_period_ms milliseconds
     const int main_task_period_ms = 40;  // define main task period time in ms e.g. 50 ms -> main task runns 20 times per second
     Timer main_task_timer;               // create Timer object which we use to run the main task every main task period time in ms
+    main_task_timer.start();
+    
+    Timer run_timer;
+    run_timer.start();
 
     // led on nucleo board
     DigitalOut user_led(LED1);      // create DigitalOut object to command user led
@@ -39,10 +43,7 @@
     
     // attach button fall and rise functions to user button object
     user_button.fall(&user_button_pressed_fcn);
-    user_button.rise(&user_button_released_fcn);
-
-    // start timer
-    main_task_timer.start();
+    user_button.rise(&user_button_released_fcn);   
 
     while (true) { // this loop will run forever
 
@@ -86,15 +87,16 @@
             neom9n.getLat() * 10.0f,
             neom9n.getHeight() * 10.0f,
             neom9n.getHeightMSL() * 10.0f);
-        printf("%0.3f, %d",                    // 15:16 : no scaling
+        printf("%0.3f, %d, ",                    // 15:16 : no scaling
             neom9n.getSatTime(),
             neom9n.getNumSat());
 
-        printf("\r\n");
-        //printf("Update time: %d\r\n", main_task_elapsed_time_mus);
+        int run_elapsed_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(run_timer.elapsed_time()).count();
+        printf("%d\r\n", run_elapsed_time_ms);
 
         // read timer and make the main thread sleep for the remaining time span (non blocking)
         int main_task_elapsed_time_ms = std::chrono::duration_cast<std::chrono::milliseconds>(main_task_timer.elapsed_time()).count();
+                
         thread_sleep_for(main_task_period_ms - main_task_elapsed_time_ms);
     }
 }