Пример #1
0
        void TestILI9163()
        {
            Console.WriteLine("Clear display");

            // Drawing natively in the display
            display.ClearScreen(250);

            Console.WriteLine("Refresh");

            display.Refresh();

            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();
        }
Пример #2
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);
        }
Пример #3
0
        static void Draw8bppGrayscaleBitmap(int x, int y, byte[] data, int width, int height, ILI9163 display)
        {
            byte c;

            //test by drawing to screen
            for (int j = 0; j < height; j++)
            {
                for (int k = 0; k < width; k++)
                {
                    c = data[k + j * width];

                    display.DrawPixel(x + k, y + height - j, c, c, c);
                }
            }
        }
Пример #4
0
        static void DrawBitmap(int x, int y, byte[] data, ILI9163 display)
        {
            byte r, g, b;

            int offset = 14 + data[14];

            int width  = data[18];
            int height = data[22];

            for (int j = 0; j < height; j++)
            {
                for (int i = 0; i < width; i++)
                {
                    b = data[i * 3 + j * width * 3 + offset];
                    g = data[i * 3 + j * width * 3 + offset + 1];
                    r = data[i * 3 + j * width * 3 + offset + 2];

                    display.DrawPixel(x + i, y + height - j, r, g, b);
                }
            }
        }