Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
LightStone to Processing
/**
* LightStone to Processing
*
* This sketch reads and graphs heart rate variability and
* skin conductance level data from the LightStone device
* via OSC messages from GlovePIE.
*/
import oscP5.*;
import netP5.*;
OscP5 oscP5;
float hrv = 0.0; // heart rate variability
float scl = 0.0; // skin conductance level
void setup() {
size(200, 200);
frameRate(30);
noStroke();
// create OSC listener
oscP5 = new OscP5(this, 7400);
// plug the input values to functions defined at end of sketch
oscP5.plug(this, "updateHrv", "/ls_hrv");
oscP5.plug(this, "updateScl", "/ls_scl");
}
void draw() {
background(#012232); // fill background with dark blue
// draw bar graph for HRV
fill(#ff0000); // set fill color to red
float mHrv = map(hrv, 0.0, 0.4, 0, 100); // map hrv to bar height
rect(50, 150, 25, -mHrv); // draw bar
// draw bar graph for SCL
fill(#00f149); // set fill color to green
float mScl = map(scl, 0.0, 20.0, 0, 100); // map scl to bar height
rect(125, 150, 25, -mScl); // draw bar
}
// update hrv value
void updateHrv(float val) {
hrv = val;
println("hrv: " + hrv);
}
// update scl value
void updateScl(float val) {
scl = val;
println("scl: " + scl);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment