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

Re : Saving high resolution frames from serial input

$
0
0
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

  1. import processing.serial.*;
  2. import processing.pdf.*;

  3. Serial myPort;

  4. int channels = 10;
  5. int [] channel = new int[channels];
  6. int packetCount = 0;

  7. float x;

  8. PGraphicsPDF pdf;

  9. //float easing=1;
  10. //int last;
  11. //int millis();
  12. String[] incomingValues;


  13. void setup() {
  14.   size(1000, 1000);
  15.   println(Serial.list());
  16.   String portName= Serial.list() [0];
  17.   myPort= new Serial(this, portName, 9600);
  18.   myPort.bufferUntil(10);
  19.   smooth();
  20.   noFill();
  21.   stroke(160);
  22.   frameRate(24);
  23.     pdf = (PGraphicsPDF)beginRecord(PDF, "Lines.pdf");
  24.   beginRecord(pdf);

  25. }

  26. void draw() {
  27.    background(0);
  28.   if (incomingValues != null && incomingValues.length>1)
  29.     {
  30.       stroke(255);
  31.       int amplitude = 100 - int(incomingValues[1].trim());
  32.       float y = 0;
  33.       float prevY = 0;
  34.  
  35.       for (int i = 1; i < width; i++)
  36.       {        y = sin(radians(i*2))*amplitude;
  37.         line(i-1, prevY+height/2, i, y+height/2);       
  38.         prevY = y;
  39.       }
  40.   }
  41.   pdf.nextPage();
  42. }

  43. void serialEvent (Serial myPort) {
  44.   incomingValues = split(myPort.readString(), ',');
  45.  
  46.   if (incomingValues.length>1) {
  47.     packetCount++;
  48.     println(incomingValues[1]);
  49.   }
  50. }

  51. void mousePressed() {
  52.   endRecord();
  53.   exit();
  54. }

Please help. I am in need of a way out.

Thank you



  



Viewing all articles
Browse latest Browse all 1768

Trending Articles