public class LegoRobot
extends java.lang.Object
Constructor and Description |
---|
LegoRobot()
Creates an instance of LegoRobot and starts execution normally.
|
LegoRobot(boolean waitStart)
Creates an instance of LegoRobot and and delays execution until the user presses the
ENTER button.
|
LegoRobot(boolean waitStart,
boolean isMelodyEnabled)
Creates an instance of LegoRobot and and delays execution until the user presses the
ENTER button.
|
Modifier and Type | Method and Description |
---|---|
void |
addButtonListener(ButtonListener listener)
Registers a button listener to report events
when one of the brick buttons is hit.
|
void |
addPart(Part part)
Assembles the given part into the robot.
|
void |
clearDisplay()
Clears the display.
|
void |
drawString(java.lang.String text,
int x,
int y)
Draws the given text line starting at given position.
|
void |
drawStringAt(java.lang.String text,
int count)
Draws the given text line starting at given screen cell count.
|
void |
exit()
Calls cleanup() of all sensors, stops any running motor and terminates the running program.
|
int |
getBatteryLevel()
Returns the battery level.
|
int |
getHitButtonID()
Returns the button ID of the button previously hit.
|
java.lang.String |
getRobotProperties() |
static java.lang.String |
getVersion()
Returns library version information.
|
boolean |
isButtonHit()
Returns true, if any of the buttons was hit.
|
boolean |
isDownHit()
Returns true, if the DOWN button was the last button hit since
the last call of this method.
|
boolean |
isEnterHit()
Returns true, if the ENTER button was the last button hit since
the last call of this method.
|
boolean |
isEscapeHit()
Returns true, if the ESCAPE button was the last button hit since
the last call of this method.
|
boolean |
isLeftHit()
Returns true, if the LEFT button was the last button hit since
the last call of this method.
|
boolean |
isRightHit()
Returns true, if the RIGHT button was the last button hit since
the last call of this method.
|
boolean |
isUpHit()
Returns true, if the UP button was the last button hit since
the last call of this method.
|
void |
playTone(int frequency,
int duration)
Plays a tone of given frequency (in Hz) for the given duration (in ms).
|
void |
setLED(int pattern)
Turn on/off the brick's left/right LEDs (only affected in pair).
|
void |
setVolume(int volume)
Sets the sound volume.
|
public LegoRobot(boolean waitStart, boolean isMelodyEnabled)
waitStart
- if true, the execution is stopped until the ENTER button is hit.isMelodyEnabled
- if true, a connect and disconnect melody is playedpublic LegoRobot(boolean waitStart)
waitStart
- if true, the execution is stopped until the ENTER button is hit.public LegoRobot()
public void addPart(Part part)
part
- the part to assemblepublic int getBatteryLevel()
public static java.lang.String getVersion()
public void exit()
public void playTone(int frequency, int duration)
frequency
- the frequency in Hertz (must be int)duration
- the duration in milliseconds (must be int)public void setVolume(int volume)
volume
- the sound volume (0..100)public void setLED(int pattern)
pattern
- the pattern 0..9public java.lang.String getRobotProperties()
public void addButtonListener(ButtonListener listener)
listener
- the ButtonListener to registerpublic boolean isButtonHit()
public int getHitButtonID()
public boolean isUpHit()
public boolean isDownHit()
public boolean isLeftHit()
public boolean isRightHit()
public boolean isEnterHit()
public boolean isEscapeHit()
public void drawString(java.lang.String text, int x, int y)
text
- the text to showx
- the column number (0..17)y
- the line number (0..7)public void drawStringAt(java.lang.String text, int count)
text
- the text to showcount
- the cell count (cells are counted from zero line-per-linepublic void clearDisplay()