public static void SimpleAnimation(BiColorLedStrip biColorLeds, List <int> initialStateIndex) { Console.Clear(); ConsoleEx.WriteMenu(-1, 2, "Q)uit"); biColorLeds.AllOff(); var biColorLedStateIndex = new List <int>() { 0, 0, 0, 0 }; biColorLeds[0].StateIndex = initialStateIndex[0]; biColorLeds[1].StateIndex = initialStateIndex[1]; biColorLeds[2].StateIndex = initialStateIndex[2]; biColorLeds[3].StateIndex = initialStateIndex[3]; while (true) { biColorLeds.Set(incState: true, firstStateIndex: 1); MadeInTheUSB.WinUtil.TimePeriod.Sleep(350 * 2); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) { break; } } } biColorLeds.AllOff(); }
public static void SimpleAnimation(BiColorLedStrip biColorLeds, List<int> initialStateIndex) { Console.Clear(); ConsoleEx.WriteMenu(-1, 2, "Q)uit"); biColorLeds.AllOff(); var biColorLedStateIndex = new List<int>() { 0, 0, 0, 0 }; biColorLeds[0].StateIndex = initialStateIndex[0]; biColorLeds[1].StateIndex = initialStateIndex[1]; biColorLeds[2].StateIndex = initialStateIndex[2]; biColorLeds[3].StateIndex = initialStateIndex[3]; while (true) { biColorLeds.Set(incState: true, firstStateIndex: 1); MadeInTheUSB.WinUtil.TimePeriod.Sleep(350*2); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) break; } } biColorLeds.AllOff(); }
public static void ScrollAnimation(BiColorLedStrip biColorLeds) { Console.Clear(); ConsoleEx.WriteMenu(-1, 2, "Q)uit"); int waitTime = 240; biColorLeds.AllOff(); var currentLed = 0; var patternIndex = 0; var patterns = new Dictionary<int, Pattern>() { { 0, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Green, ForegroundColor = BiColorLed.BiColorLedState.Red } }, { 1, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Green, ForegroundColor = BiColorLed.BiColorLedState.Yellow } }, { 2, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Red, ForegroundColor = BiColorLed.BiColorLedState.Green } }, { 3, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Red, ForegroundColor = BiColorLed.BiColorLedState.Yellow } }, { 4, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Yellow, ForegroundColor = BiColorLed.BiColorLedState.Red } }, { 5, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Yellow, ForegroundColor = BiColorLed.BiColorLedState.Green } }, }; while (true) { var p = patterns[patternIndex]; if (currentLed == 0) // When we start a scroll line sequence first let set all the 4 leds with the background color { for (var i = 0; i < biColorLeds.Count; i++) { biColorLeds[i].Set(p.BackgroundColor); } MadeInTheUSB.WinUtil.TimePeriod.Sleep(waitTime); } for (var i = 0; i < biColorLeds.Count; i++) { if (i == currentLed) { biColorLeds[currentLed].Set(p.ForegroundColor); } else { biColorLeds[i].Set(p.BackgroundColor); } } currentLed += 1; if (currentLed >= biColorLeds.Count) { currentLed = 0; patternIndex += 1; if(patternIndex >= patterns.Count) patternIndex = 0; } MadeInTheUSB.WinUtil.TimePeriod.Sleep(waitTime); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) break; } } biColorLeds.AllOff(); }
public static void ScrollAnimation(BiColorLedStrip biColorLeds) { Console.Clear(); ConsoleEx.WriteMenu(-1, 2, "Q)uit"); int waitTime = 240; biColorLeds.AllOff(); var currentLed = 0; var patternIndex = 0; var patterns = new Dictionary <int, Pattern>() { { 0, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Green, ForegroundColor = BiColorLed.BiColorLedState.Red } }, { 1, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Green, ForegroundColor = BiColorLed.BiColorLedState.Yellow } }, { 2, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Red, ForegroundColor = BiColorLed.BiColorLedState.Green } }, { 3, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Red, ForegroundColor = BiColorLed.BiColorLedState.Yellow } }, { 4, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Yellow, ForegroundColor = BiColorLed.BiColorLedState.Red } }, { 5, new Pattern() { BackgroundColor = BiColorLed.BiColorLedState.Yellow, ForegroundColor = BiColorLed.BiColorLedState.Green } }, }; while (true) { var p = patterns[patternIndex]; if (currentLed == 0) // When we start a scroll line sequence first let set all the 4 leds with the background color { for (var i = 0; i < biColorLeds.Count; i++) { biColorLeds[i].Set(p.BackgroundColor); } MadeInTheUSB.WinUtil.TimePeriod.Sleep(waitTime); } for (var i = 0; i < biColorLeds.Count; i++) { if (i == currentLed) { biColorLeds[currentLed].Set(p.ForegroundColor); } else { biColorLeds[i].Set(p.BackgroundColor); } } currentLed += 1; if (currentLed >= biColorLeds.Count) { currentLed = 0; patternIndex += 1; if (patternIndex >= patterns.Count) { patternIndex = 0; } } MadeInTheUSB.WinUtil.TimePeriod.Sleep(waitTime); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.Q) { break; } } } biColorLeds.AllOff(); }