public class DexterCompassSensor extends I2CSensor implements SensorModes
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Magnetic | Measures the strength of the magnetic field over three axes | getMagneticMode() |
Sensor configuration
Range can be set Using getRanges() and setRange methods. Internal update
frequency of the sensor can be set using getRates and setRate methods.
See
Sensor datasheet
See Sensor Product
page
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
Modifier and Type | Field and Description |
---|---|
protected static int |
REG_CONFIG |
protected static int |
REG_MAGNETO |
protected static int |
REG_STATUS |
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION, retryCount
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 |
---|
DexterCompassSensor(I2CPort port)
Constructor for the driver.
|
DexterCompassSensor(Port port) |
Modifier and Type | Method and Description |
---|---|
SampleProvider |
getMagneticMode()
Dexter Industries dCompass sensor, magnetic mode
Measures the strength of the magnetic field over three axes |
float |
getMaximumRange() |
protected int |
getMeasurementMode() |
protected int |
getOperatingMode() |
float[] |
getRanges() |
float |
getSampleRate() |
float[] |
getSampleRates() |
protected void |
init() |
protected boolean |
newDataAvailable()
Reads the new data ready bit of the status register of the sensor.
|
protected void |
setMeasurementMode(int measurementMode) |
protected void |
setOperatingMode(int operatingMode)
Sets the operating mode of the sensor
|
void |
setRange(float range) |
void |
setRange(int range)
Sets the dynamic range of the sensor (1.3 Gauss is default).
|
void |
setSampleRate(float rate) |
void |
start() |
void |
stop() |
boolean[] |
test()
Self-test routine of the sensor.
|
fetchString, getAddress, getData, getData, getPort, getProductID, getRetryCount, getVendorID, getVersion, sendData, sendData, sendData, setAddress, setRetryCount
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, setCurrentMode, setCurrentMode
getName
fetchSample, sampleSize
protected static final int REG_CONFIG
protected static final int REG_MAGNETO
protected static final int REG_STATUS
public DexterCompassSensor(I2CPort port)
port
- public DexterCompassSensor(Port port)
public SampleProvider getMagneticMode()
Size and content of the sample
The sample contains 3 elements. Each element gives the strength of the
magnetic field (in Gueass). Axis order is X, Y, Z.
Configuration
By default the sensor is configured for a range of 5.6 Gauss and an
update frequency of 30 Hertz.
The sensor can be tested using the test method.
leJOS conventions for
SampleProviders
See
Sensor datasheet protected void init()
protected int getMeasurementMode()
positive and negative bias mode should only be used for testing the sensor.
protected int getOperatingMode()
public float getMaximumRange()
protected boolean newDataAvailable()
protected void setMeasurementMode(int measurementMode)
measurementMode
- Sets the measurement mode of the sensor.protected void setOperatingMode(int operatingMode)
operatingMode
- Continuous is normal mode of operation
SingleMeasurement can be used to conserve energy or to increase maximum measurement rate
Idle is to stop the sensor and conserve energy
public void setRange(int range)
range
- public boolean[] test()
public void setSampleRate(float rate)
public float[] getSampleRates()
public void start()
public void stop()
public float getSampleRate()
public void setRange(float range)
public float[] getRanges()