Requirements

Instructions

  1. Unzip the archive (you can donwload at http://code.google.com/p/funnel/downloads/list)
  2. Create "funnel" sub-folder in "Processing/libraries/" in your document folder ("My Documents" on Windows XP, "Documents" on Windows Vista and Mac OS X)
  3. Copy "library" and "examples" of "libraries/processing/" into the folder.
  4. Launch Processing to confirm that "funnel" is displayed as a menu item of "Sketch > Import Library..." menu. If you can't see, please confirm about the previous steps.
  5. Open one of the examples that comes with the library from "File > Sketchbook > libraries > funnel > examples".

Reference

Gainer(parent, mode)
Create a Gainer object. parent should be "this" (without the quotes); mode is the configuration of Gainer such as "Gainer.MODE1" (without the quotes)
Arduino(parent, configuration)
Create an Arduino object. parent should be "this" (without the quotes); configuration should be a Configuration object such as Arduino.FIRMATA.
Configuration.setDigitalPinMode(number, type)
Set a digital pin to input, output or PWM mode (Arduino.IN or Arduino.OUT, Arduino.PWM).
button(number)
Returns the Pin object of the on-board button (Gainer)
led(number)
Returns the Pin object of the on-board LED (Gainer)
analogInput(number)
Returns the Pin object of the pin (Gainer)
analogOutput(number)
Returns the Pin object of the pin (Gainer)
digitalInput(number)
Returns the Pin object of the pin (Gainer)
digitalOutput(number)
Returns the Pin object of the pin (Gainer)
digitalPin(number)
Returns the Pin object of the digital pin (Arduino)
analogPin(number)
Returns the Pin object of the analog pin (Arduino)
Pin.value
Returns the value of the pin (from 0 to 1)
Pin.maximum
Returns the maximum value of the pin (from 0 to 1)
Pin.minimum
Returns the minimum value of the pin (from 0 to 1)
Pin.average
Returns the average value of the pin (from 0 to 1)
Pin.value =
Sets a value of a pin (from 0 to 1)
Pin.addFilter(Filter newFilter)
Adds a new filter to the pin
Pin.setFilters(Filter[] newFilters)
Sets new filters to the pin
Pin.removeAllFilters()
Removes all filters from the pin
SetPoint(threshold, hysteresis)
Create a SetPoint object; threshold is the threshold to divide an input to 1 or 1; hysteresis is the allowance for the threshold.

Examples

Gainer

/*
  Gainer Test

  Control the LED by mouse, the background color by the button.

  The circuit:
  * inputs
    - Button: the on-board tactile switch
  * outputs
    - LED: the on-board LED

  Created 10 May 2009
  By Shigeru Kobayashi

  Modified 13 May 2009
  By Shigeru Kobayashi

  http://funnel.cc/
  http://gainer.cc/

*/


import processing.funnel.*;

Gainer gainer;

color backgroundColor = color(50, 50, 50);

void setup() {
  size(200, 200);
  textFont(createFont("CourierNewPSMT", 12));

  gainer = new Gainer(this, Gainer.MODE1);

  // NOTE:
  // Regarding Gainer, a SetPoint filter is attached on each
  // digital input (including the button) by default.
  // You can add a SetPoint filter to analog inputs as follows:
  // gainer.analogInput(0).addFilter(new SetPoint(0.5, 0.1));
}

void draw() {
  background(backgroundColor);
  for (int i = 0; i < gainer.analogInput.length; i++) {
    text("a " + i + ": " + gainer.analogInput(i).value, 10, 20 + 20 * i)
  }
}

void mousePressed() {
  gainer.led().value = 1.0;
}

void mouseReleased() {
  gainer.led().value = 0.0;
}

// on change from 0 to 1 (or non-zero)
void risingEdge(PinEvent e) {
  if (e.target.number == Gainer.button) {
    // the button is pressed
    backgroundColor = color(255, 50, 50);
  }
}

// on change from 1 (or non-zero) to 0
void fallingEdge(PinEvent e) {
  if (e.target.number == Gainer.button) {
    // the button is released
    backgroundColor = color(50, 50, 50);
  }
}

Arduino

/*
  Arduino Test

  Control a LED by mouse, the background color by a switch.

  The circuit:
  * inputs
    - D12: a tactile switch with a pulldown resistor (e.g. 10k ohm)
  * outputs
    - D13: a LED with a current-limiting resistor (e.g. 330 ohm)

  Created 10 May 2009
  By Shigeru Kobayashi

  Modified 13 May 2009
  By Shigeru Kobayashi

  http://funnel.cc/
  http://arduino.cc/
  http://firmata.org/

*/


import processing.funnel.*;

Arduino arduino;
int switchPin = 12;
int ledPin = 13;

color backgroundColor = color(50, 50, 50);

void setup() {
  size(200, 200);
  textFont(createFont("CourierNewPSMT", 12));

  Configuration config = Arduino.FIRMATA;
  config.setDigitalPinMode(switchPin, Arduino.IN);
  config.setDigitalPinMode(ledPin, Arduino.OUT);

  arduino = new Arduino(this, config);
  arduino.digitalPin(switchPin).addFilter(new SetPoint(0.5, 0.1));
}

void draw() {
  background(backgroundColor);
  for (int i = 0; i < 6; i++) {
    text("A" + i + ": " + arduino.analogPin(i).value, 10, 20 + 20 * i)
  }
}

void mousePressed() {
  arduino.digitalPin(ledPin).value = 1.0;
}

void mouseReleased() {
  arduino.digitalPin(ledPin).value = 0.0;
}

// on change from 0 to 1 (or non-zero)
void risingEdge(PinEvent e) {
  if (e.target.number == switchPin) {
    // the switch is pressed
    backgroundColor = color(255, 50, 50);
  }
}

// on change from 1 (or non-zero) to 0
void fallingEdge(PinEvent e) {
  if (e.target.number == switchPin) {
    // the switch is released
    backgroundColor = color(50, 50, 50);
  }
}

Reference

http://funnel.cc/reference/processing/


Language / 言語

Featured Pages

For Members

Not a member?