Hello,
Thanks for the reply.
I did try, but there seems to be an error in the pdf file, it doesnt open.
I tried putting the code in a way you told me earlier, but i am still facing the following problems:
1. The visual is updating per second as opposed to a smooth transition, which is making it blink. (Should i use millis() and if yes, how? )
2. The pdf doesnt seem to open when i try to record many pages
Here`s the code
- import processing.serial.*;
- import processing.pdf.*;
- Serial myPort;
- int channels = 10;
- int [] channel = new int[channels];
- int packetCount = 0;
- float x;
- PGraphicsPDF pdf;
- //float easing=1;
- //int last;
- //int millis();
- String[] incomingValues;
- void setup() {
- size(1000, 1000);
- println(Serial.list());
- String portName= Serial.list() [0];
- myPort= new Serial(this, portName, 9600);
- myPort.bufferUntil(10);
- smooth();
- noFill();
- stroke(160);
- frameRate(24);
- pdf = (PGraphicsPDF)beginRecord(PDF, "Lines.pdf");
- beginRecord(pdf);
- }
- void draw() {
- background(0);
- if (incomingValues != null && incomingValues.length>1)
- {
- stroke(255);
- int amplitude = 100 - int(incomingValues[1].trim());
- float y = 0;
- float prevY = 0;
- for (int i = 1; i < width; i++)
- { y = sin(radians(i*2))*amplitude;
- line(i-1, prevY+height/2, i, y+height/2);
- prevY = y;
- }
- }
- pdf.nextPage();
- }
- void serialEvent (Serial myPort) {
- incomingValues = split(myPort.readString(), ',');
- if (incomingValues.length>1) {
- packetCount++;
- println(incomingValues[1]);
- }
- }
- void mousePressed() {
- endRecord();
- exit();
- }
Please help. I am in need of a way out.
Thank you