Beispiel #1
0
        public static void BrigthnessDemo(APA102LEDStrip ledStrip)
        {
            int maxBrightness = APA102LEDStrip.MAX_BRIGHTNESS / 2;
            int wait          = GetWaitTimeUnit(ledStrip) / 2;
            int step          = 1;

            ledStrip.AllOff();
            Console.Clear();
            ConsoleEx.WriteMenu(-1, 3, "Q)uit");
            while (!Console.KeyAvailable)
            {
                for (var b = 1; b <= maxBrightness; b += step)
                {
                    ledStrip.Reset();
                    for (var l = 0; l < ledStrip.MaxLed; l++)
                    {
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Red, b);
                        }
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Green, b);
                        }
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Blue, b);
                        }
                    }
                    ConsoleEx.Write(0, 0, string.Format("Brightness {0:00}", b), ConsoleColor.DarkCyan);
                    ledStrip.Show().Wait(wait);
                }
                ledStrip.Wait(wait * 10);
                for (var b = maxBrightness; b >= 1; b -= step)
                {
                    ledStrip.Reset();
                    for (var l = 0; l < ledStrip.MaxLed; l++)
                    {
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Red, b);
                        }
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Green, b);
                        }
                        if (!ledStrip.IsFull)
                        {
                            ledStrip.AddRGB(Color.Blue, b);
                        }
                    }
                    ConsoleEx.Write(0, 0, string.Format("Brightness {0:00}", b), ConsoleColor.DarkCyan);
                    ledStrip.Show().Wait(wait);
                }
                //ledStrip.AllOff();
                ledStrip.Wait(wait * 10);
                if (Console.KeyAvailable)
                {
                    break;
                }
            }
            ledStrip.AllOff();
            var k = Console.ReadKey(true).Key;
        }