cc.littleWire
Class LittleWire

java.lang.Object
  extended by cc.littleWire.LittleWire

public class LittleWire
extends Object

Processing interface library for Little Wire

+Example
/*
 Basic analog voltage reading and 
 plotting example for Little Wire.
 
 Connect a potentiometer to PIN2
 
 April 2012 - ihsan Kehribar
 http://kehribar.me/projects/little-wire
 */

import cc.littleWire.*;

LittleWire lw;

PFont myFont;
int stepSize=3;
int x_axis=0;
int previous_y=0;
int actual_y;
int voltage=0;
boolean connected=false;
byte i=0;
int version;

void setup()
{
  lw = new LittleWire();
  connected=lw.Connect();
  if(connected)
  {
  	lw.pwm_stop();
  	lw.pinMode(lw.PIN2,lw.INPUT);
  	version=lw.readFirmwareVersion();
    System.out.printf("Little Wire firmware version: %d.%d\n",((version & 0xF0)>>4),(version&0x0F));	  
  }	
  size(800, 512);
  background(220);
  myFont = loadFont("AgencyFB-Reg-25.vlw");
  textFont(myFont, 32);
}

void draw()
{
	if(connected)
	{
	  voltage=lw.analogRead(lw.ADC_PIN2);
	  fill(255);
	  rect(5,5,90,45);
	  fill(0);
	  text((voltage*5/1024.0),15,40);
	  if (x_axis>800)
	  {
	    background(220);
	    x_axis=0;
	  }
	  actual_y=512-(voltage/2); // Because the zero location of y axis is at the left side
	  line(x_axis, previous_y, x_axis+stepSize,actual_y);
	  x_axis=x_axis+stepSize;
	  previous_y=actual_y;
	}
}

Field Summary
 int ADC_PIN2
           
 int ADC_PIN3
           
 int ADC_TEMP_SENS
           
 int AUTO_CS
           
 int HIGH
           
 int INPUT
           
 int LOW
           
 int MANUAL_CS
           
 int OUTPUT
           
 int PIN1
           
 int PIN2
           
 int PIN3
           
 int PIN4
           
 int PWM1
           
 int PWM2
           
static String VERSION
           
 
Constructor Summary
LittleWire()
           
 
Method Summary
 int analogRead(int channel)
          Read analog voltage from a spesific channel
 boolean Connect()
          Try to connect to the device
 byte digitalRead(int pin)
          Read a state of a GPIO pin
 void digitalWrite(int pin, int state)
          Set a GPIO pin High/Low
 void pinMode(int pin, int mod)
          Set a GPIO pin input/output
 void pwm_init()
          Initialize the Pwm module on the device
 void pwm_stop()
          Stop the Pwm module on the device
 void pwm_updateCompare(int channelA, int channelB)
          Update the compare values of Pwm outputs
 void pwm_updatePrescaler(int value)
          Change the Pwm prescaler.
 int readFirmwareVersion()
          Reads the firmware version of the Little Wire \n Format: 0xXY => X: Primary version Y: Minor version
 void servo_init()
          Servo module initialization
 void servo_updateLocation(int locationChannelA, int locationChannelB)
          Servo locations update
static String version()
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final String VERSION
See Also:
Constant Field Values

PIN1

public int PIN1

PIN2

public int PIN2

PIN3

public int PIN3

PIN4

public int PIN4

ADC_PIN3

public int ADC_PIN3

ADC_PIN2

public int ADC_PIN2

ADC_TEMP_SENS

public int ADC_TEMP_SENS

PWM1

public int PWM1

PWM2

public int PWM2

INPUT

public int INPUT

OUTPUT

public int OUTPUT

LOW

public int LOW

HIGH

public int HIGH

MANUAL_CS

public int MANUAL_CS

AUTO_CS

public int AUTO_CS
Constructor Detail

LittleWire

public LittleWire()
Method Detail

Connect

public boolean Connect()
Try to connect to the device

Returns:
true for success, false for fail

readFirmwareVersion

public int readFirmwareVersion()
Reads the firmware version of the Little Wire \n Format: 0xXY => X: Primary version Y: Minor version

Parameters:
(none) -
Returns:
Firmware version

version

public static String version()

digitalWrite

public void digitalWrite(int pin,
                         int state)
Set a GPIO pin High/Low

Parameters:
pin: - Pin number
state: - 1 for High, 0 for Low

pinMode

public void pinMode(int pin,
                    int mod)
Set a GPIO pin input/output

Parameters:
pin: - Pin number
mod: - 1 for input, 0 for output

digitalRead

public byte digitalRead(int pin)
Read a state of a GPIO pin

Parameters:
pin: - Pin number
Returns:
1 for HIGH, 0 for LOW

analogRead

public int analogRead(int channel)
Read analog voltage from a spesific channel

Parameters:
channel: - 0 for RESET pin, 1 for SCK pin, 2 for internal Temperature sensor
Returns:
Analog voltage in 10bit resoultion

pwm_init

public void pwm_init()
Initialize the Pwm module on the device


pwm_stop

public void pwm_stop()
Stop the Pwm module on the device


pwm_updateCompare

public void pwm_updateCompare(int channelA,
                              int channelB)
Update the compare values of Pwm outputs

Parameters:
channelA: - Compare value of Channel A
channelB: - Compare value of Channel B /

pwm_updatePrescaler

public void pwm_updatePrescaler(int value)
Change the Pwm prescaler. Default: 1024

Parameters:
value: - 1024/256/64/8/1

servo_init

public void servo_init()
Servo module initialization


servo_updateLocation

public void servo_updateLocation(int locationChannelA,
                                 int locationChannelB)
Servo locations update

Parameters:
locationChannelA - in degrees
locationChannelB - in degrees


Processing library LittleWire by ihsan Kehribar. (C) 2011