|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcc.littleWire.LittleWire
public class LittleWire
Processing interface library for Little Wire
/* 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 |
---|
public static final String VERSION
public int PIN1
public int PIN2
public int PIN3
public int PIN4
public int ADC_PIN3
public int ADC_PIN2
public int ADC_TEMP_SENS
public int PWM1
public int PWM2
public int INPUT
public int OUTPUT
public int LOW
public int HIGH
public int MANUAL_CS
public int AUTO_CS
Constructor Detail |
---|
public LittleWire()
Method Detail |
---|
public boolean Connect()
public int readFirmwareVersion()
(none)
-
public static String version()
public void digitalWrite(int pin, int state)
pin:
- Pin numberstate:
- 1 for High, 0 for Lowpublic void pinMode(int pin, int mod)
pin:
- Pin numbermod:
- 1 for input, 0 for outputpublic byte digitalRead(int pin)
pin:
- Pin number
public int analogRead(int channel)
channel:
- 0 for RESET pin, 1 for SCK pin, 2 for internal Temperature sensor
public void pwm_init()
public void pwm_stop()
public void pwm_updateCompare(int channelA, int channelB)
channelA:
- Compare value of Channel AchannelB:
- Compare value of Channel B
/public void pwm_updatePrescaler(int value)
value:
- 1024/256/64/8/1public void servo_init()
public void servo_updateLocation(int locationChannelA, int locationChannelB)
locationChannelA
- in degreeslocationChannelB
- in degrees
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |