Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Processing 3.2.4 #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions Software/Heart_Rate_Display_Processing/HRT_MNT_P3
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Here are proposed changes for the code of the heart rate monitor, the old code could only function in the second version of Processing.
* The proposed changes now work for the newest version (3.3.2).
*
* All rights reserved to the original creators.
*/

import processing.serial.*;

Serial myPort;
int xPos = 1;
float height_old = 0;
float height_new = 0;
float inByte = 0;


void setup () {
//Window Size
size(1080, 500);

// List serial ports
println(Serial.list());
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil('\n');

//Background
background(255);

fill(color(0,0,0));
text("Heart Rate Monitor v1.0", 10, 10);
}


void draw () {

inByte = map(inByte, 0, 1023, 0, height);
height_new = height - inByte;
line(xPos - 1, height_old, xPos, height_new);
height_old = height_new;

if (xPos >= width) {
xPos = 0;
background(255);
}
else {
xPos++;
}
}


void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');

if (inString != null) {
// trim off any whitespace:
inString = trim(inString);

if (inString.equals("!")) {
stroke(0, 0, 255);
inByte = 512;
}
else {
stroke(255, 0, 0);
inByte = float(inString);
}
}
}