HRV -> Mood

Dependencies:   MAX30101 Hexi_KW40Z Hexi_OLED_SSD1351

Files at this revision

API Documentation at this revision

Comitter:
jeannie9809
Date:
Sat Mar 16 04:28:02 2019 +0000
Parent:
7:7ae14b3b00d1
Child:
9:83dcb7382516
Commit message:
HRV DONE!

Changed in this revision

8cee5929f4d8/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/8cee5929f4d8/main.cpp	Sat Mar 16 04:19:57 2019 +0000
+++ b/8cee5929f4d8/main.cpp	Sat Mar 16 04:28:02 2019 +0000
@@ -327,6 +327,16 @@
     }
     
     // SDNN -- std of normal to normal R-R intervals
+    mean_inter_time = 0;
+    for(i = 0; i < num_max-1; i++) {
+        mean_inter_time = mean_inter_time + r.at(i);
+    }
+    mean_inter_time = double(mean_inter_time/(num_max-1));
+    double SDNN_doub = 0.0;
+    for(i = 0; i < num_max-1; i++) {
+        SDNN_doub = SDNN_doub + (r.at(i)-mean_inter_time)*(r.at(i)-mean_inter_time);
+    }
+    SDNN = (int)(sqrt(SDNN_doub/(num_max-1))*1000);
 }
 
 // main() runs in its own thread in the OS