forked from biomurph/PulseSensor_Visualizer_Record_Playback
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathkeyboard_mouse.pde
More file actions
70 lines (66 loc) · 1.93 KB
/
Copy pathkeyboard_mouse.pde
File metadata and controls
70 lines (66 loc) · 1.93 KB
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
void mousePressed(){
scaleBar.press(mouseX, mouseY);
if(!dataSourceFound){
for(int i=0; i<=numPorts; i++){
if(button[i].pressRadio(mouseX,mouseY)){
if(i < numPorts){ // serialPorts.length){
try{
port = new Serial(this, Serial.list()[i], 115200); // make sure Arduino is talking serial at this baud rate
// port.clear();
delay(500);
// println(port.read());
port.clear(); // flush buffer
port.bufferUntil('\n'); // set buffer full flag on receipt of carriage return
dataSourceFound = true;
createFile();
writingToOpenFile = true;
// println("made port and file");
}
catch(Exception e){
println("Couldn't open port " + Serial.list()[i]);
drawDataWindows();
listAvailablePorts();
fill(255,0,0);
textFont(font,16);
textAlign(LEFT);
text("Couldn't open port " + Serial.list()[i],60,70);
textFont(font);
textAlign(CENTER);
}
}else{
println("selected to read a file");
selectInput("Select a folder to process:", "folderSelected");
frameRate(150);
}
}
}
}
}
void mouseReleased(){
scaleBar.release();
}
void keyPressed(){
switch(key){
case 's': // pressing 's' or 'S' will take a jpg of the processing window
case 'S':
saveFrame("heartLight-####.jpg"); // take a shot of that!
break;
case 'p': // user request to pause playback
if(onAir){
onAir = false;
}else{
onAir = true;
}
break;
case 'r': // user request to replay playback file
if(readingFromFile){
zeroDataLines();
dataReader = createReader(playbackFile.getAbsolutePath()); //
onAir = true;
dataSourceFound = true;
}
break;
default:
break;
}
}