josx.platform.rcx
Class Poll

java.lang.Object
  extended byjosx.platform.rcx.Poll

public class Poll
extends Object

Provides blocking access to events from the RCX. 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 PRGM_MASK
           
static short RUN_MASK
           
static short SENSOR1_MASK
           
static short SENSOR2_MASK
           
static short SENSOR3_MASK
           
static short SERIAL_MASK
           
static short SERIAL_SHIFT
           
static short VIEW_MASK
           
 
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
equals, getClass, hashCode, notify, notifyAll, toString, 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

ALL_SENSORS

public static final short ALL_SENSORS
See Also:
Constant Field Values

RUN_MASK

public static final short RUN_MASK
See Also:
Constant Field Values

VIEW_MASK

public static final short VIEW_MASK
See Also:
Constant Field Values

PRGM_MASK

public static final short PRGM_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.