lejos.nxt.addon
Class CruizcoreGyro

java.lang.Object
  extended by lejos.nxt.I2CSensor
      extended by lejos.nxt.addon.CruizcoreGyro
All Implemented Interfaces:
SensorConstants, Accelerometer, Gyroscope

public class CruizcoreGyro
extends I2CSensor
implements Gyroscope, Accelerometer

This Class manages the Micro Infinity Cruizcore XG1300L

Version:
1.0
Author:
Daniele Benedettelli, February 2011

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
CruizcoreGyro(I2CPort port)
          Instantiates a new Cruizcore Gyro sensor.
 
Method Summary
 int[] getAccel()
          Gets the accel.
 int getAccel(int axis)
          Gets the acceleration in the specified axis.
 int getAngle()
          Gets the accumulated angle (heading).
 float getAngularVelocity()
          Implementor must calculate and return the angular velocity in degrees per second.
 int[] getLastAccel()
          Gets the last acceleration read from the 3 axes.
 int getLastAccel(int axis)
          Gets the last accel.
 int getLastAngle()
          Gets the last angle.
 float getLastPitch()
          Gets the last pitch.
 int getLastRate()
          Gets the last rate.
 float getLastRoll()
          Gets the last roll.
 int getRate()
          Gets the rate.
 int getXAccel()
          Measures the x-axis of the accelerometer, in meters/second^2.
 int getYAccel()
          Measures the y-axis of the accelerometer, in meters/second^2.
 int getZAccel()
          Measures the z-axis of the accelerometer, in meters/second^2.
 boolean readAllData()
          Read all data from the sensor and save values in the private properties of the class.
 void recalibrateOffset()
          Implementor must calculate and set the offset/bias value for use in getAngularVelocity().
 boolean reset()
          Resets the accumulated angle (heading).
 boolean setAccScale(byte sf)
          Sets the acc scale.
 boolean setAccScale2G()
          Sets the acceleration scale factor to 2G.
 boolean setAccScale4G()
          Sets the acceleration scale factor to 4G.
 boolean setAccScale8G()
          Sets the acceleration scale factor to 8G.
 
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

CruizcoreGyro

public CruizcoreGyro(I2CPort port)
Instantiates a new Cruizcore Gyro sensor.

Parameters:
port - the port the sensor is attached to
Method Detail

readAllData

public boolean readAllData()
Read all data from the sensor and save values in the private properties of the class. Use getLastAccel() and similar methods to retrieve values.

Returns:
true, if successful

getLastAccel

public int[] getLastAccel()
Gets the last acceleration read from the 3 axes. See readAllData()

Returns:
the last acceleration

getLastAccel

public int getLastAccel(int axis)
Gets the last accel. See readAllData()

Parameters:
axis - the axis (0 for X, 1 for Y, 2 for Z)
Returns:
the last acceleration

getLastPitch

public float getLastPitch()
Gets the last pitch. See readAllData()

Returns:
the last pitch

getLastRoll

public float getLastRoll()
Gets the last roll. See readAllData()

Returns:
the last roll

getLastRate

public int getLastRate()
Gets the last rate. See readAllData()

Returns:
the last rotation rate

getLastAngle

public int getLastAngle()
Gets the last angle. See readAllData()

Returns:
the last angle

getAccel

public int[] getAccel()
Gets the accel. See readAllData()

Returns:
the acceleration

getAccel

public int getAccel(int axis)
Gets the acceleration in the specified axis.

Parameters:
axis - the axis (0 for X, 1 for Y, 2 for Z)
Returns:
the acceleration

getAngle

public int getAngle()
Gets the accumulated angle (heading).

Returns:
the angle

getRate

public int getRate()
Gets the rate.

Returns:
the rotation rate

setAccScale

public boolean setAccScale(byte sf)
Sets the acc scale.

Parameters:
sf - the scale factor 0 for +/- 2G 1 for +/- 4G 2 for +/- 8g
Returns:
true, if successful

setAccScale2G

public boolean setAccScale2G()
Sets the acceleration scale factor to 2G.

Returns:
true, if successful

setAccScale4G

public boolean setAccScale4G()
Sets the acceleration scale factor to 4G.

Returns:
true, if successful

setAccScale8G

public boolean setAccScale8G()
Sets the acceleration scale factor to 8G.

Returns:
true, if successful

reset

public boolean reset()
Resets the accumulated angle (heading).

Returns:
true, if successful

getAngularVelocity

public float getAngularVelocity()
Description copied from interface: Gyroscope
Implementor must calculate and return the angular velocity in degrees per second.

Specified by:
getAngularVelocity in interface Gyroscope
Returns:
Angular velocity in degrees/second

recalibrateOffset

public void recalibrateOffset()
Description copied from interface: Gyroscope
Implementor must calculate and set the offset/bias value for use in getAngularVelocity().

Specified by:
recalibrateOffset in interface Gyroscope

getXAccel

public int getXAccel()
Description copied from interface: Accelerometer
Measures the x-axis of the accelerometer, in meters/second^2.

Specified by:
getXAccel in interface Accelerometer
Returns:
acceleration in m/s^2

getYAccel

public int getYAccel()
Description copied from interface: Accelerometer
Measures the y-axis of the accelerometer, in meters/second^2.

Specified by:
getYAccel in interface Accelerometer
Returns:
acceleration in m/s^2

getZAccel

public int getZAccel()
Description copied from interface: Accelerometer
Measures the z-axis of the accelerometer, in meters/second^2.

Specified by:
getZAccel in interface Accelerometer
Returns:
acceleration in m/s^2