private static void DisplaySpeedTest(LiquidCrystal lc) { lc.Clear(); long i = -1; while(i++ < 1000) { lc.Clear(); //lc.SetCursor(0, 0); var date = DateTime.Now.ToString("s"); date = date.Substring(0, date.IndexOf("T")); switch (i % 2) { case 0 :_liquidCrystal.PrintRightPadded("[{0}] {1}", i.ToString("00"), DateTime.Now.ToString("T").Replace(" ","")); break; case 1 :_liquidCrystal.Print("[{0}] {1}", i.ToString("00"), date);break; } lc.SetCursor(0, 1); switch (i % 3) { case 0 : var cpuInfo = _machineInfo.CpuPercent.NextValue().ToString("0.00");_liquidCrystal.PrintRightPadded("Cpu {0}%", cpuInfo); break; case 1 :_liquidCrystal.PrintRightPadded("DiskR {0}Mb/s", (_machineInfo.DiskReadBytePerSec.NextValue()/1024/1024).ToString("0.00")); break; case 2 :_liquidCrystal.PrintRightPadded("DiskW {0}Mb/s", (_machineInfo.DiskWriteBytePerSec.NextValue()/1024/1024).ToString("0.00")); break; } TimePeriod.Sleep(1000); if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; break; } } }
private static void NusbioRocks(LiquidCrystal lc) { var autoScrollDemoText1 = "Nusbio for .NET rocks or what?"; lc.Clear(); lc.Autoscroll(); lc.SetCursor(15, 0); try { foreach (var c in autoScrollDemoText1) { lc.Print(c.ToString()); TimePeriod.Sleep(180); if (Console.KeyAvailable) return; } TimePeriod.Sleep(1000); } finally{ lc.NoAutoscroll(); lc.Clear(); } }
private static void ApiDemo(LiquidCrystal lc) { ApiDemoDisplay(lc, 0, 0, " -- Api Demo --"); // Display text ApiDemoDisplay(lc, 0, 0, "Display text on line 0 and 1"); ApiDemoDisplay(lc, 0, 0, DateTime.Now.ToString("d"), waitTime:0); ApiDemoDisplay(lc, 0, 1, DateTime.Now.ToString("T"), clear:false); // Turn display on / off ApiDemoDisplay(lc, 0, 0, "About to turn the display off", waitTime:2000); lc.NoDisplay(); TimePeriod.Sleep(1000); lc.Display(); ApiDemoDisplay(lc, 0, 0, "Display turned on"); // Flash Screen ApiDemoDisplay(lc, 0, 0, "About to flash the screen ...", waitTime:2000); ApiDemoDisplay(lc, 0, 0, "Flashing the screen ...", waitTime:0); lc.Flash(10); TimePeriod.Sleep(1000); // Cursor Blink Demo ApiDemoDisplay(lc, 0, 0, "Cursor blink mode on"); lc.Blink(); TimePeriod.Sleep(1000*4); ApiDemoDisplay(lc, 0, 0, "Cursor blink mode off"); lc.NoBlink(); // Cursor Demo ApiDemoDisplay(lc, 0, 0, "Display Cursor"); lc.Cursor(); TimePeriod.Sleep(1000); for (var i = 0; i < 15; i++) { lc.SetCursor(i, 0); TimePeriod.Sleep(300); } for (var i = 15; i >= 0; i--) { lc.SetCursor(i, 0); TimePeriod.Sleep(300); } TimePeriod.Sleep(1000*1); lc.NoCursor(); ApiDemoDisplay(lc, 0, 0, "Cursor off"); // Autoscroll demo ApiDemoDisplay(lc, 0, 0, "Autoscroll Demo", waitTime:2000); NusbioRocks(lc); // Progress Bar Demo ApiDemoDisplay(lc, 0, 0, "Progress Bar Demo"); ProgressBarDemo(lc); ApiDemoDisplay(lc, 0, 0, "-- Demo Done --"); }