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; }
public static void LineDemo(APA102LEDStrip ledStrip) { int wait = ledStrip.MaxLed <= 10 ? 55 : 0; var quit = false; ledStrip.AllOff(); Console.Clear(); ConsoleEx.TitleBar(0, "Line Demo"); ConsoleEx.WriteMenu(-1, 2, "Q)uit"); ConsoleEx.WriteMenu(-1, 3, ""); while (!quit) { var j = 0; for (var i = 0; i < ledStrip.MaxLed; i++) { // Remark: there should be a faster way to draw the line, by first setting all the led // to black and only resetting the one in color. Once we light up all the led, we would // turn them all off and re start... Todo, totry. var bkColor = RGBHelper.Wheel(((i * 256 / ledStrip.MaxLed) + j)); ledStrip.AddRGBSequence(true, 2, i + 1, bkColor); if (++j >= 256) { j = 0; } while (!ledStrip.IsFull) { ledStrip.AddRGBSequence(false, 2, Color.Black); } ledStrip.Show().Wait(wait); Console.WriteLine(String.Format("Color:{0}, Html:{1}, Dec:{2}", bkColor.Name.PadRight(16), APA102LEDStrip.ToHexValue(bkColor), APA102LEDStrip.ToDecValue(bkColor))); if (Console.KeyAvailable) { while (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) { quit = true; break; } } } } ledStrip.Wait(wait * 3).AllOff(); } ledStrip.AllOff(); }
public static void LineDemo(APA102LEDStrip ledStripe) { int wait = 20; var quit = false; ledStripe.AllOff(); Console.Clear(); ConsoleEx.WriteMenu(-1, 4, "Q)uit"); while (!quit) { var j = 0; for (var i = 0; i < ledStripe.MaxLed; i++) { var bkColor = RGBHelper.Wheel(((i * 256 / ledStripe.MaxLed) + j)); ledStripe.AddRGBSequence(true, 2, i + 1, bkColor); if (++j >= 256) { j = 0; } while (!ledStripe.IsFull) { ledStripe.AddRGBSequence(false, 2, Color.Black); } ledStripe.Show().Wait(wait); Console.WriteLine(String.Format("Color:{0}, Html:{1}, Dec:{2}", bkColor.Name.PadRight(16), APA102LEDStrip.ToHexValue(bkColor), APA102LEDStrip.ToDecValue(bkColor))); if (Console.KeyAvailable) { while (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) { quit = true; break; } } } } ledStripe.Wait(wait * 3).AllOff(); } ledStripe.AllOff(); }
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; }