Exemplo n.º 1
0
        void DrawTitleMenu()
        {
            Console.WriteLine("Draw title");

            graphics.Clear();
            graphics.Show();
            Thread.Sleep(400);//pause for video recording

            graphics.DrawLine(0, 0, 127, 0, true);
            graphics.Show();
            for (int i = 1; i < 63; i++)
            {
                graphics.DrawPixel(0, i);
                graphics.DrawPixel(127, i);
                graphics.Show();
            }

            graphics.DrawLine(0, 63, 127, 63, true);
            graphics.Show();
            Thread.Sleep(400);

            graphics.DrawText(22, 20, "Frogger");
            graphics.Show();
            Thread.Sleep(400);

            for (int i = 0; i < 5; i++)
            {
                DrawFrog(20 * (i + 1), 50, 1);

                graphics.Show();
                Thread.Sleep(400);
            }
        }
Exemplo n.º 2
0
        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();
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        private void DrawSecondHand(int second, Color color)
        {
            this.graphics.Stroke = 1;
            int x = (int)(XCenter + 70 * System.Math.Sin(second * System.Math.PI / 30));
            int y = (int)(YCenter - 70 * System.Math.Cos(second * System.Math.PI / 30));

            graphics.DrawLine(XCenter, YCenter, x, y, color);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
 public void DrawLine(int x1, int y1, int x2, int y2, int minVal)
 {
     //Console.WriteLine($"Draw Line {_graphPane.X + x1}, {_graphPane.Y + _graphPane.Height + (y1 - minVal)} " +
     //    $"to {_graphPane.X + x2}, {_graphPane.Y + _graphPane.Height + (y2 - minVal)} with min value = {minVal}");
     // draw the line in relation to the graph pane
     _graphicsLibrary.DrawLine(
         _graphPane.X + x1,
         _graphPane.Y + _graphPane.Height + minVal - y1,
         _graphPane.X + x2,
         _graphPane.Y + _graphPane.Height + minVal - y2, LineColor);
 }
Exemplo n.º 7
0
        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);
            }
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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();
        }
Exemplo n.º 11
0
        private static void LoadScreen(GraphicsLibrary graphicsLibrary, int displayWidth, int displayHeight)
        {
            Console.WriteLine("LoadScreen...");

            graphicsLibrary.Clear();

            graphicsLibrary.Stroke = 3;

            graphicsLibrary.CurrentFont = new Font12x20();
            graphicsLibrary.DrawText(54, 10, "MCP9808", Color.White);

            graphicsLibrary.DrawText(54, 130, "LM35 DZ", Color.White);

            graphicsLibrary.DrawLine(0, 220, 240, 220, Color.White);
            graphicsLibrary.DrawLine(0, 230, 240, 230, Color.White);

            graphicsLibrary.Show();
        }
Exemplo n.º 12
0
        void PolarLineTest()
        {
            graphics.Clear();
            graphics.Stroke = 1;

            for (int i = 0; i < 270; i += 12)
            {
                graphics.DrawLine(64, 64, 60, (float)(i * Math.PI / 180), Color.White);
            }

            graphics.Show();
        }
        /// <summary>
        /// Use the meadow graphics library to draw the expressive pixels - I Frame
        /// </summary>
        private void Display(IFrameDef ifd, ushort xPos, ushort yPos, ushort zoom)
        {
            int x = xPos;
            int y = yPos;

            foreach (var p in ifd.PalIndex)
            {
                if (zoom == 1)
                {
                    graphics.DrawPixel(x, y, Pallette[p]);
                    x += 1;
                    if (x - xPos >= Width)
                    {
                        x  = xPos;
                        y += 1;
                    }
                }
                else if (zoom == 2 || zoom == 3)
                {
                    graphics.Stroke = zoom;
                    graphics.DrawLine(x, y, x + zoom - 1, y, Pallette[p]);
                    x += zoom;
                    if (x - xPos >= Width * zoom)
                    {
                        x  = xPos;
                        y += zoom;
                    }
                }
                else
                {
                    graphics.DrawRectangle(x, y, zoom, zoom, Pallette[p], true);
                    x += zoom;
                    if (x - xPos >= Width * zoom)
                    {
                        x  = xPos;
                        y += zoom;
                    }
                }
            }
        }
Exemplo n.º 14
0
        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);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 16
0
        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);
        }
Exemplo n.º 17
0
        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");
        }
