|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectrcx.Sensor
public class Sensor
Sensor - encapsulates access to RCX Sensors
This class is based on leJOS's class of the same name
Before using a sensor, you should set its mode and type
with setTypeAndMode using constants defined in SensorConstants.
Sensor.S1.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT, SensorConstants.SENSOR_MODE_PCT);
SensorConstants
Field Summary | |
---|---|
int |
emulval
value used for emulation of sensor |
static Sensor |
S1
|
static Sensor |
S2
|
static Sensor |
S3
|
static Sensor[] |
SENSORS
|
Constructor Summary | |
---|---|
Sensor(int id,
RCXPort port)
creates a sensor where id is 0, 1 or 2 for the specified RCX port |
Method Summary | |
---|---|
void |
activate()
not used (for compatibility with leJOS class of the same name) |
int |
getId()
|
void |
passivate()
not used (for compatibility with leJOS class of the same name) |
boolean |
readBooleanValue()
|
int |
readRawValue()
|
int |
readValue()
|
static void |
setPort(RCXPort port)
creates the static instances S1, S2, S3 |
void |
setPreviousValue(int aValue)
reset canonical sensor value, useful for rotation sensors |
void |
setTypeAndMode(int aType,
int aMode)
Sets the sensor's mode and type The default type is LIGHT and the default is PERCENT. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static Sensor S1
public static Sensor S2
public static Sensor S3
public static Sensor[] SENSORS
public int emulval
Constructor Detail |
---|
public Sensor(int id, RCXPort port)
Method Detail |
---|
public static void setPort(RCXPort port)
public final int readValue()
public final int readRawValue()
public final boolean readBooleanValue()
public final int getId()
public final void activate()
public final void passivate()
public final void setTypeAndMode(int aType, int aMode)
aType
- 0 = RAW, 1 = TOUCH, 2 = TEMP, 3 = LIGHT, 4 = ROT.aMode
- 0x00 = RAW, 0x20 = BOOL, 0x40 = EDGE, 0x60 = PULSE,
0x80 = PERCENT, 0xA0 = DEGC, 0xC0 = DEGF, 0xE0 = ANGLESensorConstants
public final void setPreviousValue(int aValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |