|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.Button
public class Button
Abstraction for an NXT button. Example:
Button.ENTER.waitForPressAndRelease();
Sound.playTone (1000, 1);
Field Summary | |
---|---|
static Button[] |
BUTTONS
Array containing ENTER, LEFT, RIGHT, ESCAPE, in that order. |
static Button |
ENTER
The Enter button. |
static Button |
ESCAPE
The Escape button. |
static int |
ID_ENTER
|
static int |
ID_ESCAPE
|
static int |
ID_LEFT
|
static int |
ID_RIGHT
|
static Button |
LEFT
The Left button. |
static Button |
RIGHT
The Right button. |
static String |
VOL_SETTING
|
Method Summary | |
---|---|
void |
addButtonListener(ButtonListener aListener)
Adds a listener of button events. |
void |
callListeners()
Call Button Listeners. |
int |
getId()
Return the ID of the button. |
static int |
getKeyClickLength()
Return the current key click length. |
static int |
getKeyClickTone(int key)
Return the click freq for a particular key. |
static int |
getKeyClickVolume()
Return the current key click volume. |
boolean |
isPressed()
Check if the button is pressed. |
static void |
loadSettings()
Load the current system settings associated with this class. |
static int |
readButtons()
Low-level API that reads status of buttons. |
static void |
setKeyClickLength(int len)
Set the len used for key clicks |
static void |
setKeyClickTone(int key,
int freq)
Set the frequency used for a particular key. |
static void |
setKeyClickVolume(int vol)
Set the volume used for key clicks |
static int |
waitForPress()
wait for some button to be pressed (and released). |
static int |
waitForPress(int timeout)
wait for some button to be pressed (and released). |
void |
waitForPressAndRelease()
Wait until the button is released. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int ID_ENTER
public static final int ID_LEFT
public static final int ID_RIGHT
public static final int ID_ESCAPE
public static final String VOL_SETTING
public static final Button ENTER
public static final Button LEFT
public static final Button RIGHT
public static final Button ESCAPE
public static final Button[] BUTTONS
Method Detail |
---|
public final int getId()
public final boolean isPressed()
true
if button is pressed, false
otherwise.public final void waitForPressAndRelease()
public static int waitForPress(int timeout)
timeout
- The number of milliseconds to wait.
public static int waitForPress()
public void addButtonListener(ButtonListener aListener)
public static int readButtons()
public void callListeners()
callListeners
in interface ListenerCaller
public static void setKeyClickVolume(int vol)
vol
- public static int getKeyClickVolume()
public static void setKeyClickLength(int len)
len
- the click durationpublic static int getKeyClickLength()
public static void setKeyClickTone(int key, int freq)
key
- the NXT keyfreq
- the frequencypublic static int getKeyClickTone(int key)
public static void loadSettings()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |