|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ridgesoft.handyboard.HandyBoard
public class HandyBoard
Handy Board support class.
Field Summary | |
---|---|
static int |
DIGITAL_IN
Address of the digital input port. |
static int |
PORTA
Address of port A on the 68HC11. |
static byte |
TYPE_HANDY_BOARD
Used in setBoardType method to denote a standard Handy Board. |
static byte |
TYPE_SUMO11
Used in setBoardType method to denote a Sumo11 board. |
Method Summary | |
---|---|
static int |
analog(int portNumber)
Samples the analog input for portNumber specified. |
static void |
beep()
Beeps the buzzer. |
static void |
clearDigitalOutput(int portNumber)
Clears the specified digital output bit. |
static void |
click()
Click the buzzer. |
static void |
enableEncoder(int encoder)
Enables the specified shaft encoder. |
static void |
enablePulseMeasurement(int port,
boolean enabled)
Initializes digital input 7 or 8 for pulse measurement. |
static AnalogInput |
getAnalogInput(int portNumber)
Gets the AnalogInput object for the specified input port. |
static byte |
getBoardType()
Returns the board type. |
static Speaker |
getBuzzer()
Gets the Speaker object for the buzzer. |
static DigitalInput |
getDigitalInput(int portNumber)
Gets the DigitalInput object for the specified input port. |
static DigitalOutput |
getDigitalOutput(int output)
Gets the DigitalOutput object for the specified output number. |
static int |
getEncoderCounts(int encoder)
Read the counts for the particular encoder. |
static int |
getEncoderRate(int encoder)
Read the current rate of the encoder counter. |
static IrReceiver |
getIrReceiver()
Gets the IrReceiver object for the infrared receiver. |
static Display |
getLcdDisplay()
Gets the Display object for the LCD. |
static Motor |
getMotor(int motor)
Gets the Motor object for the specified motor. |
static OutputStream |
getOutputStream()
Gets the OutputStream for the LCD. |
static Servo |
getServo(int servo)
Gets the Servo object for a particular Handy Board servo. |
static ShaftEncoder |
getShaftEncoder(int encoder)
Gets the ShaftEncoder object for a particular quadrature shaft encoder. |
static PushButton |
getStartButton()
Returns the PushButton object for the START button. |
static PushButton |
getStopButton()
Returns the PushButton object for the STOP button. |
static AnalogInput |
getThumbWheel()
Gets the AnalogInput object for the thumbwheel. |
static int |
irRead()
Reads a waiting character from the infrared receiver. |
static void |
irRxInitialize(int startMin,
int startMax,
int shortMin,
int threshold,
int longMax,
int numberOfBits,
boolean invertBits,
boolean reverseBits)
Initializes the receiver. |
static boolean |
isDigitalInputSet(int portNumber)
Reads a digital input bit. |
static boolean |
isDigitalOutputSet(int portNumber)
Returns the state of the specified digital output bit. |
static void |
play(int frequency,
int duration)
Plays the specified tone (frequency) using the buzzer. |
static void |
pulseDigitalOutput(int portNumber,
int duration)
Pulses the specified digital output bit. |
static int |
readEdgeCount(int port)
Returns the count of rising and falling edges detected on this input since pulse measurement was enabled by the enablePulseMeasurement method. |
static int |
readPulseDuration(int port)
Returns the duration of the last pulse, the value -1 will be returned if no pulse has completed since pulse intput was enabled or since the last read. |
static int |
readPulseDuration(int port,
boolean highPulse)
Returns the duration of the last high pulse. |
static int |
readThumbWheel()
Samples the thumbwheel analog input. |
static void |
setBoardType(byte type)
Tells the virtual machine what type of controller it is running on. |
static void |
setDigital9Direction(boolean isOutput)
Sets the direction for digital port 9. |
static void |
setDigitalOutput(int portNumber)
Set the specified digital output bit. |
static void |
setMotorPower(int motor,
int power)
Sets a motor's power. |
static void |
setServoPosition(int servo,
int position)
Sets the position of the specified servo. |
static void |
setTerminateOnStop(boolean terminateOnStop)
Configures whether the virtual machine terminates the program when the STOP button is pressed. |
static boolean |
startPressed()
Returns true if the START button is pressed. |
static boolean |
stopPressed()
Returns true if the STOP button is pressed. |
static void |
toggleDigitalOutput(int portNumber)
Toggles the specified digital output bit. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
Field Detail |
---|
public static final int DIGITAL_IN
public static final int PORTA
public static final byte TYPE_HANDY_BOARD
public static final byte TYPE_SUMO11
Method Detail |
---|
public static int analog(int portNumber)
portNumber
- number of the input
public static void beep()
Doesn't return until the beep is finished.
public static void clearDigitalOutput(int portNumber)
portNumber
- digital output bit to clear
public static void click()
Doesn't return until the click is finished.
public static void enableEncoder(int encoder)
encoder
- encoder to enable (0 to 2)public static void enablePulseMeasurement(int port, boolean enabled)
port
- digital input port to initialize (7 or 8)enabled
- true enables pulse measurement, false disables pulse
measurementpublic static AnalogInput getAnalogInput(int portNumber)
portNumber
- input pin number
public static byte getBoardType()
public static Speaker getBuzzer()
public static DigitalInput getDigitalInput(int portNumber)
portNumber
- input pin number on the Handy Board
public static DigitalOutput getDigitalOutput(int output)
output
- output pin number
public static int getEncoderCounts(int encoder)
Shaft encoders on the Handy Board are sampled once per millisecond. Therefore, the maximum rate which is supported is 500 counts per second.
encoder
- encoder to read (0 to 2)
public static int getEncoderRate(int encoder)
Shaft encoders on the Handy Board are sampled once per millisecond. Therefore, the maximum rate which is supported is 500 counts per second. The maximum value this function can return is 7.
encoder
- encoder to read (0 to 2)
public static IrReceiver getIrReceiver()
public static Display getLcdDisplay()
The Display object may be used to print to a specific line or character position. Alternatively, the getOutputStream method can be used to print scrolling text to the LCD.
public static Motor getMotor(int motor)
motor
- number of the motor (0 - 3)
public static OutputStream getOutputStream()
This method can be used in conjuntion with a PrintStream object to print scrolling output to the LCD.
The LCD can be addressed in line and character mode by using the getLcdDisplay method.
public static Servo getServo(int servo)
The Sumo11 expansion board supports up to 8 servos, though connectors are only provided for four. The left and right servo connectors on the main board are not supported by objects returned by this method. The left servo on the main board shares the TOC3 signal used by the expansion board servos. Therefore, the left main board servo port should not be used. The right servo port is connected to TOC2. This servo port could be used but is not supported by the objects returned by this method.
The objects returned by this method are intended to support Futuba compatible servos which are controlled by a 1 to 2 millisecond positioning pulse every 16 - 20 milliseconds. The pulse period is 18 ms.
servo
- number of the servo (0 - 7)
public static ShaftEncoder getShaftEncoder(int encoder)
Each shaft encoder uses a pair of digital inputs to implement a quadrature shaft encoder. The two pins should be connected to two digital sensors that generate a quadrature signal. The two sensors should be 90 degrees out of phase. If the counter counts in the opposite direction of what is expected, swap the two inputs.
Shaft encoders on the Handy Board are sampled once per millisecond. Therefore, the maximum counting rate which is supported is 500 counts per second.
On the Handy Board, the encoder rate value is updated every 128 milliseconds. The maximum value the getRate method can return is 7.
encoder
- number of the encoder
public static PushButton getStartButton()
public static PushButton getStopButton()
public static AnalogInput getThumbWheel()
public static int irRead()
public static void irRxInitialize(int startMin, int startMax, int shortMin, int threshold, int longMax, int numberOfBits, boolean invertBits, boolean reverseBits)
The infrared receiver supports infrared protocols which transmit data by transmitting a long start pulse followed by short and long data bit pulses.
startMin
- minimum start bit length in microsecondsstartMax
- maximum start bit length in microsecondsshortMin
- minimum short bit length in microsecondsthreshold
- threshold distinguishing short bit from long bit in
microsecondslongMax
- maximum long bit lengthnumberOfBits
- number of bits frameinvertBits
- true if short bits are 1s, false if long bits are 1sreverseBits
- true if frames arrive least significant bit firstpublic static boolean isDigitalInputSet(int portNumber)
portNumber
- number of the port (7 - 15)
public static boolean isDigitalOutputSet(int portNumber)
portNumber
- digital output bit to toggle
public static void play(int frequency, int duration)
The audible range for a human ear is about 20 Hz and 20 kHz. The range supported by the hardware on the Handy Board is approximately 20 Hz to about 2 kHz.
The frequencies of musical notes starting at middle C on a piano are:
The frequencies of notes double for each higher octave and are halved for each lower octave.
This method doesn't return until tone has been played.
frequency
- frequency in Hz of the tone to playduration
- duration to play the tone for in millisecondspublic static void pulseDigitalOutput(int portNumber, int duration)
portNumber
- digital output bit to toggle
duration
- duration of the pulse in microseconds. This value should not
be greater than 65,535.public static int readEdgeCount(int port)
port
- digital input port to read
public static int readPulseDuration(int port)
port
- digital input port to read
public static int readPulseDuration(int port, boolean highPulse)
The method enablePulseMeasurement must be called prior to calling this method.
port
- digital input port to readhighPulse
- true for duration of high pulse, false for duration of low
pulse
public static int readThumbWheel()
public static void setBoardType(byte type)
Motor, servo control, and digital out 8 are controlled differently between the Handy Board and Sumo11.
Note: This method must be called on Sumo11 boards prior to using any of these features.
type
- TYPE_HANDY_BOARD or TYPE_SUMO11, defaults to TYPE_HANDY_BOARD
on startup.public static void setDigital9Direction(boolean isOutput)
Port 9 may be used as an input or an output. By default it is configured as an input.
isOutput
- true if digital 9 is to be configured for output, otherwise
falsepublic static void setDigitalOutput(int portNumber)
portNumber
- digital output bit to toggle
public static void setMotorPower(int motor, int power)
power
- The power level to set.
public static void setServoPosition(int servo, int position)
The Handy Board expansion board supports up to 8 servos, though the full electronics are only present for the first 6 servos. A single servo signal can be supported by a Handy Board without an expansion board by attaching the servo signal to TOC3 (Pin 7 on J3), powering the servo with a 6 volt power source and using this method specifying servo 0.
The Sumo11 expansion board supports up to 8 servos, though connectors are only provided for four. The left and right servo connectors on the main board are not supported by this method. The left servo on the main board shares the TOC3 signal used by the expansion board servos. Therefore, the left main board servo port should not be used. The right servo port is connected to TOC2. This servo port could be used but is not supported via this method.
On the Handy Board, TOC2 is used to control the IR transmitter.
This method is intended to support Futuba compatible servos which are controlled by a 1 to 2 millisecond positioning pulse every 16 - 20 milliseconds. The pulse period is 18 ms.
servo
- number of the servo (0 - 7)position
- position of the servo in percent. (0 = 1 ms positioning pulse,
100 = 2 ms positioning pulse, -1 = no pulse, servo off)public static void setTerminateOnStop(boolean terminateOnStop)
The initial setting when the program starts is true.
terminateOnStop
- true if the program should terminate when the STOP button is
pressed.public static boolean startPressed()
public static boolean stopPressed()
public static void toggleDigitalOutput(int portNumber)
portNumber
- digital output bit to toggle
|
RoboJDETM v2.0 | |||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |