int BenchCircles(int num) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); graphics.Stroke = 1; graphics.Clear(true); for (int i = 1; i < num; i++) { graphics.DrawCircle(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayHeight / 2) + 1, RandColor(), false); graphics.Show(); } int empty = (int)stopWatch.Elapsed.TotalMilliseconds; Console.WriteLine($"{num} Circles {empty}ms"); stopWatch.Restart(); graphics.Clear(true); for (int i = 1; i < num; i++) { graphics.DrawCircle(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayHeight / 2) + 1, RandColor(), true); graphics.Show(); } int full = (int)stopWatch.Elapsed.TotalMilliseconds; Console.WriteLine($"{num} Circles filled {full}ms"); stopWatch.Restart(); stopWatch.Stop(); return(empty + full); }
void CircleTest() { graphics.Clear(); graphics.Stroke = 1; graphics.DrawCircle(120, 120, 20, Color.Purple); graphics.Stroke = 2; graphics.DrawCircle(120, 120, 30, Color.Red); graphics.Stroke = 3; graphics.DrawCircle(120, 120, 40, Color.Orange); graphics.Stroke = 4; graphics.DrawCircle(120, 120, 50, Color.Yellow); graphics.Stroke = 5; graphics.DrawCircle(120, 120, 60, Color.LawnGreen); graphics.Stroke = 6; graphics.DrawCircle(120, 120, 70, Color.Cyan); graphics.Stroke = 7; graphics.DrawCircle(120, 120, 80, Color.Blue); graphics.Show(); }
void UpdateDisplayFancy(float temperature) { Console.WriteLine("Update display"); graphics.Clear(); Console.WriteLine("Draw"); var primaryColor = Color.FromRgb(238, 243, 189); var accentColor = Color.FromRgb(26, 128, 170); var tempText = GetTemperatureString(temperature); var xTempPos = graphics.Width / 2 - tempText.Length * 12; graphics.DrawCircle(120, 84, 80, accentColor, true); graphics.DrawCircle(120, 84, 80, primaryColor); graphics.DrawText((int)xTempPos, 70, tempText, primaryColor, GraphicsLibrary.ScaleFactor.X2); //draw pressure bar int barWidth = (int)(220.0 * sensor.Pressure / Conversions.StandardAtmInPa); graphics.DrawRectangle(10, 190, barWidth, 30, accentColor, true); graphics.DrawRectangle(10, 190, 220, 30, primaryColor); graphics.DrawText(20, 196, GetPressureString(sensor.Pressure), primaryColor); Console.WriteLine("Show"); graphics.Show(); }
void Face() { Console.WriteLine("Face..."); charlieWing.Clear(); charlieWing.Frame = 0; graphics.DrawCircle(6, 3, 3); graphics.DrawPixel(5, 2); graphics.DrawPixel(7, 2); graphics.DrawLine(5, 4, 7, 4, true); charlieWing.Show(0); charlieWing.Frame = 1; graphics.DrawCircle(6, 3, 3); graphics.DrawPixel(5, 2); graphics.DrawPixel(7, 2); graphics.DrawPixel(5, 4); graphics.DrawPixel(6, 5); graphics.DrawPixel(7, 4); byte frameIndex = 0; for (int i = 0; i < 10; i++) { charlieWing.Show(frameIndex); frameIndex = (frameIndex == 0) ? (byte)1 : (byte)0; Thread.Sleep(1000); } }
void TestCircles() { graphics.Clear(); // graphics.DrawCircle(20, 20, 1); graphics.DrawCircle(20, 20, 2); graphics.DrawCircle(20, 20, 5); graphics.DrawCircle(20, 20, 8); graphics.DrawCircle(20, 20, 12); graphics.Show(); }
public static void Main() { // SPI constructor var oled = new ST7565(chipSelectPin: Pins.GPIO_PIN_D10, dcPin: Pins.GPIO_PIN_D8, resetPin: Pins.GPIO_PIN_D9, spiModule: SPI.SPI_module.SPI1, speedKHz: 10000); oled.SetContrast(24); oled.SetContrast(12); oled.SetContrast(0); oled.Clear(true); oled.InvertDisplay(true); oled.Clear(true); oled.InvertDisplay(false); oled.IgnoreOutOfBoundsPixels = true; var display = new GraphicsLibrary(oled); display.Clear(true); display.DrawLine(0, 0, 60, 28, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawCircle(63, 31, 20, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(20, 20, 60, 40); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(30, 10, 50, 40, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.CurrentFont = new Font8x8(); display.DrawText(4, 0, "NETDUINO 3 WiFi"); display.DrawCircle(64, 32, 16, true, true); display.Show(); Thread.Sleep(Timeout.Infinite); }
void DrawShapes() { Random rand = new Random(); graphics.Clear(true); int radius = 10; int originX = displayWidth / 2; int originY = displayHeight / 2; for (int i = 1; i < 5; i++) { graphics.DrawCircle ( centerX: originX, centerY: originY, radius: radius, color: Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)) ); graphics.Show(); radius += 30; } int sideLength = 30; for (int i = 1; i < 5; i++) { graphics.DrawRectangle ( x: (displayWidth - sideLength) / 2, y: (displayHeight - sideLength) / 2, width: sideLength, height: sideLength, color: Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255)) ); graphics.Show(); sideLength += 60; } graphics.DrawLine(0, displayHeight / 2, displayWidth, displayHeight / 2, Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))); graphics.DrawLine(displayWidth / 2, 0, displayWidth / 2, displayHeight, Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))); graphics.DrawLine(0, 0, displayWidth, displayHeight, Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))); graphics.DrawLine(0, displayHeight, displayWidth, 0, Color.FromRgb(rand.Next(128, 255), rand.Next(128, 255), rand.Next(128, 255))); graphics.Show(); //Thread.Sleep(5000); }
public MeadowApp() { Console.WriteLine("ePaper sample"); Console.WriteLine("Create Spi bus"); var spiBus = Device.CreateSpiBus();// Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, 2000); Console.WriteLine("Create display driver instance"); display = new Il91874(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D14, dcPin: Device.Pins.D13, resetPin: Device.Pins.D15, busyPin: Device.Pins.D12, width: 176, height: 264); var graphics = new GraphicsLibrary(display); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; graphics.CurrentFont = new Font12x16(); graphics.Clear(); graphics.DrawText(2, 2, "IL91874"); graphics.DrawText(2, 20, "Meadow B3.12"); /* int ySpacing = 12; * * for (int i = 0; i < 3; i++) * { * graphics.DrawLine(2, 70 + ySpacing * i, 22, 50 + ySpacing * i, true); * graphics.DrawLine(22, 50 + ySpacing * i, 42, 70 + ySpacing * i, true); * graphics.DrawLine(44, 70 + ySpacing * i, 64, 50 + ySpacing * i, true); * graphics.DrawLine(64, 50 + ySpacing * i, 84, 70 + ySpacing * i, true); * graphics.DrawLine(86, 70 + ySpacing * i, 106, 50 + ySpacing * i, true); * graphics.DrawLine(106, 50 + ySpacing * i, 126, 70 + ySpacing * i, true); * }*/ graphics.DrawCircle(50, 100, 20, Color.Red, false); graphics.DrawCircle(100, 100, 20, Color.White, false); graphics.DrawCircle(150, 100, 20, Color.Red, true); graphics.DrawCircle(200, 100, 20, Color.White, true); Console.WriteLine("Show"); graphics.Show(); Console.WriteLine("Show complete"); }
void TestILI9163() { Console.WriteLine("Clear display"); // Drawing natively in the display display.ClearScreen(250); Console.WriteLine("Draw"); for (int i = 0; i < 30; i++) { display.DrawPixel(i, i, true); display.DrawPixel(30 + i, i, true); display.DrawPixel(60 + i, i, true); } Console.WriteLine("Show"); display.Show(); Console.WriteLine("Show complete"); // Drawing with Display Graphics Library graphics.CurrentFont = new Font8x8(); graphics.Clear(); graphics.DrawTriangle(10, 10, 50, 50, 10, 50, Meadow.Foundation.Color.Red); graphics.DrawRectangle(20, 15, 40, 20, Meadow.Foundation.Color.Yellow, false); graphics.DrawCircle(50, 50, 40, Meadow.Foundation.Color.Blue, false); graphics.DrawText(5, 5, "Meadow F7 SPI"); graphics.Show(); }
static void UITest() { display.Clear(); display.DrawLine(10, 10, 118, 150, Color.OrangeRed); display.Show(); // Thread.Sleep(500); display.DrawLine(118, 10, 10, 150, Color.OrangeRed); display.Show(); // Thread.Sleep(500); display.DrawCircle(64, 64, 25, Color.Purple); display.Show(); // Thread.Sleep(1000); display.DrawRectangle(5, 5, 118, 150, Color.Aquamarine); display.Show(); // Thread.Sleep(1000); display.DrawRectangle(10, 125, 108, 25, Color.Yellow, true); display.Show(); // Thread.Sleep(1000); display.CurrentFont = new Font8x8(); display.DrawText(4, 10, "NETDUINO 3 WiFi", Color.SkyBlue); display.Show(); Thread.Sleep(Timeout.Infinite); }
void LoadScreen() { Console.WriteLine("LoadScreen..."); graphics.Clear(); int radius = 225; int originX = displayWidth / 2; int originY = displayHeight / 2 + 130; graphics.Stroke = 3; for (int i = 1; i < 5; i++) { graphics.DrawCircle ( centerX: originX, centerY: originY, radius: radius, color: colors[i - 1], filled: true ); graphics.Show(); radius -= 20; } graphics.DrawLine(0, 220, 240, 220, Color.White); graphics.DrawLine(0, 230, 240, 230, Color.White); graphics.CurrentFont = new Font12x20(); graphics.DrawText(54, 130, "TEMPERATURE", Color.White); graphics.Show(); }
void DrawWatchFace() { graphics.Clear(); int hour = 12; int xCenter = displayWidth / 2; int yCenter = displayHeight / 2; int x, y; graphics.DrawRectangle(0, 0, displayWidth, displayHeight, Color.White); graphics.DrawRectangle(5, 5, displayWidth - 10, displayHeight - 10, Color.White); graphics.CurrentFont = new Font12x20(); graphics.DrawCircle(xCenter, yCenter, 100, WatchBackgroundColor, true); for (int i = 0; i < 60; i++) { x = (int)(xCenter + 80 * Math.Sin(i * Math.PI / 30)); y = (int)(yCenter - 80 * Math.Cos(i * Math.PI / 30)); if (i % 5 == 0) { graphics.DrawText( hour > 9 ? x - 10 : x - 5, y - 5, hour.ToString(), Color.Black); if (hour == 12) { hour = 1; } else { hour++; } } } graphics.Show(); }
void StartBreakoutLoop() { while (true) { breakoutGame.Update(); graphics.Clear(false); graphics.DrawCircle(breakoutGame.Ball.X, breakoutGame.Ball.Y, breakoutGame.Ball.Radius, true, true); graphics.DrawRectangle(breakoutGame.Paddle.X, breakoutGame.Paddle.Y, breakoutGame.Paddle.Width, breakoutGame.Paddle.Height, true); for (int i = 0; i < breakoutGame.Blocks.Length; i++) { if (breakoutGame.Blocks[i].IsVisible) { graphics.DrawRectangle(breakoutGame.Blocks[i].X, breakoutGame.Blocks[i].Y, breakoutGame.Blocks[i].Width, breakoutGame.Blocks[i].Height); } } graphics.Show(); } }
public static void Main() { var oled = new SSD1306(0x3c, 400, SSD1306.DisplayType.OLED128x64); var display = new GraphicsLibrary(oled); display.Clear(true); display.DrawLine(0, 30, 80, 60, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawCircle(63, 31, 20, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(20, 20, 60, 40); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(30, 10, 50, 40, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.CurrentFont = new Font8x8(); display.DrawText(4, 10, "NETDUINO 3 WiFi"); display.Show(); Thread.Sleep(Timeout.Infinite); }
void TestDisplay() { //force a collection GC.Collect(); Console.WriteLine("Draw"); for (int i = 0; i < 30; i++) { display.DrawPixel(i, 120 + i, true); display.DrawPixel(30 + i, 120 + i, true); display.DrawPixel(60 + i, 120 + i, true); } // Draw with Display Graphics Library graphics.CurrentFont = new Font8x8(); graphics.Clear(); graphics.DrawTriangle(10, 10, 50, 50, 10, 50, Meadow.Foundation.Color.Red); graphics.DrawRectangle(20, 15, 40, 20, Meadow.Foundation.Color.Yellow, false); graphics.DrawCircle(50, 50, 40, Meadow.Foundation.Color.Blue, false); graphics.DrawText(5, 5, "Meadow F7 SPI", Color.White); graphics.Show(); }
void WelcomeScreen() { string thermv01 = "Therm v0.1"; graphics.Clear(true); graphics.Stroke = 1; graphics.DrawRectangle(0, 0, (int)st7789.Width, (int)st7789.Height, Color.White); graphics.DrawRectangle(5, 5, (int)st7789.Width - 10, (int)st7789.Height - 10, Color.White); graphics.DrawCircle((int)st7789.Width / 2, (int)st7789.Height / 2, (int)(st7789.Width / 2) - 10, Color.White, true); graphics.CurrentFont = new Font12x20(); graphics.DrawText((int)(st7789.Width - thermv01.Length * 12) / 2, 110, thermv01, Color.Black); graphics.Show(); }
static private void DrawClock(int hour = 6, int minute = 20, int second = 30) { int xCenter = 64; int yCenter = 80; int x, y; Draw24bppBitmap(24, 60, meadowLogo, tftDisplay); //ticks - let's do 60 for (int i = 0; i < 60; i++) { x = (int)(xCenter + 50 * System.Math.Sin(i * System.Math.PI / 30)); y = (int)(yCenter - 50 * System.Math.Cos(i * System.Math.PI / 30)); if (i % 5 == 0) { tftGraphics.DrawCircle(x, y, 2, Color.White); } else { tftDisplay.DrawPixel(x, y, true); } } if (hour == -1) { tftGraphics.DrawText(44, 64, "Wilderness", Color.Gray); return; } int xT, yT; //hour x = (int)(xCenter + 23 * System.Math.Sin(hour * System.Math.PI / 6)); y = (int)(yCenter - 23 * System.Math.Cos(hour * System.Math.PI / 6)); xT = (int)(xCenter + 3 * System.Math.Sin((hour - 3) * System.Math.PI / 6)); yT = (int)(yCenter - 3 * System.Math.Cos((hour - 3) * System.Math.PI / 6)); tftGraphics.DrawLine(xT, yT, x, y, Color.LawnGreen); xT = (int)(xCenter + 3 * System.Math.Sin((hour + 3) * System.Math.PI / 6)); yT = (int)(yCenter - 3 * System.Math.Cos((hour + 3) * System.Math.PI / 6)); tftGraphics.DrawLine(xT, yT, x, y, Color.LawnGreen); //minute x = (int)(xCenter + 35 * System.Math.Sin(minute * System.Math.PI / 30)); y = (int)(yCenter - 35 * System.Math.Cos(minute * System.Math.PI / 30)); xT = (int)(xCenter + 3 * System.Math.Sin((minute - 15) * System.Math.PI / 6)); yT = (int)(yCenter - 3 * System.Math.Cos((minute - 15) * System.Math.PI / 6)); tftGraphics.DrawLine(xT, yT, x, y, Color.LawnGreen); xT = (int)(xCenter + 3 * System.Math.Sin((minute + 15) * System.Math.PI / 6)); yT = (int)(yCenter - 3 * System.Math.Cos((minute + 15) * System.Math.PI / 6)); tftGraphics.DrawLine(xT, yT, x, y, Color.LawnGreen); //second x = (int)(xCenter + 40 * System.Math.Sin(second * System.Math.PI / 30)); y = (int)(yCenter - 40 * System.Math.Cos(second * System.Math.PI / 30)); tftGraphics.DrawLine(xCenter, yCenter, x, y, Color.Red); }
public MeadowApp() { Console.WriteLine("TftSpi sample"); Console.WriteLine("Create Spi bus"); spiBus = Device.CreateSpiBus(3000); Console.WriteLine("Create display driver instance"); display = new Ssd1351(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D02, dcPin: Device.Pins.D01, resetPin: Device.Pins.D00, width: 128, height: 128); Console.WriteLine("Create graphics lib"); var graphicsLib = new GraphicsLibrary(display); graphicsLib.CurrentFont = new Font8x12(); graphicsLib.Clear(); graphicsLib.DrawCircle(80, 80, 40, Meadow.Foundation.Color.Cyan, false); int indent = 0; int spacing = 10; int y = indent; graphicsLib.DrawText(indent, y, "Meadow F7 (SSD1351)"); graphicsLib.DrawText(indent, y += spacing, "Red", Meadow.Foundation.Color.Red); graphicsLib.DrawText(indent, y += spacing, "Purple", Meadow.Foundation.Color.Purple); graphicsLib.DrawText(indent, y += spacing, "BlueViolet", Meadow.Foundation.Color.BlueViolet); graphicsLib.DrawText(indent, y += spacing, "Blue", Meadow.Foundation.Color.Blue); graphicsLib.DrawText(indent, y += spacing, "Cyan", Meadow.Foundation.Color.Cyan); graphicsLib.DrawText(indent, y += spacing, "LawnGreen", Meadow.Foundation.Color.LawnGreen); graphicsLib.DrawText(indent, y += spacing, "GreenYellow", Meadow.Foundation.Color.GreenYellow); graphicsLib.DrawText(indent, y += spacing, "Yellow", Meadow.Foundation.Color.Yellow); graphicsLib.DrawText(indent, y += spacing, "Orange", Meadow.Foundation.Color.Orange); graphicsLib.DrawText(indent, y += spacing, "Brown", Meadow.Foundation.Color.Brown); Console.WriteLine("Show"); graphicsLib.Show(); Console.WriteLine("Show complete"); }
void ShapeTest() { Console.WriteLine("Shape test"); graphics.Clear(); graphics.DrawCircle(60, 60, 20, Color.Purple); graphics.DrawRectangle(10, 10, 30, 60, Color.Red); graphics.DrawTriangle(20, 20, 10, 70, 60, 60, Color.Green); graphics.DrawCircle(90, 60, 20, Color.Cyan, true); graphics.DrawRectangle(100, 100, 30, 10, Color.Yellow, true); graphics.DrawTriangle(120, 20, 110, 70, 160, 60, Color.Pink, true); graphics.DrawLine(10, 120, 110, 130, Color.SlateGray); graphics.Show(); Console.WriteLine("Shape test complete"); }
void LoadScreen() { Console.WriteLine("LoadScreen..."); graphics.Clear(true); graphics.Stroke = 1; graphics.DrawRectangle( x: 0, y: 0, width: (int)display.Width, height: (int)display.Height, color: Color.White); graphics.DrawRectangle( x: 5, y: 5, width: (int)display.Width - 10, height: (int)display.Height - 10, color: Color.White); graphics.DrawCircle( centerX: (int)display.Width / 2, centerY: (int)display.Height / 2, radius: (int)(display.Width / 2) - 10, color: Color.FromHex("#EF7D3B"), filled: true); DisplayJPG(55, 40); graphics.CurrentFont = new Font8x12(); string textMotion = "MOTION"; graphics.DrawText( (int)(display.Width - textMotion.Length * 16) / 2, 140, textMotion, Color.Black, GraphicsLibrary.ScaleFactor.X2); string textDetector = "DETECTOR"; graphics.DrawText( (int)(display.Width - textDetector.Length * 16) / 2, 165, textDetector, Color.Black, GraphicsLibrary.ScaleFactor.X2); graphics.Show(); }
void Draw() { int angle = 160; int increment = 4; int x, y = 0; while (true) { graphics.Clear(); DrawRadar(); graphics.DrawLine(120, 120, 105, (float)(angle * Math.PI / 180), Color.Yellow); if (angle >= 180) { increment = -4; } if (angle <= 0) { increment = 4; } angle += increment; graphics.DrawText(0, 0, $"{180 - angle}°", Color.Yellow); if (sensor?.Conditions?.Distance != null && sensor?.Conditions?.Distance.Value >= 0) { graphics.DrawText(170, 0, $"{sensor.Conditions.Distance.Value}mm", Color.Yellow); radarData[angle] = sensor.Conditions.Distance.Value / 2; } else { Console.WriteLine("no data"); radarData[angle] = 0; } for (int i = 0; i < 180; i++) { x = 120 + (int)(radarData[i] * MathF.Cos(i * MathF.PI / 180f)); y = 120 - (int)(radarData[i] * MathF.Sin(i * MathF.PI / 180f)); //graphics.DrawPixel(x, y, Color.Yellow); graphics.DrawCircle(x, y, 2, Color.Yellow, true); } graphics.Show(); Thread.Sleep(100); } }
protected void Render() { lock (RenderLock) { if (IsRendering) { Console.WriteLine("Already in render loop"); return; } IsRendering = true; } Graphics.Clear(false); Graphics.Stroke = 1; Graphics.DrawRectangle( x: 0, y: 0, width: (int)Display.Width - 10, height: (int)Display.Height - 10, Color.White); Graphics.DrawCircle( centerX: (int)Display.Width / 2 - 5, centerY: (int)Display.Height / 2 - 5, radius: (int)(Display.Width / 2) - 10, Color.FromHex("#23abe3"), filled: true); DisplayJPG(55, 40); string text = $"{Conditions.Temperature?.ToString("##.#")}°C"; Graphics.CurrentFont = new Font12x20(); Graphics.DrawText( x: (int)(Display.Width - text.Length * 24) / 2, y: 140, text: text, color: Color.Black, scaleFactor: GraphicsLibrary.ScaleFactor.X2); Graphics.Rotation = GraphicsLibrary.RotationType._180Degrees; Graphics.Show(); IsRendering = false; }
static void UITest() { display.CurrentFont = new Font8x12(); display.DrawText(4, 4, "abcdefghijklm", Color.SkyBlue); display.DrawText(4, 18, "nopqrstuvwxyz", Color.SkyBlue); display.DrawText(4, 32, "`1234567890-=", Color.SkyBlue); display.DrawText(4, 46, "~!@#$%^&*()_+", Color.SkyBlue); display.DrawText(4, 60, "[]\\;',./", Color.SkyBlue); display.DrawText(4, 74, "{}|:\"<>?", Color.SkyBlue); display.DrawText(4, 88, "ABCDEFGHIJKLM", Color.SkyBlue); display.DrawText(4, 102, "NOPQRSTUVWXYZ", Color.SkyBlue); display.CurrentFont = new Font4x8(); display.DrawText(4, 116, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", Color.White); display.DrawText(4, 126, "abcdefghijklmnopqrstuvwxyz", Color.White); display.DrawText(4, 136, "01234567890!@#$%^&*()_+-=", Color.White); display.DrawText(4, 146, "\\|;:'\",<.>/?[]{}", Color.White); display.Show(); Thread.Sleep(20000); display.Clear(); display.DrawLine(10, 10, 118, 150, Color.OrangeRed); display.Show(); Thread.Sleep(500); display.DrawLine(118, 10, 10, 150, Color.OrangeRed); display.Show(); Thread.Sleep(500); display.DrawCircle(64, 64, 25, Color.Purple); display.Show(); Thread.Sleep(1000); display.DrawRectangle(5, 5, 118, 150, Color.Aquamarine); display.Show(); Thread.Sleep(1000); display.DrawRectangle(10, 100, 108, 50, Color.Yellow, true); display.Show(); Thread.Sleep(1000); var bytes = Resources.GetBytes(Resources.BinaryResources.trees); DrawBitmap(10, 120, bytes, tft); tft.Refresh(); }
public static void Main() { ePaper = new EPD2i7(chipSelectPin: Pins.GPIO_PIN_D4, dcPin: Pins.GPIO_PIN_D7, resetPin: Pins.GPIO_PIN_D6, busyPin: Pins.GPIO_PIN_D5, spiModule: SPI.SPI_module.SPI1, speedKHz: 4000); /* var e27 = (EPD2i7)ePaper; * * e27.ClearFrame(); * e27.DisplayFrame(); * e27.Show();*/ ePaper.Clear(false, true); display = new GraphicsLibrary(ePaper); display.DrawLine(10, 10, 94, 100); // display.Show(); // Thread.Sleep(500); display.DrawCircle(52, 60, 32); // display.Show(); // Thread.Sleep(500); display.DrawRectangle(5, 40, 60, 60); // display.Show(); // Thread.Sleep(1000); display.DrawRectangle(20, 100, 40, 25, Color.Red, true); // display.Show(); // Thread.Sleep(500); display.CurrentFont = new Font8x12(); display.DrawText(2, 2, "Wilderness"); display.CurrentFont = new Font8x8(); display.DrawText(2, 16, "Netduino 3", Color.Red); display.Show(); Thread.Sleep(-1); }
public MeadowApp() { Console.WriteLine("ePaper sample"); Console.WriteLine("Create Spi bus"); var spiBus = Device.CreateSpiBus();// Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, 2000); Console.WriteLine("Create display driver instance"); display = new Il91874(device: Device, spiBus: spiBus, chipSelectPin: Device.Pins.D14, dcPin: Device.Pins.D13, resetPin: Device.Pins.D15, busyPin: Device.Pins.D12, width: 176, height: 264); var graphics = new GraphicsLibrary(display); //any color but black will show the ePaper alternate color // graphics.DrawRectangle(1, 1, 126, 32, Meadow.Foundation.Color.Red, false); graphics.CurrentFont = new Font12x16(); graphics.DrawText(2, 2, "IL91874"); graphics.DrawText(2, 20, "Meadow F7"); int ySpacing = 12; for (int i = 0; i < 3; i++) { graphics.DrawLine(2, 70 + ySpacing * i, 22, 50 + ySpacing * i, true); graphics.DrawLine(22, 50 + ySpacing * i, 42, 70 + ySpacing * i, true); graphics.DrawLine(44, 70 + ySpacing * i, 64, 50 + ySpacing * i, true); graphics.DrawLine(64, 50 + ySpacing * i, 84, 70 + ySpacing * i, true); graphics.DrawLine(86, 70 + ySpacing * i, 106, 50 + ySpacing * i, true); graphics.DrawLine(106, 50 + ySpacing * i, 126, 70 + ySpacing * i, true); } graphics.DrawCircle(100, 150, 50, true, false); Console.WriteLine("Show"); graphics.Show(); }
void StartGameLoop() { while (true) { pongGame.Update(); graphics.Clear(); graphics.DrawCircle(pongGame.BallX, pongGame.BallY, pongGame.BallRadius, true, true); graphics.DrawRectangle(pongGame.PlayerX, pongGame.PlayerY, pongGame.PaddleWidth, pongGame.PaddleHeight, true, true); graphics.DrawRectangle(pongGame.CpuX, pongGame.CpuY, pongGame.PaddleWidth, pongGame.PaddleHeight, true, true); graphics.DrawText(52, 0, $"{pongGame.PlayerScore}:{pongGame.CpuScore}"); graphics.Show(); Thread.Sleep(10); } }
public static void Main() { // I2C constructor // var oled = new SSD1306(Cpu.Pin.GPIO_Pin9, Cpu.Pin.GPIO_Pin10, Cpu.Pin.GPIO_Pin7, SPI.SPI_module.SPI1, 4000, SSD1306.DisplayType.OLED128x32); // SPI constructor var oled = new SSD1306(chipSelectPin: Pins.GPIO_PIN_D9, dcPin: Pins.GPIO_PIN_D10, resetPin: Pins.GPIO_PIN_D7, spiModule: SPI.SPI_module.SPI1, speedKHz: 400000, displayType: SSD1306.DisplayType.OLED128x32); oled.IgnoreOutOfBoundsPixels = true; var display = new GraphicsLibrary(oled); display.Clear(true); display.DrawLine(0, 0, 60, 28, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawCircle(63, 31, 20, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(20, 20, 60, 40); display.Show(); Thread.Sleep(1000); display.Clear(true); display.DrawRectangle(30, 10, 50, 40, true, true); display.Show(); Thread.Sleep(1000); display.Clear(true); display.CurrentFont = new Font8x8(); display.DrawText(4, 10, "NETDUINO 3 WiFi"); display.Show(); Thread.Sleep(Timeout.Infinite); }
/// <summary> /// Does the actual rendering. If it's already rendering, it'll bail out, /// so render requests don't stack up. /// </summary> protected void Render() { Console.WriteLine($"Render() - is rendering: {isRendering}"); lock (renderLock) { // if we're already rendering, bail out. if (isRendering) { Console.WriteLine("Already in a rendering loop, bailing out."); return; } isRendering = true; } graphics.Clear(true); graphics.Stroke = 1; graphics.DrawRectangle(0, 0, (int)display.Width, (int)display.Height, Color.White); graphics.DrawRectangle(5, 5, (int)display.Width - 10, (int)display.Height - 10, Color.White); graphics.DrawCircle((int)display.Width / 2, (int)display.Height / 2, (int)(display.Width / 2) - 10, Color.FromHex("#23abe3"), true); DisplayJPG(); string text = $"{conditions.Temperature?.ToString("##.#")}°C"; graphics.CurrentFont = new Font12x20(); graphics.DrawText( x: (int)(display.Width - text.Length * 24) / 2, y: 140, text: text, color: Color.Black, scaleFactor: GraphicsLibrary.ScaleFactor.X2); graphics.Rotation = GraphicsLibrary.RotationType._270Degrees; graphics.Show(); Console.WriteLine("Show complete"); isRendering = false; }
void ColorFontTest() { graphics.CurrentFont = new Font8x12(); graphics.Clear(); graphics.DrawTriangle(120, 20, 200, 100, 120, 100, Meadow.Foundation.Color.Red, false); graphics.DrawRectangle(140, 30, 40, 90, Meadow.Foundation.Color.Yellow, false); graphics.DrawCircle(160, 80, 40, Meadow.Foundation.Color.Cyan, false); int indent = 5; int spacing = 14; int y = indent; graphics.DrawText(indent, y, "Meadow + SSD1327!!"); graphics.DrawText(indent, y += spacing, "Red", Meadow.Foundation.Color.Red); graphics.DrawText(indent, y += spacing, "Purple", Meadow.Foundation.Color.Purple); graphics.DrawText(indent, y += spacing, "BlueViolet", Meadow.Foundation.Color.BlueViolet); graphics.DrawText(indent, y += spacing, "Blue", Meadow.Foundation.Color.Blue); graphics.DrawText(indent, y += spacing, "Cyan", Meadow.Foundation.Color.Cyan); graphics.DrawText(indent, y += spacing, "LawnGreen", Meadow.Foundation.Color.LawnGreen); graphics.DrawText(indent, y += spacing, "GreenYellow", Meadow.Foundation.Color.GreenYellow); graphics.DrawText(indent, y += spacing, "Yellow", Meadow.Foundation.Color.Yellow); graphics.DrawText(indent, y += spacing, "Orange", Meadow.Foundation.Color.Orange); graphics.DrawText(indent, y += spacing, "Brown", Meadow.Foundation.Color.Brown); graphics.Show(); Console.WriteLine("Show complete"); }
public static void Main() { Debug.Print(Resources.GetString(Resources.StringResources.String1)); var display = new PCD8544(chipSelectPin: Pins.GPIO_PIN_D9, dcPin: Pins.GPIO_PIN_D8, resetPin: Pins.GPIO_PIN_D10, spiModule: SPI.SPI_module.SPI1); var gl = new GraphicsLibrary(display); gl.CurrentFont = new Font8x8(); gl.DrawText(0, 0, "PCD8544"); gl.CurrentFont = new Font4x8(); gl.DrawText(0, 10, "Nokia 3110 & 5110"); gl.DrawRectangle(20, 20, 10, 10); gl.DrawCircle(60, 30, 12, true, false); gl.Show(); Thread.Sleep(-1); }