Class NXTColorSensor

    • Field Detail

      • colorMap

        protected static int[] colorMap
    • Constructor Detail

      • NXTColorSensor

        public NXTColorSensor​(AnalogPort port)
        Create a new Color Sensor instance and bind it to a port.
        Parameters:
        port - Port to use for the sensor.
      • NXTColorSensor

        public NXTColorSensor​(Port port)
        Create a new Color Sensor instance and bind it to a port.
        Parameters:
        port - Port to use for the sensor.
    • Method Detail

      • init

        protected void init()
      • getColorIDMode

        public SensorMode getColorIDMode()
        get a sample provider in color ID mode
        Returns:
        the sample provider
      • getRedMode

        public SensorMode getRedMode()
        get a sample provider the returns the light value when illuminated with a Red light source.
        Returns:
        the sample provider
      • getGreenMode

        public SensorMode getGreenMode()
        get a sample provider the returns the light value when illuminated with a Green light source.
        Returns:
        the sample provider
      • getBlueMode

        public SensorMode getBlueMode()
        get a sample provider the returns the light value when illuminated with a Blue light source.
        Returns:
        the sample provider
      • getRGBMode

        public SensorMode getRGBMode()
        get a sample provider the returns the light values (RGB + ambient) when illuminated by a white light source.
        Returns:
        the sample provider
      • getAmbientMode

        public SensorMode getAmbientMode()
        get a sample provider the returns the light value when illuminated without a light source.
        Returns:
        the sample provider
      • readRaw

        protected void readRaw()
      • readFull

        protected void readFull()
      • setFloodlight

        public void setFloodlight​(boolean floodlight)
        Description copied from interface: LampController
        Turns the default LED light on or off. If the sensor has more than one lamp color, this will control the red LED.
        Specified by:
        setFloodlight in interface LampController
        Parameters:
        floodlight - true to turn on lamp, false for off (ambient light only).
      • getFloodlight

        public int getFloodlight()
        Description copied from interface: LampController
        Returns the color of the floodlight, including Color.NONE.
        Specified by:
        getFloodlight in interface LampController
        Returns:
        An enumeration of the current color.
      • isFloodlightOn

        public boolean isFloodlightOn()
        Description copied from interface: LampController
        Checks if the floodlight is currently on.
        Specified by:
        isFloodlightOn in interface LampController
        Returns:
        true if on, false if off.
      • setFloodlight

        public boolean setFloodlight​(int color)
        Description copied from interface: LampController
        Used to turn on or off the floodlight by color. If the sensor has multiple light colors, you can control which color is turned on or off. If the color does not exist, it does nothing and returns false. You can turn the floodlight off by using Color.NONE.
        Specified by:
        setFloodlight in interface LampController
        Parameters:
        color - Use Color enumeration constant to control lamp colors.
        Returns:
        True if lamp changed, false if lamp color doesn't exist for this sensor.
      • getColorID

        public int getColorID()
        Read the current color and return an enumeration constant. This is usually only accurate at a distance of about 1 cm.
        Specified by:
        getColorID in interface ColorIdentifier
        Returns:
        The color id under the sensor.