@I2cDeviceType @DeviceProperties(name="@string/mr_compass_name", description="@string/mr_compass_description", xmlTag="ModernRoboticsI2cCompassSensor", builtIn=true) public class ModernRoboticsI2cCompassSensor extends I2cDeviceSynchDevice<I2cDeviceSynch> implements CompassSensor, I2cAddrConfig
ModernRoboticsI2cCompassSensor implements support for the Modern Robotics compass sensor.
"During normal operation the LED will blink briefly at 1Hz. During Hard Iron Calibration the LED
will blink at 1/2Hz. During tilt up and tilt down calibration the LED will be on during a period
of calibration measurement."| Modifier and Type | Class and Description |
|---|---|
static class |
ModernRoboticsI2cCompassSensor.Command |
static class |
ModernRoboticsI2cCompassSensor.Register |
CompassSensor.CompassModeHardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
static I2cAddr |
ADDRESS_I2C_DEFAULT |
deviceClient, deviceClientIsOwned, isInitialized| Constructor and Description |
|---|
ModernRoboticsI2cCompassSensor(I2cDeviceSynch deviceClient) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
calibrationFailed()
Check to see whether calibration was successful.
|
protected boolean |
doInitialize()
Actually carries out the initialization of the instance.
|
Acceleration |
getAcceleration() |
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
double |
getDirection()
Get the current direction, in degrees, in the range [0, 360).
|
I2cAddr |
getI2cAddress()
Returns the I2C address currently in use to communicate with an I2C hardware device
|
MagneticFlux |
getMagneticFlux() |
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
boolean |
isCalibrating() |
byte |
read8(ModernRoboticsI2cCompassSensor.Register reg) |
ModernRoboticsI2cCompassSensor.Command |
readCommand() |
int |
readShort(ModernRoboticsI2cCompassSensor.Register reg) |
void |
setI2cAddress(I2cAddr newAddress)
Configures a new I2C address to use
|
void |
setMode(CompassSensor.CompassMode mode)
Change to calibration or measurement mode
|
protected void |
setOptimalReadWindow() |
java.lang.String |
status()
Status of this sensor, in string form
|
void |
write8(ModernRoboticsI2cCompassSensor.Register reg,
byte value) |
void |
writeCommand(ModernRoboticsI2cCompassSensor.Command command) |
void |
writeShort(ModernRoboticsI2cCompassSensor.Register reg,
short value) |
close, disengage, engage, getConnectionInfo, getDeviceClient, getVersion, initialize, initializeIfNecessary, onModuleStateChange, registerArmingStateCallback, resetDeviceConfigurationForOpModeclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclose, getConnectionInfo, getVersion, resetDeviceConfigurationForOpModepublic static final I2cAddr ADDRESS_I2C_DEFAULT
public ModernRoboticsI2cCompassSensor(I2cDeviceSynch deviceClient)
protected void setOptimalReadWindow()
protected boolean doInitialize()
I2cDeviceSynchDevicedoInitialize in class I2cDeviceSynchDevice<I2cDeviceSynch>public HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic byte read8(ModernRoboticsI2cCompassSensor.Register reg)
public void write8(ModernRoboticsI2cCompassSensor.Register reg, byte value)
public int readShort(ModernRoboticsI2cCompassSensor.Register reg)
public void writeShort(ModernRoboticsI2cCompassSensor.Register reg, short value)
public void writeCommand(ModernRoboticsI2cCompassSensor.Command command)
public ModernRoboticsI2cCompassSensor.Command readCommand()
public Acceleration getAcceleration()
public MagneticFlux getMagneticFlux()
public double getDirection()
CompassSensorgetDirection in interface CompassSensorpublic java.lang.String status()
CompassSensorstatus in interface CompassSensorpublic boolean isCalibrating()
public boolean calibrationFailed()
CompassSensorcalibrationFailed in interface CompassSensorpublic void setMode(CompassSensor.CompassMode mode)
CompassSensorsetMode in interface CompassSensorpublic void setI2cAddress(I2cAddr newAddress)
I2cAddrConfigsetI2cAddress in interface I2cAddrConfignewAddress - the new I2C address to usepublic I2cAddr getI2cAddress()
I2cAddressableDevicegetI2cAddress in interface I2cAddressableDevice