예제 #1
0
        /// <summary>
        /// <para>Sets the minimum and the maximum of the color range.</para>
        /// </summary>
        /// <param name="minRange">Minimum</param>
        /// <param name="maxRange">Maximum</param>
        /// <seealso cref="OnInsideRange"/>
        /// <seealso cref="OnOutsideRange"/>
        public void SetColorRange(Nxt2Color minRange, Nxt2Color maxRange)
        {
            this.minRange = minRange;
            this.maxRange = maxRange;

            if (minRange >= maxRange)
            {
                throw new ArgumentException("The minimum-value must be less than the maximum-value.");
            }
        }
        /// <summary>
        /// <para>Switches the sensor into light sensor mode.</para>
        /// </summary>
        /// <param name="color">The floodlight color. The sensor will accept red, green and blue, or black and null for no floodlights.</param>
        public void SetLightSensorMode(Nxt2Color? color)
        {
            if (color != null && color != Nxt2Color.Red && color != Nxt2Color.Green && color != Nxt2Color.Blue && color != Nxt2Color.Black)
                throw new ArgumentException("The color must be red, green, blue, black or null.");

            switch (color)
            {
                case Nxt2Color.Red:
                    this.sensorType = NxtSensorType.COLORRED;
                    break;
                case Nxt2Color.Green:
                    this.sensorType = NxtSensorType.COLORGREEN;
                    break;
                case Nxt2Color.Blue:
                    this.sensorType = NxtSensorType.COLORBLUE;
                    break;
                case Nxt2Color.Black:
                case null:
                    this.sensorType = NxtSensorType.COLORNONE;
                    break;
            }

            this.sensorMode = Nxt2ColorSensorMode.LightSensor;
            InitSensor();
        }
        /// <summary>
        /// <para>Sets the minimum and the maximum of the color range.</para>
        /// </summary>
        /// <param name="minRange">Minimum</param>
        /// <param name="maxRange">Maximum</param>
        /// <seealso cref="OnInsideRange"/>
        /// <seealso cref="OnOutsideRange"/>
        public void SetColorRange(Nxt2Color minRange, Nxt2Color maxRange)
        {
            this.minRange = minRange;
            this.maxRange = maxRange;

            if (minRange >= maxRange)
            {
                throw new ArgumentException("The minimum-value must be less than the maximum-value.");
            }
        }