Exemplo n.º 18
0
        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();
        }
Exemplo n.º 19
0
        public MeadowApp()
        {
            Console.WriteLine("ePaper sample");
            Console.WriteLine("Create Spi bus");

            spiBus = Device.CreateSpiBus();// Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, 2000);


            Console.WriteLine("Create display driver instance");
            display = new IL0373(device: Device, spiBus: spiBus,
                                 chipSelectPin: Device.Pins.D02,
                                 dcPin: Device.Pins.D01,
                                 resetPin: Device.Pins.D00,
                                 busyPin: Device.Pins.D03,
                                 width: 102,
                                 height: 212);


            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 Font8x12();
            graphics.DrawText(2, 2, ".NET Conf 2019");
            graphics.DrawText(2, 20, "Meadow F7");

            int ySpacing = 6;

            for (int i = 0; i < 3; i++)
            {
                graphics.DrawLine(2, 70 + ySpacing * i, 22, 50 + ySpacing * i);
                graphics.DrawLine(22, 50 + ySpacing * i, 42, 70 + ySpacing * i);
                graphics.DrawLine(44, 70 + ySpacing * i, 64, 50 + ySpacing * i);
                graphics.DrawLine(64, 50 + ySpacing * i, 84, 70 + ySpacing * i);
                graphics.DrawLine(86, 70 + ySpacing * i, 106, 50 + ySpacing * i);
                graphics.DrawLine(106, 50 + ySpacing * i, 126, 70 + ySpacing * i);
            }

            Console.WriteLine("Show");

            graphics.Show();
        }
Exemplo n.º 20
0
        void DrawMeadowLogo()
        {
            graphics.Clear();

            var bottom = 200;
            var height = 54;

            graphics.DrawLine(4, bottom, 44, bottom - height, Color.White);
            graphics.DrawLine(4, bottom, 44, bottom, Color.White);
            graphics.DrawLine(44, 200 - height, 64, bottom - height / 2, Color.White);
            graphics.DrawLine(44, bottom, 84, bottom - height, Color.White);
            graphics.DrawLine(84, bottom - height, 124, bottom, Color.White);

            //mountain fill
            int lineWidth, x, y;

            for (int i = 0; i < height - 1; i++)
            {
                y = bottom - i;
                x = 5 + i * 20 / 27;

                //fill bottom of mountain
                if (i < height / 2)
                {
                    lineWidth = 38;
                    graphics.DrawLine(x, y, x + lineWidth, y, Color.YellowGreen);
                }
                else
                { //fill top of mountain
                    lineWidth = 38 - (i - height / 2) * 40 / 27;
                    graphics.DrawLine(x, y, x + lineWidth, y, Color.YellowGreen);
                }
            }

            graphics.Show();
        }
Exemplo n.º 21
0
        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 Il3897(device: Device, spiBus: spiBus,
                                 chipSelectPin: Device.Pins.D02,
                                 dcPin: Device.Pins.D01,
                                 resetPin: Device.Pins.D00,
                                 busyPin: Device.Pins.D03,
                                 width: 122,
                                 height: 250);

            var graphics = new GraphicsLibrary(display);

            graphics.CurrentFont = new Font8x12();
            graphics.DrawText(2, 2, "IL3897");
            graphics.DrawText(2, 20, "Meadow F7");

            int ySpacing = 6;

            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);
            }

            Console.WriteLine("Show");

            graphics.Show();
        }
Exemplo n.º 22
0
        void UpdateDisplay()
        {
            //any color but black will show the ePaper alternate color
            graphics.DrawRectangle(0, 0, 128, 34, Meadow.Foundation.Color.Red, false);

            graphics.DrawText(2, 2, ".NET Conf 2019");
            graphics.DrawText(2, 20, "Meadow F7");

            int ySpacing = 6;

            for (int i = 0; i < 3; i++)
            {
                graphics.DrawLine(2, 70 + ySpacing * i, 22, 50 + ySpacing * i);
                graphics.DrawLine(22, 50 + ySpacing * i, 42, 70 + ySpacing * i);
                graphics.DrawLine(44, 70 + ySpacing * i, 64, 50 + ySpacing * i);
                graphics.DrawLine(64, 50 + ySpacing * i, 84, 70 + ySpacing * i);
                graphics.DrawLine(86, 70 + ySpacing * i, 106, 50 + ySpacing * i);
                graphics.DrawLine(106, 50 + ySpacing * i, 126, 70 + ySpacing * i);
            }

            Console.WriteLine("Show");

            graphics.Show();
        }
