rcx
Class Sensor

java.lang.Object
  extended by rcx.Sensor

public class Sensor
extends java.lang.Object

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.

Example:

Sensor.S1.setTypeAndMode(SensorConstants.SENSOR_TYPE_LIGHT, SensorConstants.SENSOR_MODE_PCT);

Version:
2.1 Copyright 2002 Dario Laverde, under terms of GNU LGPL
Author:
Dario Laverde
See Also:
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

S1

public static Sensor S1

S2

public static Sensor S2

S3

public static Sensor S3

SENSORS

public static Sensor[] SENSORS

emulval

public int emulval
value used for emulation of sensor

Constructor Detail

Sensor

public Sensor(int id,
              RCXPort port)
creates a sensor where id is 0, 1 or 2 for the specified RCX port

Method Detail

setPort

public static void setPort(RCXPort port)
creates the static instances S1, S2, S3


readValue

public final int readValue()

readRawValue

public final int readRawValue()

readBooleanValue

public final boolean readBooleanValue()

getId

public final int getId()

activate

public final void activate()
not used (for compatibility with leJOS class of the same name)


passivate

public final void passivate()
not used (for compatibility with leJOS class of the same name)


setTypeAndMode

public final void setTypeAndMode(int aType,
                                 int aMode)
Sets the sensor's mode and type
The default type is LIGHT and the default is PERCENT. (note: mode can be OR'd with slope (0..31) )

Parameters:
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 = ANGLE
See Also:
SensorConstants

setPreviousValue

public final void setPreviousValue(int aValue)
reset canonical sensor value, useful for rotation sensors