ch.aplu.nxt
Class Tools

java.lang.Object
  extended by ch.aplu.nxt.Tools

public class Tools
extends java.lang.Object

Class with some useful helper methods.


Constructor Summary
Tools()
           
 
Method Summary
static void delay(long duration)
          Suspends execution of the current thread for the given amount of time.
static java.lang.String getBtAddress()
          Gets the Bluetooth address of the device.
static java.lang.String getBtName()
          Gets the Bluetooth friendly name of the device.
static java.lang.String[] getKnownBtDevices()
          Returns a list of all registered Bluetooth devices.
static long getTime()
          Gets the timer's time.
static boolean isBtDeviceKnown(java.lang.String name)
           
static boolean putSleep()
          Same as putSleep(int timeout) with timeout = 0 (timeout disalbed).
static boolean putSleep(int timeout)
          Puts the current thread in a wait state until wakeUp() is called or timeout (in ms) expires.
static void startTimer()
          Starts a timer or restart it by setting its time to zero.
static void waitEnter()
          Waits until ENTER button is hit.
static void waitEnter(java.lang.String prompt)
          Displays the prompt and waits until ENTER button is hit.
static void waitEscape()
          Waits until ESCAPE button is hit.
static void waitEscape(java.lang.String prompt)
          Displays the prompt and waits until ESCAPE button is hit.
static void wakeUp()
          Wakes up the waiting thread.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Tools

public Tools()
Method Detail

startTimer

public static void startTimer()
Starts a timer or restart it by setting its time to zero.


getTime

public static long getTime()
Gets the timer's time.

Returns:
the current time of the timer (in ms)

delay

public static void delay(long duration)
Suspends execution of the current thread for the given amount of time. (Other threads may continue to run.)

Parameters:
duration - the duration (in ms)

putSleep

public static boolean putSleep(int timeout)
Puts the current thread in a wait state until wakeUp() is called or timeout (in ms) expires. If timeout <= 0 the method blocks infinitely until wakeUp() is called. Only one thread may be in the wait state.
Return values:
true: wakeUp was called before timeout expired ("no timeout occured")
false: timeout expired before wakeUp was called ("timeout occured")


putSleep

public static boolean putSleep()
Same as putSleep(int timeout) with timeout = 0 (timeout disalbed).


wakeUp

public static void wakeUp()
Wakes up the waiting thread.


waitEnter

public static void waitEnter()
Waits until ENTER button is hit.


waitEnter

public static void waitEnter(java.lang.String prompt)
Displays the prompt and waits until ENTER button is hit.


waitEscape

public static void waitEscape()
Waits until ESCAPE button is hit.


waitEscape

public static void waitEscape(java.lang.String prompt)
Displays the prompt and waits until ESCAPE button is hit.


getBtName

public static java.lang.String getBtName()
Gets the Bluetooth friendly name of the device.

Returns:
the Bluetooth friendly name

getBtAddress

public static java.lang.String getBtAddress()
Gets the Bluetooth address of the device.

Returns:
the Bluetooth address (as string)

getKnownBtDevices

public static java.lang.String[] getKnownBtDevices()
Returns a list of all registered Bluetooth devices. Register a new device with the Lejos command processor.

Returns:
a string array of all known devices

isBtDeviceKnown

public static boolean isBtDeviceKnown(java.lang.String name)