Zeheng Chen
/
funky
heart rate test
Diff: main.cpp
- Revision:
- 4:3edb2dedc40b
- Parent:
- 3:fe75390a6f30
- Child:
- 5:6db460f13fcc
diff -r fe75390a6f30 -r 3edb2dedc40b main.cpp --- a/main.cpp Tue Apr 14 03:08:26 2015 +0000 +++ b/main.cpp Tue Apr 14 03:28:30 2015 +0000 @@ -32,7 +32,6 @@ data = sensor.read() * 3.3; running_count++; // printf("data = %f\n",data); - if (data - previous_data > 0){ //increasing printf("Increasing \n"); @@ -43,7 +42,13 @@ printf("Decrease\n"); if(firstRun){ float diff = data - global_max; - if(diff < difference || diff >-1*difference) { + float negative = -1*difference; + printf("HERE\n"); + printf("diff = %f\n",diff); + printf("data = %f\n",data); + printf("global_max = %f\n",global_max); + printf("HERE End\n"); + if(diff < difference && diff >negative) { printf("Within the range of first max, confident\n"); printf("found max, data= %f\n",data); foundMax = true; @@ -59,9 +64,10 @@ max1 = data; } } - else{ - if((max1-data < difference || max1-data > -1*difference) && foundMax){ + else if(data - previous_data < 0 && foundMax){ + if((max1-data < difference && max1-data > -1*difference)){ //found second max; + printf("max1 = %f\n",max1); printf("found second max,data = %f \n",data); count2 = running_count; float period = (count2 - count1)* count_period; @@ -75,6 +81,9 @@ } } + else{ + } + if(!foundMax && running_count>250){ reset(); global_max = normalization();