Exemplo n.º 23
0
        void DrawWireframe()
        {
            graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[1, 0], cubeWireframe[1, 1], true);
            graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], true);
            graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], true);
            graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[0, 0], cubeWireframe[0, 1], true);

            //cross face above
            graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[3, 0], cubeWireframe[3, 1], true);
            graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[2, 0], cubeWireframe[2, 1], true);

            graphics.DrawLine(cubeWireframe[4, 0], cubeWireframe[4, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], true);
            graphics.DrawLine(cubeWireframe[5, 0], cubeWireframe[5, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], true);
            graphics.DrawLine(cubeWireframe[6, 0], cubeWireframe[6, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], true);
            graphics.DrawLine(cubeWireframe[7, 0], cubeWireframe[7, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], true);

            graphics.DrawLine(cubeWireframe[0, 0], cubeWireframe[0, 1], cubeWireframe[4, 0], cubeWireframe[4, 1], true);
            graphics.DrawLine(cubeWireframe[1, 0], cubeWireframe[1, 1], cubeWireframe[5, 0], cubeWireframe[5, 1], true);
            graphics.DrawLine(cubeWireframe[2, 0], cubeWireframe[2, 1], cubeWireframe[6, 0], cubeWireframe[6, 1], true);
            graphics.DrawLine(cubeWireframe[3, 0], cubeWireframe[3, 1], cubeWireframe[7, 0], cubeWireframe[7, 1], true);
        }
Exemplo n.º 24
0
        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);
        }
Exemplo n.º 25
0
        void DrawGame()
        {
            //draw gameboard
            graphics.DrawRectangle(xStart, yStart, CellSize * connectGame.Width + 1, CellSize * connectGame.Height + 1, Color.DarkBlue, true);
            graphics.DrawRectangle(xStart, yStart, CellSize * connectGame.Width + 1, CellSize * connectGame.Height + 1, Color.Blue, false);

            for (int i = 1; i < 7; i++)
            {
                graphics.DrawLine(xStart + CellSize * i,
                                  yStart,
                                  xStart + CellSize * i,
                                  yStart + CellSize * 6 + 1,
                                  Color.Blue);
            }

            for (int j = 1; j < 6; j++)
            {
                graphics.DrawLine(xStart,
                                  yStart + j * CellSize,
                                  CellSize * connectGame.Width + xStart,
                                  yStart + j * CellSize,
                                  Color.Blue);
            }

            for (int x = 0; x < connectGame.Width; x++)
            {
                for (int y = 0; y < connectGame.Height; y++)
                {
                    if (connectGame.GameField[x, y] == 0)
                    {
                        continue;
                    }
                    DrawChipOnBoard(x, y, connectGame.GameField[x, y] == 1);
                    //DrawChipOnBoard(x, y, x % 2 == 0);
                }
            }

            //Game state
            switch (connectGame.GameState)
            {
            case Span4Game.GameStateType.Draw:
                graphics.DrawText(2, 0, "Draw", Color.White);
                break;

            case Span4Game.GameStateType.Player1Wins:
                graphics.DrawText(2, 0, "Player 1 Wins!", Color.White);
                break;

            case Span4Game.GameStateType.Player2Wins:
                graphics.DrawText(2, 0, "Player 2 Wins!", Color.White);
                break;

            case Span4Game.GameStateType.Player1Turn:
                DrawPreviewChip(currentColumn, true);
                break;

            case Span4Game.GameStateType.Player2Turn:
                DrawPreviewChip(currentColumn, false);
                break;
            }

            //Draw side display

            /*   int xText = 150;
             * graphics.DrawText(xText, 0, "Span4!");
             *
             * graphics.DrawText(xText, 18, "Player 1");
             * DrawChip(xText + 40, 21, 3, true);
             *
             * graphics.DrawText(xText, 27, "Player 2");
             * DrawChip(xText + 40, 30, 3, false);
             *
             * graphics.DrawText(xText, 45, "Score:");
             * graphics.DrawText(xText, 54, $"{connectGame.Player1Wins} to {connectGame.Player2Wins}");  */
        }
