Ejemplo n.º 1
0
        public async Task  TestColorSensor()
        {
            EV3ColorSensor color = new EV3ColorSensor(_brick, SensorPort.Port2, ColorSensorMode.Blue);

            color.PropertyChanged += HandleColorPropertyChangedEvent;

            while (false)
            {
                try
                {
                    if (color.ColorMode == ColorSensorMode.Color)
                    {
                        Console.WriteLine($"{color.ReadColor()}");
                    }
                    else
                    {
                        Console.WriteLine(color.CalculateRawAverage());

                        /*
                         * var rgb = color.ReadRGBValues();
                         *
                         * Console.WriteLine($"Red: {rgb.Red}");
                         * Console.WriteLine($"Blue: {rgb.Green}");
                         * Console.WriteLine($"Green: {rgb.Blue}");
                         * Console.WriteLine($"Ambient: {rgb.Blue}");
                         *
                         * var rgb2 = color.ReadRGBColor();
                         *
                         * Console.WriteLine($"Red2: {rgb.Red}");
                         * Console.WriteLine($"Blue2: {rgb.Green}");
                         * Console.WriteLine($"Green2: {rgb.Blue}");
                         */
                    }
                }
                catch (System.Exception ex)
                {
                    Console.WriteLine($"{ex.Message}");
                }

                await Task.Delay(1000);
            }
        }