static void PerformanceTest(NusbioMatrix matrix, int deviceIndex) { Console.Clear(); ConsoleEx.TitleBar(0, "Performance Test"); ConsoleEx.WriteLine(0, 2, "Drawing images as fast as possible", ConsoleColor.Cyan); int maxRepeat = 16; matrix.CurrentDeviceIndex = deviceIndex; var images = new List <List <string> > { Square00Bmp, Square02Bmp }; ConsoleEx.WriteLine(0, 3, "Slow mode first", ConsoleColor.Cyan); ConsoleEx.Gotoxy(0, 4); for (byte rpt = 0; rpt < maxRepeat; rpt++) { foreach (var image in images) { matrix.Clear(deviceIndex, refresh: false); matrix.DrawBitmap(0, 0, image, 8, 8, 1); matrix.WriteDisplay(deviceIndex); Console.Write("."); Thread.Sleep(200); } } maxRepeat = 128; ConsoleEx.WriteLine(0, 5, "Fast mode first", ConsoleColor.Cyan); ConsoleEx.Gotoxy(0, 6); matrix.BytesSentOutCounter = 0; var sw = Stopwatch.StartNew(); int writeDisplayCount = 0; for (byte rpt = 0; rpt < maxRepeat; rpt++) { foreach (var image in images) { matrix.Clear(deviceIndex, refresh: false); matrix.DrawBitmap(0, 0, image, 8, 8, 1); matrix.WriteDisplay(deviceIndex); writeDisplayCount++; Console.Write("."); } } Console.WriteLine(""); Console.WriteLine("Display Refresh:{0}, {1:0.0} Refresh/S, Bytes Sent:{2}, {3:0.0} K Byte/S", writeDisplayCount, writeDisplayCount * 1000.0 / sw.ElapsedMilliseconds, matrix.BytesSentOutCounter, matrix.BytesSentOutCounter / (sw.ElapsedMilliseconds / 1000.0) / 1024.0 ); sw.Stop(); Console.WriteLine("Hit any key to continue"); var k = Console.ReadKey(); }
static void DisplayImageSequence(NusbioMatrix matrix, string title, int deviceIndex, int maxRepeat, int wait, List <List <string> > images) { matrix.CurrentDeviceIndex = deviceIndex; Console.Clear(); ConsoleEx.TitleBar(0, title); ConsoleEx.WriteMenu(0, 2, "Q)uit"); for (byte rpt = 0; rpt < maxRepeat; rpt++) { foreach (var image in images) { matrix.Clear(deviceIndex, refresh: false); matrix.DrawBitmap(0, 0, image, 8, 8, 1); matrix.CopyToAll(deviceIndex, refreshAll: true); TimePeriod.Sleep(wait); if (Console.KeyAvailable) { if (Console.ReadKey().Key == ConsoleKey.Q) { return; } } } } matrix.Clear(deviceIndex, refresh: true); }
static void DisplayImage(NusbioMatrix matrix) { int MAX_REPEAT = 3; int wait = 400; ConsoleEx.Bar(0, ConsoleUserStatusRow, "DrawBitmap Demo", ConsoleColor.Yellow, ConsoleColor.Red); for (byte rpt = 0; rpt < MAX_REPEAT; rpt++) { var images = new List <List <string> > { neutralBmp, smileBmp, neutralBmp, frownbmp }; foreach (var image in images) { matrix.Clear(refresh: false); matrix.DrawBitmap(0, 0, BitUtil.ParseBinary(image), 8, 8, 1); matrix.WriteDisplay(); TimePeriod.Sleep(wait); } } matrix.Clear(); }