lejos.nxt.addon
Class CompassHTSensor

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.CompassHTSensor
All Implemented Interfaces:
SensorConstants, DirectionFinder

public class CompassHTSensor
extends I2CSensor
implements DirectionFinder

This class supports the HiTechnic compass sensor.


Field Summary
 
Fields inherited from class lejos.nxt.I2CSensor
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION
 
Fields inherited from interface lejos.nxt.SensorConstants
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, 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 Summary
CompassHTSensor(I2CPort port)
          Create a compass sensor object
CompassHTSensor(I2CPort port, int address)
          Create a compass sensor object
 
Method Summary
 float getDegrees()
          Returns the directional heading in degrees.
 float getDegreesCartesian()
          Cartesian coordinate systems increase from 0 to 360 counter-clockwise, but Compass readings increase clockwise .
 void resetCartesianZero()
          Changes the current direction the compass is facing into the zero angle for the method getDegreesCartesian().
 void startCalibration()
          Starts calibration for the compass.
 void stopCalibration()
          Ends calibration sequence.
 
Methods inherited from class lejos.nxt.I2CSensor
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompassHTSensor

public CompassHTSensor(I2CPort port,
                       int address)
Create a compass sensor object

Parameters:
port - Sensor port for the compass
address - The I2C address used by the sensor

CompassHTSensor

public CompassHTSensor(I2CPort port)
Create a compass sensor object

Parameters:
port - Sensor port for the compass
Method Detail

getDegrees

public float getDegrees()
Returns the directional heading in degrees. (0 to 359.9) 0 is due North. Readings increase clockwise.

Returns:
Heading in degrees. Resolution is within 0.1 degrees

getDegreesCartesian

public float getDegreesCartesian()
Cartesian coordinate systems increase from 0 to 360 counter-clockwise, but Compass readings increase clockwise . This method returns the Cartesian compass reading. Also, the resetCartesianZero() method can be used to designate any direction as zero, rather than relying on North as being zero.

Specified by:
getDegreesCartesian in interface DirectionFinder
Returns:
Cartesian direction.

resetCartesianZero

public void resetCartesianZero()
Changes the current direction the compass is facing into the zero angle for the method getDegreesCartesian().

Specified by:
resetCartesianZero in interface DirectionFinder

startCalibration

public void startCalibration()
Starts calibration for the compass. Must rotate *very* slowly, taking at least 20 seconds per rotation. Should make 1.5 to 2 full rotations. Must call stopCalibration() when done.

Specified by:
startCalibration in interface DirectionFinder

stopCalibration

public void stopCalibration()
Ends calibration sequence.

Specified by:
stopCalibration in interface DirectionFinder