Last active
May 14, 2016 16:34
-
-
Save galyaobe/e31da8b6ff64618806515ce7505771d9 to your computer and use it in GitHub Desktop.
Wave Plotter Program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void serialEvent(Serial myPort) { | |
String ardIn = myPort.readStringUntil(linefeed); | |
if (ardIn != null) { | |
ardIn = trim(ardIn); | |
input = float(split(ardIn, ',')); | |
printArray(input[0]); | |
if (counter%4 == 0 && counter !=0) { | |
println("DIG EV"); | |
digitalEvent=true; | |
counter++; | |
} else { | |
println("ANA EV"); | |
analogEvent=true; | |
counter++; | |
} | |
delay(200); | |
} | |
} | |
void eventHappen() { | |
if (analogEvent) { | |
for (int j = 1; j < n; j++) | |
analog[j-1] = analog[j]; | |
for (int i = 0; i < 1; i++) | |
analog[n-1] = input[i]; | |
analogEvent=false; | |
} | |
if (digitalEvent) { | |
for (int j = 1; j < n; j++) | |
digital[j-1] = digital[j]; | |
for (int i = 0; i < 1; i++) | |
digital[n-1] = input[i]; | |
digitalEvent=false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The EEGen Project | |
//Created by Galya Oberman | |
//theeegenproject.wordpress.com | |
import processing.serial.*; | |
PGraphics canvas; | |
Serial myPort; | |
int linefeed = 10; | |
float[] input = new float[1]; //temporary store for values | |
float[] digital = new float[200]; | |
float[] analog = new float [200]; //2D array for point plotting | |
int n = 200; //number of points onscreen at a time | |
int counter = 1; | |
boolean analogEvent = false; | |
boolean digitalEvent = false; | |
void setup() { | |
size(1000, 250); | |
canvas = createGraphics(1000, 250); | |
canvas.beginDraw(); | |
canvas.endDraw(); | |
myPort = new Serial(this, Serial.list()[0], 9600); | |
myPort.bufferUntil(linefeed); | |
println(Serial.list()); | |
//can change to initialize to fix incoming wave/line onscreen | |
for (int j = 1; j < n; j++) | |
analog[j] = 450; | |
} | |
void draw() { | |
background(255); | |
smooth(); | |
stroke(102, 102, 255); | |
strokeWeight(1); // wave midlines | |
line(0, 125, 1000, 125); | |
stroke(255, 51, 51); | |
strokeWeight(4); // wave boundaries | |
line(0, 0, 1000, 0); | |
line(0, 249, 1000, 249); | |
stroke(0); | |
strokeWeight(2); | |
noFill(); | |
eventHappen(); | |
translate(0, -50); | |
beginShape(); | |
for (int j = 0; j < n; j++) {//plot all points for whole wave | |
vertex(j*5, (1333 - analog[j])/5); | |
} | |
endShape(); | |
} | |
void keyPressed() { | |
if (key == 's' || key == 'S') { | |
save("C:/Users/Galya's/Desktop/The EEGen Program/WaveMatrixOneInputNew/data/output/INITIALS-" + month() + "-" + day() + "-" + hour() + "-" + minute() + "-" + second() + ".tif"); //change to own file path | |
println((millis()/1000.0) + " seconds: SCREENSHOT"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The EEGen Program - https://gist.github.com/galyaobe/b93cac3edaf8a7afa42bd923b95fe8da
Circuit - http://www.pdf-archive.com/2016/05/14/circuitsheet/circuitsheet.pdf