Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Fork of modular_signal_processing by
Diff: main.cpp
- Revision:
- 7:cc766c97686a
- Parent:
- 6:9c5c36d2c0e1
--- a/main.cpp Fri Feb 16 15:57:50 2018 +0000
+++ b/main.cpp Sat Mar 03 13:35:40 2018 +0000
@@ -55,7 +55,7 @@
//}
}
-float initialMin() //Get min value of first two pulses data
+float Min() //Get min value of two pulses data
{
int min = avg_buffer[0];
for (int i = 0; i < AVG_LEN; i++) {
@@ -66,7 +66,7 @@
return min;
}
-float initialMax() //Get max value of first two pulse data
+float Max() //Get max value of two pulse data
{
int max = avg_buffer[0];
for (int i = 0; i < AVG_LEN; i++) {
@@ -98,8 +98,8 @@
intialised= true;
//Get inital min and max
- max = initialMax();
- min = initialMin();
+ max = Max();
+ min = Min();
}
@@ -111,8 +111,8 @@
avg_write = avg_write%AVG_LEN; //Ensure avg_write wraps around
- max = initialMax();
- min = initialMin();
+ max = Max();
+ min = Min();
float trendedData = data - (avg_sum/AVG_LEN);
float offsetData = trendedData+OFFSET;
return offsetData; //Remove trendline
@@ -149,19 +149,19 @@
void detectPulse(float normalisedData) //Turn on LED during high part of pulse
{
// Implementation of hysteresis
- if(triggered) {
- if (below_trig_low(normalisedData)) {
+ if(triggered) { //Previously bove high trigger
+ if (below_trig_low(normalisedData)) { //If it drops below ,ow trigger point
triggered = false;
pulse = 0;
- } else {
+ } else { //Still above low trigger
pulse = 1;
}
}
- else {
- if (above_trig_high(normalisedData)) {
+ else { //Previously below low trigger
+ if (above_trig_high(normalisedData)) {//If it goes above high trigger point
triggered = true;
pulse = 1;
- } else {
+ } else { //Still below high trigger
pulse = 0;
}
}

