@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.CompassMode
HardwareDevice.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, resetDeviceConfigurationForOpMode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, getConnectionInfo, getVersion, resetDeviceConfigurationForOpMode
public static final I2cAddr ADDRESS_I2C_DEFAULT
public ModernRoboticsI2cCompassSensor(I2cDeviceSynch deviceClient)
protected void setOptimalReadWindow()
protected boolean doInitialize()
I2cDeviceSynchDevice
doInitialize
in class I2cDeviceSynchDevice<I2cDeviceSynch>
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public 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()
CompassSensor
getDirection
in interface CompassSensor
public java.lang.String status()
CompassSensor
status
in interface CompassSensor
public boolean isCalibrating()
public boolean calibrationFailed()
CompassSensor
calibrationFailed
in interface CompassSensor
public void setMode(CompassSensor.CompassMode mode)
CompassSensor
setMode
in interface CompassSensor
public void setI2cAddress(I2cAddr newAddress)
I2cAddrConfig
setI2cAddress
in interface I2cAddrConfig
newAddress
- the new I2C address to usepublic I2cAddr getI2cAddress()
I2cAddressableDevice
getI2cAddress
in interface I2cAddressableDevice