static void ScrollDemo(NusbioMatrix matrix, int deviceIndex) { Console.Clear(); ConsoleEx.TitleBar(0, "Scroll Demo"); ConsoleEx.WriteMenu(0, 2, "Q)uit"); matrix.Clear(all: true, refresh: true); for (var d = 0; d < matrix.DeviceCount; d++) { for (var x = 0; x < matrix.Width; x++) { matrix.SetLed(d, x, 0, true); matrix.SetLed(d, x, 7, true); matrix.SetLed(d, 0, x, true); } } matrix.WriteDisplay(all: true); Thread.Sleep(1000); for (var z = 0; z < 8 * 3; z++) { matrix.ScrollPixelLeftDevices(3, 0); matrix.WriteDisplay(all: true); } }
private static void ScrollText(NusbioMatrix matrix, int deviceIndex = 0) { var quit = false; var speed = 10; var text = "Hello World! "; if (matrix.DeviceCount == 1 && matrix.MAX7219Wiring == NusbioMatrix.MAX7219_WIRING_TO_8x8_LED_MATRIX.OriginBottomRightCorner) { speed = speed * 3; } while (!quit) { Console.Clear(); ConsoleEx.TitleBar(0, "Scroll Text"); ConsoleEx.WriteMenu(0, 2, string.Format("Q)uit F)aster S)lower Speed:{0:000}", speed)); matrix.Clear(all: true); matrix.WriteDisplay(all: true); for (var ci = 0; ci < text.Length; ci++) { var c = text[ci]; ConsoleEx.WriteMenu(ci, 4, c.ToString()); matrix.WriteChar(deviceIndex, c); // See property matrix.MAX7218Wiring for more info matrix.WriteDisplay(all: true); if (speed > 0) { Thread.Sleep(speed); // Provide a better animation if (matrix.DeviceCount == 1 && matrix.MAX7219Wiring == NusbioMatrix.MAX7219_WIRING_TO_8x8_LED_MATRIX.OriginBottomRightCorner) { Thread.Sleep(speed * 12); } } for (var i = 0; i < MAX7219.MATRIX_ROW_SIZE; i++) { matrix.ScrollPixelLeftDevices(matrix.DeviceCount - 1, 0, 1); matrix.WriteDisplay(all: true); // Do not wait when we scrolled the last pixel, we will wait when we display the new character if (i < MAX7219.MATRIX_ROW_SIZE - 1) { if (speed > 0) { Thread.Sleep(speed); } } if (Console.KeyAvailable) { switch (Console.ReadKey().Key) { case ConsoleKey.Q: quit = true; i = 100; ci = 10000; break; case ConsoleKey.S: speed += 10; break; case ConsoleKey.F: speed -= 10; if (speed < 0) { speed = 0; } break; } ConsoleEx.WriteMenu(0, 2, string.Format("Q)uit F)aster S)lower Speed:{0:000}", speed)); } } } } }