Exemplo n.º 26
0
        public MeadowApp()
        {
            //CreateSpiDisplay();
            CreateI2CDisplay();

            Console.WriteLine("Fill display");
            for (int x = 0; x < display.Width; x++)
            {
                for (int y = 0; y < display.Height; y++)
                {
                    display.DrawPixel(x, y, true);
                }
            }
            display.Show();
            Thread.Sleep(2000);

            /*   Console.WriteLine("Test display API");
             * TestRawDisplayAPI();
             * Thread.Sleep(3000); */


            Console.WriteLine("Create Graphics Library");
            TestDisplayGraphicsAPI();
            Thread.Sleep(2000);

            Console.WriteLine("Test Inversion");
            for (int x = 0; x < 64; x++)
            {
                for (int y = 0; y < 12; y++)
                {
                    display.InvertPixel(x, y);
                }
            }
            display.Show();
            Thread.Sleep(3000);

            Console.WriteLine("Check offsets");

            graphics.Clear();
            graphics.DrawRectangle(0, 0, (int)display.Width, (int)display.Height, true, false);
            graphics.Show();

            Thread.Sleep(3000);

            for (int x = 0; x < display.Width; x++)
            {
                Console.WriteLine($"X: {x}");
                graphics.Clear();

                graphics.DrawLine(x, 0, x, (int)display.Height - 1, true);

                graphics.Show();

                Thread.Sleep(50);
            }

            for (int y = 0; y < display.Height; y++)
            {
                Console.WriteLine($"Y: {y}");
                graphics.Clear();

                graphics.DrawLine(0, y, (int)display.Width - 1, y, true);

                graphics.Show();

                Thread.Sleep(50);
            }

            Thread.Sleep(Timeout.Infinite);
        }
Exemplo n.º 27
0
        int BenchLines(int num)
        {
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            graphics.Stroke = 1;
            graphics.Clear(true);
            for (int i = 1; i < num; i++)
            {
                graphics.DrawLine(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayWidth), rand.Next(displayHeight), RandColor());
                graphics.Show();
            }
            int l1 = (int)stopWatch.Elapsed.TotalMilliseconds;

            Console.WriteLine($"{num} lines {l1}ms");
            stopWatch.Restart();

            graphics.Stroke = 2;
            graphics.Clear(true);
            for (int i = 1; i < num; i++)
            {
                graphics.DrawLine(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayWidth), rand.Next(displayHeight), RandColor());
                graphics.Show();
            }
            int l2 = (int)stopWatch.Elapsed.TotalMilliseconds;

            Console.WriteLine($"{num} 2x lines {l2}ms");
            stopWatch.Restart();

            graphics.Stroke = 3;
            graphics.Clear(true);
            for (int i = 1; i < num; i++)
            {
                graphics.DrawLine(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayWidth), rand.Next(displayHeight), RandColor());
                graphics.Show();
            }
            int l3 = (int)stopWatch.Elapsed.TotalMilliseconds;

            Console.WriteLine($"{num} 3x lines {l3}ms");
            stopWatch.Restart();

            graphics.Stroke = 2;
            graphics.Clear(true);
            for (int i = 1; i < num; i++)
            {
                graphics.DrawHorizontalLine(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayWidth), RandColor());
                graphics.Show();
            }
            int lh = (int)stopWatch.Elapsed.TotalMilliseconds;

            Console.WriteLine($"{num} horz lines {lh}ms");
            stopWatch.Restart();

            graphics.Stroke = 2;
            graphics.Clear(true);
            for (int i = 1; i < num; i++)
            {
                graphics.DrawVerticalLine(rand.Next(displayWidth), rand.Next(displayHeight), rand.Next(displayWidth), RandColor());
                graphics.Show();
            }
            int lv = (int)stopWatch.Elapsed.TotalMilliseconds;

            Console.WriteLine($"{num} vert lines {lh}ms");
            stopWatch.Restart();

            stopWatch.Stop();

            return(l1 + l2 + l3 + lh + lv);
        }
