import controlP5.*; import processing.serial.*; import grafica.*; PImage img; // Declare variable "a" of type PImage ControlP5 cp5; Textlabel temp; Textlabel pr; Textlabel spo2; Serial myPort; // Create object from Serial class int val=-1, started=0; // Data received from the serial port int val1; int val2; int val3; String textValue = ""; void setup() { size(1000,700); PFont font = createFont("arial",20); cp5 = new ControlP5(this); cp5.addTextfield("input") .setPosition(10,10) .setSize(200,40) .setFont(font) .setFocus(true) .setColor(color(255,255,255)) ; cp5.addBang("enter") .setPosition(240,10) .setSize(80,40) .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER) ; textFont(font); background(0); text("Temperature: ", 600, 460); text("Pulse Rate: ", 600, 510); text("SpO2: ", 600, 560); img = loadImage("ED Labs.png"); // Load the image into the program image(img, 800, 10); } void draw() { fill(255); if(started == 1) { float[] firstPlotPos = new float[] { 0, 0 }; float[] panelDim = new float[] { 200, 200 }; float[] margins = new float[] { 60, 70, 40, 30}; // Create four plots to represent the 4 panels GPlot plot1 = new GPlot(this); plot1.setPos(10,95); GPlot plot2 = new GPlot(this); plot2.setPos(510,95); GPlot plot3 = new GPlot(this); plot3.setPos(10,410); // Prepare the points for the four plots int nPoints = 21; GPointsArray points1 = new GPointsArray(nPoints); GPointsArray points2 = new GPointsArray(nPoints); GPointsArray points3 = new GPointsArray(nPoints); GPointsArray points4 = new GPointsArray(nPoints); for(int i=0; i< nPoints; i++) { while(myPort.read() != '\n') { ; } val1=myPort.read(); val2=myPort.read(); val3=myPort.read(); if(val1 != -1 && val2 != -1 && val3 != -1) { fill(0); rect(750,455,100,400); fill(255); text(val1, 760, 460); text(val2, 760, 510); text(val3, 760, 560); points1.add(i,val1); points2.add(i,val2); points3.add(i,val3); points4.add(i, i); println(val1); println(val2); println(val3); } } // Set the points, the title and the axis labels plot1.setPoints(points1); plot1.getXAxis().setAxisLabelText("Samples"); plot1.getYAxis().setAxisLabelText("Degree F"); plot1.setTitleText("TEMPERATURE (F)"); plot2.setPoints(points2); plot2.getXAxis().setAxisLabelText("Samples"); plot2.getYAxis().setAxisLabelText("Bpm"); plot2.setTitleText("PULSE RATE (Bpm)"); plot3.setPoints(points3); plot3.getXAxis().setAxisLabelText("Samples"); plot3.getYAxis().setAxisLabelText("%"); plot3.setTitleText("SpO2 (%)"); plot1.defaultDraw(); plot2.defaultDraw(); plot3.defaultDraw(); } } public void enter() { int nPoints = 10; //cp5.get(Textfield.class,"input").clear(); textValue = cp5.get(Textfield.class,"input").getText(); //text(textValue, 360,180); println(textValue); if(started==0) { myPort = new Serial(this, textValue, 9600); started=1; } else { myPort.stop(); started=0; } }