|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object maslab.orc.Orc
public class Orc
Low-level access to the OrcBoard; when possible, use a wrapper class.
Nested Class Summary | |
---|---|
static class |
Orc.DrawMode
|
static class |
Orc.LcdFont
|
static class |
Orc.MotorDirection
Motor Direction constants, for use with motorSet. |
static class |
Orc.PinMode
Pin modes, for use with pinModeSet |
Field Summary | |
---|---|
static int |
BUTTON_DOWN
|
static int |
BUTTON_LEFT
|
static int |
BUTTON_MENU
Bit field mask for the Pad's Menu button |
static int |
BUTTON_RIGHT
|
static int |
BUTTON_STICK
Bit field mask for the Pad's Stick button |
static int |
BUTTON_STOP
Bit field mask for the Pad's Stop button |
static int |
BUTTON_UP
|
Constructor Summary | |
---|---|
Orc()
Create a new Orc object, connecting to localhost on the default ports (7320, 7321) |
|
Orc(java.lang.String host)
|
|
Orc(java.lang.String host,
int cmdport,
int asyncport)
Create a new Orc object. |
Method Summary | |
---|---|
void |
addUpdateListener(OrcUpdateListener ul)
Add an OrcUpdateListener. |
void |
allStop()
Perform an emergency allStop. |
int |
analogLPFRead(int port)
Read the current low-pass filter value. |
void |
analogLPFWrite(int port,
int val)
Configure the analog low-pass filter for a port. |
double |
analogRead(int port)
ports 0-19 correspond to numbered ports. |
long |
clockRead()
Read the Orc board's internal clock, a 16 bit counter updating at 512 Hz. |
int |
dacRead(int port)
Read the DAC (digital-to-analog) NOT IMPLEMENTED. |
void |
dacWrite(int port,
int v)
Write to the DAC (digital-to-analog). |
static int |
diff16(long a,
long b)
Compute a-b, accounting for wraparound with 16 bit numbers. |
static long |
diff32(long a,
long b)
Compute a-b, accounting for wraparound with 32 bit numbers. |
boolean |
digitalRead(int port)
Read the digital port. |
void |
digitalWrite(int port,
boolean v)
Write the digital port. |
long |
gyroReadRaw()
Read the raw gyro integrator value. |
boolean |
i2cRead(int addr,
byte[] buf,
int len)
Perform an I2C Read transaction REQUIRES FIRMWARE UPGRADE. |
boolean |
i2cWrite(int addr,
byte[] buf,
int len)
Perform an I2C Write transaction REQUIRES FIRMWARE UPGRADE. |
boolean |
i2cWriteRead(int addr,
byte[] writebuf,
int writelen,
byte[] readbuf,
int readlen)
Perform a combined write/read I2C transaction UNTESTED. |
int |
joyX()
Returns the Pad's current joystick position (X axis) |
int |
joyY()
Returns the Pad's current joystick position (Y axis) |
void |
lcdClear()
Clear the LCD |
void |
lcdConsoleGoto(int x,
int y)
Move the console cursor position. |
void |
lcdConsoleHome()
Clear the portion of the lcd being used by the console, and move the cursor to the top left position. |
void |
lcdConsoleSettings(int top,
int height,
int left,
int width)
Set the console size and location. |
void |
lcdConsoleWrite(java.lang.String s)
Write text to the console at the current cursor position. |
void |
lcdDrawLine(int x0,
int y0,
int x1,
int y1)
Draw a line. |
void |
lcdDrawMode(Orc.DrawMode dm)
Set the draw mode. |
void |
lcdDrawText(Orc.LcdFont font,
int x,
int y,
java.lang.String s)
Draw text at an arbitrary location. |
void |
lcdFill(int even,
int odd)
Fill the entire LCD with a pattern. |
java.awt.image.BufferedImage |
lcdRead()
Read the entire LCD frame buffer. |
void |
lcdRead(int x,
int y,
int length,
byte[] buf,
int offset)
Read the LCD's frame buffer. |
void |
lcdWrite(int xi,
int yi,
java.awt.image.BufferedImage i)
Draw an image on the lcd. |
void |
lcdWrite(int x,
int y,
byte[] buf,
int blocksize)
Write to the LCD's frame buffer. |
Orc.MotorDirection |
motorActualDirectionRead(int port)
Returns the motor's actual direction. |
int |
motorActualRead(int port)
Read the motor's current PWM. |
double |
motorCurrentRead(int port)
Returns the current consumption for the motor. |
Orc.MotorDirection |
motorGoalDirectionRead(int port)
Returns the motor's goal direction. |
int |
motorGoalRead(int port)
Read the motor's current goal PWM |
int |
motorSlewRead(int port)
Returns the current slew rate. |
void |
motorSlewWrite(int port,
int slew)
Set the rate at which motors can change the PWM. |
void |
motorWrite(int port,
int pwm)
Set a motor's goal speed and direction. |
void |
motorWrite(int port,
int pwm,
Orc.MotorDirection dir)
Set a motor's goal speed and direction. |
int |
padButtonsGet()
Wait for a button to be pressed and released, and return it. |
int |
padButtonsPoll()
Test the current status of the buttons and return immediately. |
Orc.PinMode |
pinModeRead(int port)
Determine the new pin mode. |
void |
pinModeWrite(int port,
Orc.PinMode m)
Configure a port. |
int |
pwmDutyCycleRead(int port)
NOT IMPLEMENTED. |
int |
pwmPeriodRead(int port)
NOT IMPLEMENTED. |
int |
pwmSourceRead(int port)
NOT IMPLEMENTED. |
void |
pwmWrite(int port,
int source,
int period,
int dutycycle)
NOT IMPLEMENTED. |
int |
quadphaseErrorsRead(int port)
Returns the number of errors that have occured on the quadphase port. |
int |
quadphaseRead(int port)
Read the quadphase/monophase counter. |
void |
removeUpdateListener(OrcUpdateListener ul)
Remove an OrcUpdateListener. |
double |
servoCurrentRead(int port)
Returns the current consumption for the servo. |
int |
servoRead(int port)
Read the servo's current position. |
void |
servoWrite(int port,
int v)
Write the servo's position. |
void |
setCacheLifetime(int ms)
Set the maximum number of milliseconds that the cache will be used for. |
void |
ultrasoundPing(int port)
Initiate a new ultrasound ping. |
int |
ultrasoundPingCount(int port)
Returns a continuously running 4bit counter of the number of pings on this port |
double |
ultrasoundRange(int port)
Determine the range for an ultrasound ping. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int BUTTON_STICK
public static final int BUTTON_MENU
public static final int BUTTON_STOP
public static final int BUTTON_UP
public static final int BUTTON_DOWN
public static final int BUTTON_LEFT
public static final int BUTTON_RIGHT
Constructor Detail |
---|
public Orc() throws java.io.IOException
java.io.IOException
public Orc(java.lang.String host) throws java.io.IOException
java.io.IOException
public Orc(java.lang.String host, int cmdport, int asyncport) throws java.io.IOException
host
- The host to connect tocmdport
- The TCP port for command connectionsasyncport
- The TCP port for async event connections
java.io.IOException
Method Detail |
---|
public void setCacheLifetime(int ms)
public Orc.MotorDirection motorGoalDirectionRead(int port)
port
- [0,3]public Orc.MotorDirection motorActualDirectionRead(int port)
port
- [0,3]public int motorActualRead(int port)
public int motorGoalRead(int port)
public double motorCurrentRead(int port)
port
- [0,3]
public double servoCurrentRead(int port)
port
- [0,3]
public double analogRead(int port)
public void analogLPFWrite(int port, int val)
port
- [0,19] that supports analog in.val
- [0,10]. The parameter of the low-pass filter, higher numbers
representing much stronger filtering.public int analogLPFRead(int port)
port
- [0,19] that supports analog in.public int dacRead(int port)
port
- [12]
public void dacWrite(int port, int v)
port
- [12]v
- [0,255]public boolean digitalRead(int port)
port
- [0,19]public void digitalWrite(int port, boolean v)
port
- [0,19]v
- The valuepublic int servoRead(int port)
port
- [0,3]
public void servoWrite(int port, int v)
port
- [0,3]v
- [0,65535] The PWM value.public void ultrasoundPing(int port)
port
- The port, 4 or 6.public double ultrasoundRange(int port)
port
- The port, 5 or 7.
public int ultrasoundPingCount(int port)
public void pinModeWrite(int port, Orc.PinMode m)
port
- The port, [0,19].m
- The mode.public Orc.PinMode pinModeRead(int port)
port
- The port, [0,19].public void pwmWrite(int port, int source, int period, int dutycycle)
public int pwmSourceRead(int port)
public int pwmPeriodRead(int port)
public int pwmDutyCycleRead(int port)
public int quadphaseErrorsRead(int port)
port
- The port, [16,19].public int quadphaseRead(int port)
port
- The port, [16,19].public void allStop()
public void motorWrite(int port, int pwm, Orc.MotorDirection dir)
port
- [0,3]pwm
- [0,255]. For directions other than disabled, low
pwms imply braking.dir
- The directionpublic void motorWrite(int port, int pwm)
port
- [0,3]pwm
- [-255,255]. Negative PWMs correspond to backwards,
positive PWM to forwards. The motor is never disabled with this
API.public void motorSlewWrite(int port, int slew)
port
- [0,3]slew
- [1,255]. Motor speeds are updated at 64Hz, so the
worst case slewing interval is seconds=512/(64*slew).public int motorSlewRead(int port)
port
- [0,3]public int padButtonsGet()
public int padButtonsPoll()
public int joyX()
public int joyY()
public void lcdClear()
public void lcdConsoleGoto(int x, int y)
public void lcdConsoleWrite(java.lang.String s)
public void lcdFill(int even, int odd)
public void lcdDrawLine(int x0, int y0, int x1, int y1)
public void lcdConsoleHome()
public void lcdConsoleSettings(int top, int height, int left, int width)
top
- The top line of the console, [0,7]height
- The number of lines in the console, [0,7].left
- The leftmost column of the console [0,31]width
- The number of columns in the console.public void lcdDrawMode(Orc.DrawMode dm)
public void lcdDrawText(Orc.LcdFont font, int x, int y, java.lang.String s)
font
- The font to draw inx
- The x location (in pixels), [0, 127]y
- The y location (in pixels), [0, 63]s
- The string to write, no more than 32 characters long.public void lcdRead(int x, int y, int length, byte[] buf, int offset)
x
- The x offset to begin reading from.y
- The y offset to begin reading from. Must be a multiple of 8.length
- The number of bytes to read.buf
- The buffer to deposit the data intooffset
- The offset in the bufferpublic void lcdWrite(int x, int y, byte[] buf, int blocksize)
x
- The x offset to begin writing from.y
- The y offset to begin writing from. Must be a multiple of 8.buf
- The buffer to get the data fromblocksize
- The number of bytes to use from the bufferpublic java.awt.image.BufferedImage lcdRead()
public void lcdWrite(int xi, int yi, java.awt.image.BufferedImage i)
xi
- The top left x coordinate, [0,127]yi
- The top left y coordinate, [0,63] and a multiple of 8.i
- The image. For good results, the image should be
reduced to dithered black and white. This procedure uses only
the green channel to determine whether a pixel should be on or
off.public long clockRead()
public long gyroReadRaw()
public boolean i2cRead(int addr, byte[] buf, int len)
addr
- I2C Address, [0,127]buf
- Buffer to deposit data intolen
- Length of read (<64)
public boolean i2cWrite(int addr, byte[] buf, int len)
addr
- I2C Address, [0,127]buf
- Buffer to data to writelen
- Length of write (<64)
public boolean i2cWriteRead(int addr, byte[] writebuf, int writelen, byte[] readbuf, int readlen)
addr
- I2C Address, [0,127]writebuf
- The buffer which will be written firstwritelen
- The length of the buffer (<64)readbuf
- The buffer in which to deposit read datareadlen
- The number of bytes to read (<64)
public static int diff16(long a, long b)
public static long diff32(long a, long b)
public void addUpdateListener(OrcUpdateListener ul)
public void removeUpdateListener(OrcUpdateListener ul)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |