Example #1
0
        public static void BrigthnessDemo(APA102LEDStrip ledStrip0, APA102LEDStrip ledStrip1)
        {
            Console.Clear();
            ConsoleEx.TitleBar(0, "Brightness Demo", ConsoleColor.White, ConsoleColor.DarkBlue);
            ConsoleEx.WriteMenu(-1, 3, "Q)uit");

            ledStrip0.AllOff();
            ledStrip1.AllOff();
            var bkColors = TargetColors.Replace(Environment.NewLine, ",").Split(',').ToList();
            var wait     = 15;

            while (!Console.KeyAvailable)
            {
                foreach (var sBColor in bkColors)
                {
                    var bkColor = APA102LEDStrip.DrawingColors[sBColor];

                    for (var b = 1; b <= APA102LEDStrip.MAX_BRIGHTNESS; b += 2)
                    {
                        ConsoleEx.Write(1, 2, string.Format("Brightness {0:00}", b), ConsoleColor.DarkCyan);
                        ledStrip0.SetColor(b, bkColor).Show();
                        ledStrip1.SetColor(b, bkColor).Show().Wait(wait);
                    }

                    if (Console.KeyAvailable)
                    {
                        break;
                    }
                    ledStrip0.Wait(wait * 10); // Wait when the fade in is done

                    for (var b = APA102LEDStrip.MAX_BRIGHTNESS; b >= 0; b -= 2)
                    {
                        ConsoleEx.Write(1, 2, string.Format("Brightness {0:00}", b), ConsoleColor.DarkCyan);
                        ledStrip0.SetColor(b, bkColor).Show();
                        ledStrip1.SetColor(b, bkColor).Show().Wait(wait);
                    }

                    if (Console.KeyAvailable)
                    {
                        break;
                    }
                    ledStrip0.Wait(wait * 10); // Wait when the fade out is deon
                }
            }
            ledStrip0.AllOff();
            ledStrip1.AllOff();
            var k = Console.ReadKey(true).Key;
        }