Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Re : Visualise Real time long CSV datatype

$
0
0
Here`s the CSV data:


The package EEG data i am getting in the Serial Monitor is as follows:
"signal strength, attention, meditation, delta, theta, low alpha, high alpha, low beta, high beta, low gamma, high gamma"

Now, i want the processing to read these data types and bring up visuals, corresponding to it. 

Here`s a bit of coding i tried doing, but in vain:

import processing.serial.*;

Serial myPort;

int channels= 10;
int [] channel= new int[channels];
int packetCount=0;

void setup() {
  size(800,600);
  println(Serial.list());
  String portName= Serial.list() [0];
  myPort= new Serial(this, portName, 9600);
  myPort.bufferUntil(10);
  background(0);
  smooth();
}

void draw() {
  if(channel.length>3) {
    for (int i=3; i<channel.length; i++) {
      ellipse(400,300, channel[i], channel[i]);
      
}
  }
}

void serialEvent (Serial myPort) {
  String[] incomingValues = split(myPort.readString(), ',');
  println (incomingValues);
  
  if(incomingValues.length>1) {
    packetCount++;
    
    if (packetCount>3) {
      for (int i = 0; i < incomingValues.length; i++) {
        int newValue = Integer.parseInt(incomingValues[i].trim());
        
        if ((Integer.parseInt(incomingValues[0]) == 200) && (i > 2)) newValue = 0;
        
//    channel[i].addDataPoint(newValue);
      }
    }
  }
}


  long mapLong(long x, long in_min, long in_max, long out_min, long out_max) { 
  return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}

// Extend Processing's built-in constrain() function to support the Long datatype
long constrainLong(long value, long min_value, long max_value) {
  if (value > max_value) return max_value;
  if (value < min_value) return min_value;
  return value;
}  

I dont know where to go from here. I want to visualise each data type from the hacked arduino EEG. Plz help.

Viewing all articles
Browse latest Browse all 1768

Trending Articles