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; 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"); } 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() { 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