public static void DrawCircleFractal(OLED _oledDisplay, int x, int y, int r) { _oledDisplay.DrawCircle(x, y, r, true); _oledDisplay.DrawCircle(x + r, y, r / 2, true); _oledDisplay.DrawCircle(x - r, y, r / 2, true); _oledDisplay.WriteDisplay(); }
public static void TextDemo(OLED oledDisplay) { Console.Clear(); ConsoleEx.TitleBar(0, "Text demo"); ConsoleEx.WriteMenu(-1, 4, "Q)uit"); oledDisplay.DrawWindow(" NUSBIO "); var messages = new List <string>() { "Hello World", "Hello World.", "Hello World..", "Hello World...", "Written in C#", "or VB.net", "Could be done in F#", "PowerShell? Maybe!", }; var messageIndex = 0; var goOn = true; while (goOn) { oledDisplay.WriteString(-1, 6 * 8, DateTime.Now.ToString()); oledDisplay.WriteString(-1, 3 * 8, messages[messageIndex]); oledDisplay.WriteDisplay(); oledDisplay.WriteString(-1, 3 * 8, messages[messageIndex], clearText: true); messageIndex++; if (messageIndex == messages.Count) { messageIndex = 0; } ConsoleEx.WriteLine(0, 2, "Message Displayed:", ConsoleColor.Cyan); ConsoleEx.WriteLine(19, 2, messages[messageIndex].PadRight(64), ConsoleColor.Yellow); if (Console.KeyAvailable) { var k = Console.ReadKey().Key; if (k == ConsoleKey.Q) { goOn = false; } } Thread.Sleep(900); } oledDisplay.Clear(refresh: true); }
public static void CircleDemo(OLED _oledDisplay) { Console.Clear(); ConsoleEx.TitleBar(0, "Circle Demo"); ConsoleEx.WriteMenu(0, 1, "Q)uit"); var rnd = new Random(); _oledDisplay.Clear(refresh: true); for (var i = 0; i < 16; i += 1) { var r = rnd.Next(2, 16); var x = rnd.Next(r + 1, _oledDisplay.Width - r); var y = rnd.Next(r + 1, _oledDisplay.Height - r); _oledDisplay.DrawCircle(x, y, r, true); _oledDisplay.WriteDisplay(); Console.WriteLine("Circle {0:000},{1:000} r:{2:000}", x, y, r); TimePeriod.Sleep(125); } }
public static void RectangleDemo(OLED _oledDisplay, int wait) { Console.Clear(); ConsoleEx.TitleBar(0, "Rectangle demo"); ConsoleEx.WriteMenu(-1, 6, "Q)uit"); if (wait > 0) { _oledDisplay.DrawWindow("Rectangle Demo", "Slow Speed"); } else { _oledDisplay.DrawWindow("Rectangle Demo", "Full Speed"); } TimePeriod.Sleep(1000 * 2); var sw = Stopwatch.StartNew(); for (var j = 1; j < 64; j++) { _oledDisplay.Clear(refresh: false); for (var i = 0; i < _oledDisplay.Height; i += j) { _oledDisplay.DrawRect(i, i, _oledDisplay.Width - (i * 2), _oledDisplay.Height - (i * 2), true); Console.WriteLine("Rectangle {0:000},{1:000} {2:000},{3:000}", i, i, _oledDisplay.Width - (i * 2), _oledDisplay.Height - (i * 2)); } try { // With Nusbio v 1.0A - FT232RL based this may throw _oledDisplay.WriteDisplay(); } catch { } if (wait > 0) { TimePeriod.Sleep(wait); } } sw.Stop(); _oledDisplay.DrawWindow("Rectangle demo", "The End."); Console.WriteLine("Execution Time:{0}. Hit space to continue", sw.ElapsedMilliseconds); var k = Console.ReadKey(); }
public static void ExperimentDemo(OLED oledDisplay) { Console.Clear(); ConsoleEx.TitleBar(0, "Text demo"); ConsoleEx.WriteMenu(-1, 6, "Q)uit"); //oledDisplay.Clear(refresh:true); //Thread.Sleep(1000); oledDisplay.Clear(true); for (var y = 0; y < 16; y += 1) { for (var x = 0; x < 128; x += 1) { oledDisplay.SetPixel(x, y, true); if (y > oledDisplay.Height - 24) { y = 0; } } oledDisplay.WriteDisplay(); } }