public class AnalogSensor extends BaseSensor implements SensorConstants
Modifier and Type | Field and Description |
---|---|
protected int |
currentType |
protected AnalogPort |
port |
currentMode, modes
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, BROWN, GREEN, GREEN_INDEX, MAX_TYPE, MIN_TYPE, MODE_RAW, NXT_ADC_RES, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HIGHSPEED, TYPE_HIGHSPEED_9V, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW
Constructor and Description |
---|
AnalogSensor(AnalogPort p) |
AnalogSensor(Port p) |
AnalogSensor(Port p,
int type,
int mode) |
Modifier and Type | Method and Description |
---|---|
protected float |
normalize(float val)
Helper method.
|
protected int |
NXTRawIntValue(float val)
Return the equivalent NXT RAW sensor reading to the given voltage
|
protected float |
NXTRawValue(float val)
Return the equivalent NXT RAW sensor reading to the given voltage
|
protected void |
switchType(int newType,
long switchDelay)
Switch to the selected type (if not already in that type) and delay for the
specified period to allow the sensor to settle in the new state.
|
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
protected AnalogPort port
protected int currentType
public AnalogSensor(AnalogPort p)
public AnalogSensor(Port p, int type, int mode)
public AnalogSensor(Port p)
protected float normalize(float val)
val
- input valueprotected float NXTRawValue(float val)
val
- ADC voltageprotected int NXTRawIntValue(float val)
val
- ADC voltageprotected void switchType(int newType, long switchDelay)
newType
- The type to switch to.switchDelay
- Time in mS to delay after the switch.