lejos.nxt
Class Poll

java.lang.Object
  extended by lejos.nxt.Poll

public class Poll
extends Object

Provides blocking access to events from the NXT. Poll is a bit of a misnomer (since you don't 'poll' at all) but it takes its name from the Unix call of the same name.


Field Summary
static short ALL_BUTTONS
           
static short ALL_SENSORS
           
static short BUTTON_MASK_SHIFT
           
static short ENTER_MASK
           
static short ESCAPE_MASK
           
static short LEFT_MASK
           
static short RIGHT_MASK
           
static short SENSOR1_MASK
           
static short SENSOR2_MASK
           
static short SENSOR3_MASK
           
static short SENSOR4_MASK
           
static short SERIAL_MASK
           
static short SERIAL_SHIFT
           
 
Constructor Summary
Poll()
          Constructor.
 
Method Summary
 int poll(int mask, int millis)
          Wait for the sensor/button values to change then return.
 void setThrottle(int throttle)
          Set a throttle on the regularity with which inputs are polled.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SENSOR1_MASK

public static final short SENSOR1_MASK
See Also:
Constant Field Values

SENSOR2_MASK

public static final short SENSOR2_MASK
See Also:
Constant Field Values

SENSOR3_MASK

public static final short SENSOR3_MASK
See Also:
Constant Field Values

SENSOR4_MASK

public static final short SENSOR4_MASK
See Also:
Constant Field Values

ALL_SENSORS

public static final short ALL_SENSORS
See Also:
Constant Field Values

ENTER_MASK

public static final short ENTER_MASK
See Also:
Constant Field Values

LEFT_MASK

public static final short LEFT_MASK
See Also:
Constant Field Values

RIGHT_MASK

public static final short RIGHT_MASK
See Also:
Constant Field Values

ESCAPE_MASK

public static final short ESCAPE_MASK
See Also:
Constant Field Values

ALL_BUTTONS

public static final short ALL_BUTTONS
See Also:
Constant Field Values

BUTTON_MASK_SHIFT

public static final short BUTTON_MASK_SHIFT
See Also:
Constant Field Values

SERIAL_MASK

public static final short SERIAL_MASK
See Also:
Constant Field Values

SERIAL_SHIFT

public static final short SERIAL_SHIFT
See Also:
Constant Field Values
Constructor Detail

Poll

public Poll()
Constructor.

Method Detail

poll

public final int poll(int mask,
                      int millis)
               throws InterruptedException
Wait for the sensor/button values to change then return.

Parameters:
mask - bit mask of values to monitor.
millis - wait for at most millis milliseconds. 0 = forever.
Returns:
a bit mask of the values that have changed
Throws:
InterruptedException

setThrottle

public final void setThrottle(int throttle)
Set a throttle on the regularity with which inputs are polled.

Parameters:
throttle - number of sensor reads between polls. Default value is 1. 0 means poll as often as possible. Sensor reads occur every 3ms.