Exemplo n.º 28
0
        void DrawGame()
        {
            //draw gameboard
            graphics.DrawRectangle(0, 9, 64, 55, true, false);

            for (int i = 1; i < 7; i++)
            {
                graphics.DrawLine(CellSize * i,
                                  yStart,
                                  CellSize * i,
                                  yStart + CellSize * 6 + 1,
                                  true);
            }

            for (int j = 1; j < 6; j++)
            {
                graphics.DrawLine(xStart,
                                  yStart + j * CellSize,
                                  63 + xStart,
                                  yStart + j * CellSize,
                                  true);
            }

            for (int x = 0; x < connectGame.Width; x++)
            {
                for (int y = 0; y < connectGame.Height; y++)
                {
                    if (connectGame.GameField[x, y] == 0)
                    {
                        continue;
                    }
                    DrawChipOnBoard(x, y, connectGame.GameField[x, y] == 1);
                }
            }

            //Game state
            switch (connectGame.GameState)
            {
            case Span4Game.GameStateType.Draw:
                graphics.DrawText(2, 0, "Draw");
                break;

            case Span4Game.GameStateType.Player1Wins:
                graphics.DrawText(2, 0, "Player 1 Wins!");
                break;

            case Span4Game.GameStateType.Player2Wins:
                graphics.DrawText(2, 0, "Player 2 Wins!");
                break;

            case Span4Game.GameStateType.Player1Turn:
                DrawPreviewChip(currentColumn, true);
                break;

            case Span4Game.GameStateType.Player2Turn:
                DrawPreviewChip(currentColumn, false);
                break;
            }

            //Draw side display
            int xText = 75;

            graphics.DrawText(xText, 0, "Span4!");

            graphics.DrawText(xText, 18, "Player 1");
            DrawChip(115, 21, true);

            graphics.DrawText(xText, 27, "Player 2");
            DrawChip(115, 30, false);

            graphics.DrawText(xText, 45, "Score:");
            graphics.DrawText(xText, 54, $"{connectGame.Player1Wins} to {connectGame.Player2Wins}");
        }
Exemplo n.º 29
0
        void DrawShapes()
        {
            while (true)
            {
                Random rand = new Random();

                graphics.Clear(true);

                int radius  = 100;
                int originX = this.displayWidth / 2;
                int originY = this.displayHeight / 2;

                for (int i = 1; i < 5; i++)
                {
                    graphics.DrawCircle
                    (
                        centerX: originX,
                        centerY: originY,
                        radius: radius,
                        color: Color.FromRgb(
                            rand.Next(255), rand.Next(255), rand.Next(255)),
                        filled: true
                    );

                    graphics.Show();
                    radius -= 30;
                }

                int sideLength = 30;

                for (int i = 1; i < 5; i++)
                {
                    graphics.Stroke = 4;

                    graphics.DrawRectangle
                    (
                        xLeft: (displayWidth - sideLength) / 2,
                        yTop: (displayHeight - sideLength) / 2,
                        width: sideLength,
                        height: sideLength,
                        color: Color.FromRgb(
                            rand.Next(255), rand.Next(255), rand.Next(255))
                    );

                    graphics.Show();
                    sideLength += 60;
                }

                // horizontal
                graphics.DrawLine(0, displayHeight / 2, displayWidth, displayHeight / 2,
                                  Color.FromRgb(rand.Next(255), rand.Next(255), rand.Next(255)));

                graphics.Show();

                //vertical
                graphics.DrawLine(displayWidth / 2, 0, displayWidth / 2, displayHeight,
                                  Color.FromRgb(rand.Next(255), rand.Next(255), rand.Next(255)));

                graphics.Show();

                // diagonal lt_rb
                graphics.DrawLine(0, 0, displayWidth, displayHeight,
                                  Color.FromRgb(rand.Next(255), rand.Next(255), rand.Next(255)));

                graphics.Show();

                // diagonal lb_rt
                graphics.DrawLine(0, displayHeight, displayWidth, 0,
                                  Color.FromRgb(rand.Next(255), rand.Next(255), rand.Next(255)));

                graphics.Show();

                Thread.Sleep(5000);
            }
        }
Exemplo n.º 30
0
        void ShapeTest()
        {
            graphicsLib.Clear();

            graphicsLib.DrawCircle(60, 60, 20, Color.Purple);
            graphicsLib.DrawRectangle(10, 10, 30, 60, Color.Red);
            graphicsLib.DrawTriangle(20, 20, 10, 70, 60, 60, Color.Green);

            graphicsLib.DrawCircle(90, 60, 20, Color.Cyan, true);
            graphicsLib.DrawRectangle(100, 100, 30, 10, Color.Yellow, true);
            graphicsLib.DrawTriangle(120, 20, 110, 70, 160, 60, Color.Pink, true);

            graphicsLib.DrawLine(10, 120, 110, 130, Color.SlateGray);

            graphicsLib.Show();
        }