Example #1
0
        /// <summary>
        /// Sets the brightness level of a color.
        /// </summary>
        /// <param name="color">The color to set.</param>
        /// <param name="level">Value between 0 and 1. Zero is off, 0.5 is half, one is full brightness.</param>
        public static void SetLevel(BrainPad.Color.Palette color, double level)
        {
            if (level < 0 | level > 1)
            {
                throw new Exception("level must be a value between 0 and 1.");
            }

            TurnOff(color);

            switch (color)
            {
            case BrainPad.Color.Palette.Red:
                _ryg[0].DutyCycle = level;
                _ryg[0].Start();
                break;

            case BrainPad.Color.Palette.Yellow:
                _ryg[1].DutyCycle = level;
                _ryg[1].Start();
                break;

            case BrainPad.Color.Palette.Green:
                _ryg[2].DutyCycle = level;
                _ryg[2].Start();
                break;

            default:
                throw new Exception("color must be Red, Yellow or Green");
            }
        }
Example #2
0
        /// <summary>
        /// Turn off a color.
        /// </summary>
        /// <param name="color">Red, Yellow or Green</param>
        public static void TurnOff(BrainPad.Color.Palette color)
        {
            switch (color)
            {
            case BrainPad.Color.Palette.Red:
                _ryg[0].Stop();
                break;

            case BrainPad.Color.Palette.Yellow:
                _ryg[1].Stop();
                break;

            case BrainPad.Color.Palette.Green:
                _ryg[2].Stop();
                break;

            default:
                throw new Exception("color must be Red, Yellow or Green");
            }
        }