-
Notifications
You must be signed in to change notification settings - Fork 2
/
AllSerialHandling.ino
43 lines (37 loc) · 1.22 KB
/
AllSerialHandling.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
//////////
///////// All Serial Handling Code,
///////// It's Changeable with the 'outputType' variable
///////// It's declared at start of code.
/////////
void serialOutput(){ // Decide How To Output Serial.
switch(outputType){
case PROCESSING_VISUALIZER:
sendDataToSerial('S', Signal); // goes to sendDataToSerial function
break;
case SERIAL_PLOTTER: // open the Arduino Serial Plotter to visualize these data
Serial.print(BPM);
Serial.print(",");
Serial.print(IBI);
Serial.print(",");
Serial.println(Signal);
break;
default:
break;
}
}
// Decides How To OutPut BPM and IBI Data
void serialOutputWhenBeatHappens(){
switch(outputType){
case PROCESSING_VISUALIZER: // find it here https://github.com/WorldFamousElectronics/PulseSensor_Amped_Processing_Visualizer
sendDataToSerial('B',BPM); // send heart rate with a 'B' prefix
sendDataToSerial('Q',IBI); // send time between beats with a 'Q' prefix
break;
default:
break;
}
}
// Sends Data to Pulse Sensor Processing App, Native Mac App, or Third-party Serial Readers.
void sendDataToSerial(char symbol, int data ){
Serial.print(symbol);
Serial.println(data);
}