// Pascal.pde This program needs Pascal.ino to controle Arduino Uno // Pascal.ino modified from the original scktchs "i2c_command" provided by Infineon Technologies // This version is tested on Raspverry Pi Linux only // prog. by Yoshio Okamoto 2022-01-31 import processing.serial.*; int xmax = 1500; // windows size for width int ymax = 800; // for height int tmax = xmax * 12; // data max 12: Rows for signal line int base = 0; // wave signal base line shift; calicurating automatially from the initial data int x = 0; // for signal display int y = 0; int px = 0; // past coordinate x int py = 0; // y int k = 0; // mean value counter int kmax = 10; // data max for mean value caliculasion int yy = 0; // sum for y data mean caliculation int m = 0; // minte for time mark int pm = 0; // past value of m Serial Port; //Port: serial port name int lf = 10; // ASCII return String Pascal = ""; // pressure value string float pressure; // presure value float int t = 0; int tt = 0; int ttt = 0; // row number int tm = 0; // time mark float M = 300.0; // Magnify pressure level for display String datastr; // display for time stamp String datetimestr; // PrintWriter output; void setup() { size(1500, 800); stroke (0,200,200); background(0); // list available serial port printArray(Serial.list()); Port = new Serial(this, Serial.list()[1], 9600); // if no line, please check the comment window of Processing, Port.clear(); // and adjust Serial.list()[1] to Arduino port number Pascal = Port.readStringUntil(lf); Pascal = null; Port.bufferUntil(10); frameRate(5); // sampling rate/sec 5[Hz], you can adjust it, if need delay(2000); // skip 2[sec] for initialize Port.write('*'); } void draw() { pressure = float(Pascal)/100; // Pascal to hPa println(pressure); // pressure value display // data file init. if (t == 0){ datetimestr = year()+"/"+nf(month(),2)+"/"+nf(day(),2)+"/Time="+nf(hour(),2) + "_" + nf(minute(),2) + "_" + nf(second(),2)+"_DPS310"; // for Windows output = createWriter(datetimestr+".dat"); text( datetimestr,10,35); Port.write( '*' ); // caliculationg base from initial mean of y for (k=0; ktmax){ t = 0; tt = 0; // save window image save( datetimestr+".png" ); output.flush(); // write buffer to file output.close(); // close file background(0); // reflesh window } } // for 1ch signal data input from Arduino void serialEvent( Serial Port ) { if ( Port.available() > 1 ) { Pascal = Port.readStringUntil(10); // data are input from Arduino as string not float or int -> this takes long time Port.write( '*' ); } }