void keyPressed() { if(keyCode == LEFT){ leftright = leftright + 5; }else if(keyCode == RIGHT){ leftright = leftright - 5; } if(leftright < 0){ leftright = 0; } else if(leftright >= (val.length - width)){ leftright = val.length - width; } }
http://trendy.nikkeibp.co.jp/article/column/20111206/1038885/?ST=life&P=1&rt=nocnt )
String data[]; float val[][]; // ǥ饤ɤ뤿ѿ int leftright = 0; // Ѥѿ void setup() { background(0); noLoop(); size(2280, 480); // դXɤäͤˤäѹ(ͽ) String loadPath = selectInput(); // եϤ뤿Υեνи if (loadPath == null) { println("ե뤬Ƥޤ"); // ե뤬Ƥʤä } else { println(loadPath); // ե뤬줿顢եѥɽ data = loadStrings(loadPath); // CSVƥȤɤ߹ val = new float[data.length][3]; // CSVƥȤιԤĹ /* :loadPathϤޤǥեѥʤΤǡloadStringsǥեѥȤ */ for (int i = 0; i < data.length; i++) { String d[] = data[i].split(","); // ƥΥޤʸ˳Ǽ for(int j = 0; j < d.length; j++){ // ԤĹ֤x, y, zͤȤ val[i][j] = float(d[j]); // floatѴ print(val[i][j]+":"); } print("\n"); } } } void draw() { /*if(keyPressed == true) { if(keyCode == LEFT && leftright <= 0){ leftright = leftright + 1; }else if(keyCode == RIGHT && leftright >= -10000){ leftright = leftright - 1; } }*/ stroke(255, 0, 0); noFill(); beginShape(); for (int i = 0; i < val.length; i++) { //if(i%100==0){ println(val[i][0]*100.0); vertex(i, 150.0-val[i][0]*100.0); // դ:x //} } endShape(); stroke(0, 255, 0); noFill(); beginShape(); for (int i = 0; i < val.length; i++) { //if(i%100==0){ println(val[i][1]*100.0); vertex(i, 310.0-val[i][1]*100.0); // դ:y //} } endShape(); stroke(0, 0, 255); noFill(); beginShape(); for (int i = 0; i < val.length; i++) { //if(i%100==0){ println(val[i][2]*100.0); vertex(i, 470.0-val[i][2]*100.0); // դ:z //} } endShape(); }
String data[]; void setup() { background(0); noLoop(); size(180, 480); // դXɤäͤˤäѹ(ͽ) String loadPath = selectInput(); // եϤ뤿Υեνи if (loadPath == null) { println("ե뤬Ƥޤ"); // ե뤬Ƥʤä } else { println(loadPath); // ե뤬줿顢եѥɽ data = loadPath; // CSVƥȤɤ߹ for (int i = 1, i < data.length; i++) { String d[] = data[i].split(",");// ƥΥޤʸ Ǽ int val[] = int(d); // intѴ } } } // 3դν void drawLine(int i, float xval1, float yval1, float zval1, float xval2, float yval2, float zval2){ stroke(200,0,0); line(i, xval1, i, 250-xval2); stroke(0,200,0); line(i, 250-yval1, i, 250-yval2); stroke(0,200,0); line(i, 250-zval1, i, 250-zval2); } void draw() { for(int i = 1; i < data.length; i++) { // ޤդν drawLine(i, , , , , , , ); // } }
SimpleScope?
SimpleScopeArduinoFio?import processing.funnel.*; final int id = 5; // end device ID final int kChannles = 3; // the number of channels to display //ĿŪʳĥ PrintWriter csvout; Fio fio; Scope[] scope; int startTime; int endTime; void setup() { size(340, 35+150*kChannles); frameRate(30); int[] moduleIDs = {id}; fio = new Fio(this, moduleIDs, Fio.FIRMATA); scope = new Scope[kChannles]; for (int channel = 0; channel < kChannles; channel++) { scope[channel] = new Scope(30, 35+150*channel, 200, 100, "A"+channel); } // ϥե̾ջ.csvפȤ롣 String y = str(year()); String mo = str(month()); String d = str(day()); String h = str(hour()); String mi = str(minute()); String s = str(second()); csvout = createWriter(y+mo+d+h+mi+s+".csv"); startTime = minute()*60+second(); } void draw() { background(0); for (int channel = 0; channel < kChannles; channel++) { scope[channel].updateAndDraw(fio.iomodule(id).analogPin(channel)); } } class Scope { private int l; private int t; private int h; private float values[]; private int index = 0; private int points = 200; private String title; Scope(int l, int t, int w, int h, String title) { this.l = l; this.t = t; this.h = h; this.points = w; this.title = title; values = new float[this.points]; } public void updateAndDraw(Pin pin) { values[index] = pin.value; smooth(); textSize(12); text(title, l - 24, t - 8); text("1.0", l - 24, t + 8); text("0.0", l - 24, t + h); text("val: " + pin.value, l + points + 8, t + 8); text("max: " + pin.maximum, l + points + 8, t + 20); text("min: " + pin.minimum, l + points + 8, t + 32); text("avg: " + pin.average, l + points + 8, t + 44); // draw outlines stroke(200); noFill(); beginShape(); vertex(l - 1, t - 1); vertex(l + points, t - 1); vertex(l + points, t + h); vertex(l - 1, t + h); endShape(CLOSE); // draw the signal stroke(255); beginShape(); for (int i = 1; i < points; i++) { vertex(l + i, t + h - values[(index + i) % points] * (float)h); } endShape(); // ĿŪ˳ĥ csvout.println(values[0]+","+values[1]+ ","+values[2]); index = (index + 1) % points; } } void keyPressed() { endTime = minute()*60+second(); int time = endTime - startTime; csvout.println(time); csvout.flush(); // Writes the remaining data to the file csvout.close(); // Finishes the file exit(); // Stops the program }
SimpleScope?
TOTAL_DIGITAL_PINS
SimpleScope?
SimpleScope? http://www.atinfinity.info/wiki/index.php?Gainer%2F%E5%8A%A0%E9%80%9F%E5%BA%A6%E3%82%BB%E3%83%B3%E3%82%B5
http://gainer.cc/Cookbook/AccelerationSensor