Class FtcMRI2cColorSensor

All Implemented Interfaces:
TrcSensor.DataSource<FtcMRI2cColorSensor.DataType>

public class FtcMRI2cColorSensor extends FtcMRI2cDevice implements TrcSensor.DataSource<FtcMRI2cColorSensor.DataType>
This class implements the Modern Robotics Color Sensor extending FtcMRI2cDevice that implements the common features of all Modern Robotics I2C devices.
  • Field Details

  • Constructor Details

    • FtcMRI2cColorSensor

      public FtcMRI2cColorSensor(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String instanceName, int i2cAddress, boolean addressIs7Bit)
      Constructor: Creates an instance of the object.
      Parameters:
      hardwareMap - specifies the global hardware map.
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
      addressIs7Bit - specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
    • FtcMRI2cColorSensor

      public FtcMRI2cColorSensor(String instanceName, int i2cAddress, boolean addressIs7Bit)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
      i2cAddress - specifies the I2C address of the device.
      addressIs7Bit - specifies true if the I2C address is a 7-bit address, false if it is 8-bit.
    • FtcMRI2cColorSensor

      public FtcMRI2cColorSensor(String instanceName)
      Constructor: Creates an instance of the object.
      Parameters:
      instanceName - specifies the instance name.
  • Method Details

    • setLEDEnabled

      public void setLEDEnabled(boolean enabled)
      This method turns on the internal LED to illuminate the target surface or turns off the internal LED and reads from external light sources.
      Parameters:
      enabled - specifies true to turn on internal LED, false otherwise.
    • set50HzMode

      public void set50HzMode()
      This method sets the operating frequency to 50Hz. This setting is saved in EEPROM. This function is provided to enable the sampling to coincide with the normal flickering associated with mains electrical A/C artificial lighting, and helps minimize signal noise issues. Call this method when used in countries with 50Hz A/C electric current frequency. When Frequency Mode set is complete, the LED will blink off briefly and then the previous measurement mode will resume.
    • set60HzMode

      public void set60HzMode()
      This method sets the operating frequency to 60Hz. This setting is saved in EEPROM. This function is provided to enable the sampling to coincide with the normal flickering associated with mains electrical A/C artificial lighting, and helps minimize signal noise issues. Call this method when used in countries with 60Hz A/C electric current frequency. When Frequency Mode set is complete, the LED will blink off briefly and then the previous measurement mode will resume.
    • calibrateBlackLevel

      public void calibrateBlackLevel()
      This method calibrates the black level. It runs 64 measurement cycles to obtain an average value for each of the 3 color channels. The three values obtained are stored in EEPROM and will subsequently be subtracted from all future measurements. When the black level calibration is complete, the LED will blink off briefly and then the previous measurement mode will resume with the command byte being set to 00H or 01H. During the black level calibration, the sensor should be placed such that no surface is within 5 feet (1.5m) of the sensor element.
    • calibrateWhiteBalance

      public void calibrateWhiteBalance()
      This method calibrates the white balance. It runs 64 measurement cycles to obtain an average value for each of the 3 color channels. The values obtained are adjusted according to the stored black level calibration values and stored in EEPROM. When the white balance calibration is complete, the LED will blink off briefly and then previous measurement mode will resume. During white balance calibration, the sensor must be placed approximately 2 inches (5cm) from a white target. This target must be as white as possible. At least 3 layers of high quality copy paper make a good white target.
    • getColorNumber

      public TrcSensor.SensorData<Double> getColorNumber()
      This method returns the color number.
      Returns:
      color number.
    • getRedValue

      public TrcSensor.SensorData<Double> getRedValue()
      This method returns the red value.
      Returns:
      red value.
    • getGreenValue

      public TrcSensor.SensorData<Double> getGreenValue()
      This method returns the green value.
      Returns:
      green value.
    • getBlueValue

      public TrcSensor.SensorData<Double> getBlueValue()
      This method returns the blue value.
      Returns:
      blue value.
    • getWhiteValue

      public TrcSensor.SensorData<Double> getWhiteValue()
      This method returns the white value.
      Returns:
      white value.
    • getRawData

      public TrcSensor.SensorData<Double> getRawData(int index, FtcMRI2cColorSensor.DataType dataType)
      This method returns the sensor data of the specified index.
      Specified by:
      getRawData in interface TrcSensor.DataSource<FtcMRI2cColorSensor.DataType>
      Parameters:
      index - specifies the data index.
      dataType - specifies the data type.
      Returns:
      sensor data of the specified index and type.