-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfolderStuff.pde
76 lines (66 loc) · 1.97 KB
/
folderStuff.pde
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
void folderSelected(File selection) {
if (selection == null) {
println("Window was closed or the user hit cancel.");
} else {
println("User selected " + selection.getAbsolutePath());
playbackFile = selection;
dataReader = createReader(playbackFile.getAbsolutePath()); //
readingFromFile = true;
onAir = true;
dataSourceFound = true;
zeroDataLines();
}
}
void createFile(){
logFileName = "PulseSensor Data/PS_"+month()+"-"+day()+"_"+year()+"_"+hour()+"-"+minute()+".csv";
dataWriter = createWriter(logFileName);
dataWriter.println("%Pulse Sensor Hummingbird Data Log " + month()+"/"+day()+" "+hour()+":"+minute());
dataWriter.println("%https://github.com/biomurph/PulseSensor_Visualizer_Record-Playback");
dataWriter.println("%Data formatted for playback in Processing Visualizer");
dataWriter.println("%Comma separated values");
dataWriter.println("%Signal, BPM, IBI");
}
void readDataLineFromFile(){
try {
readDataLine = dataReader.readLine();
}
catch (IOException e) {
e.printStackTrace();
readDataLine = null;
}
if (readDataLine == null) {
// Stop reading because of an error or file is empty
// Start again from the beginning?
// Press 'r' for replay?
// readingFromFile = false;
println("nothing left in file");
onAir = false;
readingFromFile = false;
dataSourceFound = false;
refreshPorts = true;
zeroDataLines();
lineCounter = 0;
//
} else {
lineCounter++;
readDataLine = trim(readDataLine); // trim the \n off the end
if(readDataLine.charAt(0) == '%'){
println(readDataLine);
return;
}
String[] s = splitTokens(readDataLine, ",");
Sensor = int(s[0]);
int _bpm = int(s[1]);
if(BPM != _bpm){
BPM = _bpm;
}
if(IBI != int(s[2])){
IBI = int(s[2]);
}
int p = int(s[3]);
if(p == 1){
beat = true; // set beat flag to advance heart rate graph
heart = 20; // expand heart
}
}
}