Enum Class ColorPeriod

java.lang.Object
java.lang.Enum<ColorPeriod>
com.reduxrobotics.sensors.canandcolor.ColorPeriod
All Implemented Interfaces:
Serializable, Comparable<ColorPeriod>, Constable

public enum ColorPeriod extends Enum<ColorPeriod>
Enum representing the internal configuration of the Canandcolor's color IC. Passed to CanandcolorSettings.setColorIntegrationPeriod(ColorPeriod) which may be then used with Canandcolor.setSettings(CanandcolorSettings) to configure the device.

The color sensor IC supports a single parameter that serves as both the integration and sampling period, which can be adjusted from 25 millisecondss to 400 milliseconds. This period functions as a kind of "exposure time" -- longer periods mean colors at lower light can be read more accurately, but also mean they saturate faster in higher light conditions and update less frequently, regardless of the device frame period.

The rate at which the color sensor produces new values once every integration period, so k400ms will produce a new color reading every 400 milliseconds, and k25ms will produce a new reading every 25 milliseconds.

The factory default is k25ms.
  • Enum Constant Details

    • k400ms

      public static final ColorPeriod k400ms
      Sample the color sensor every 400 ms.
    • k200ms

      public static final ColorPeriod k200ms
      Sample the color sensor every 200 ms.
    • k100ms

      public static final ColorPeriod k100ms
      Sample the color sensor every 100 ms.
    • k50ms

      public static final ColorPeriod k50ms
      Sample the color sensor every 50 ms.
    • k25ms

      public static final ColorPeriod k25ms
      Sample the color sensor every 25 ms.
  • Method Details

    • values

      public static ColorPeriod[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ColorPeriod valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • fromIndex

      public static ColorPeriod fromIndex(int idx)
      Returns a corresponding color config from the index.
      Parameters:
      idx - the index to fetch.
      Returns:
      a valid color config. If the index value is invalid it will return the default.
    • getIndex

      public int getIndex()
      Gets the corresponding index for the value in question.
      Returns:
      the index value for the enum (used internally)