|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjosx.platform.rcx.ProximitySensor
public class ProximitySensor
A 'sensor' to detect object proximity. Sends a short message out of the infra-red port every so often and looks for the reflection using the light sensor (which happens to be very infra-red sensitive).
| Constructor Summary | |
|---|---|
ProximitySensor(Sensor sensor)
Constructor. |
|
ProximitySensor(Sensor sensor,
int threshhold)
Constructor. |
|
| Method Summary | |
|---|---|
void |
stateChanged(Sensor sensor,
int oldValue,
int newValue)
Called from a thread private to sensor that runs at MAX_PRIORITY If newValue > oldValue by more than the threshhold, notify anything wait()ing on the sensor. |
void |
waitTillNear(long millis)
Block the current thread until a near object is detected. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait |
| Constructor Detail |
|---|
public ProximitySensor(Sensor sensor)
sensor - the sensor to which the light detector is connected.
the constructor will initialize the sensor and set up the infrared
transmitter.
public ProximitySensor(Sensor sensor,
int threshhold)
sensor - the sensor to which the light detector is connected.
the constructor will initialize the sensor and set up the infrared
transmitter.threshhold - the bigger the number the closer we get.| Method Detail |
|---|
public void waitTillNear(long millis)
throws InterruptedException
millis - wait at most millis milliseconds. 0 means wait forever
InterruptedException - if some thread calls interrupt() on the
calling thread.
public void stateChanged(Sensor sensor,
int oldValue,
int newValue)
stateChanged in interface SensorListenersensor - The sensor that generated the event.oldValue - The old sensor value.newValue - The new sensor value.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||