Пример #1
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();
        }
Пример #2
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();
        }
Пример #3
0
        public void CountDown()
        {
            int y = 30;

            for (int i = 3; i > 0; i--)
            {
                display.DrawRectangle(114, y, 12, 16, Color.Black, true);
                display.DrawText(114, y, $"{i}", Orange);
                display.Show();
            }
            display.DrawRectangle(114, y, 12, 16, Color.Black, true);
        }
Пример #4
0
        public DisplayController(St7789 display)
        {
            graphics             = new GraphicsLibrary(display);
            graphics.CurrentFont = new Font12x20();
            graphics.Stroke      = 3;

            graphics.Clear();

            graphics.DrawRectangle(0, 0, 240, 240, Color.White, true);

            string plant   = "Plant";
            string monitor = "Monitor";

            graphics.CurrentFont = new Font12x16();
            graphics.DrawText((240 - (plant.Length * 24)) / 2, 80, plant, Color.Black, GraphicsLibrary.ScaleFactor.X2);
            graphics.DrawText((240 - (monitor.Length * 24)) / 2, 130, monitor, Color.Black, GraphicsLibrary.ScaleFactor.X2);

            graphics.Show();
        }
Пример #5
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();
        }
Пример #6
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            onboardLed = new RgbPwmLed(device: Device,
                                       redPwmPin: Device.Pins.OnboardLedRed,
                                       greenPwmPin: Device.Pins.OnboardLedGreen,
                                       bluePwmPin: Device.Pins.OnboardLedBlue,
                                       3.3f, 3.3f, 3.3f,
                                       Meadow.Peripherals.Leds.IRgbLed.CommonType.CommonAnode);

            Console.WriteLine("Create Display with SPI...");

            var config = new SpiClockConfiguration(12000, SpiClockConfiguration.Mode.Mode0);

            var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            ssd1309 = new Ssd1309
                      (
                device: Device,
                spiBus: bus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            Console.WriteLine("Create GraphicsLibrary...");

            graphics = new GraphicsLibrary(ssd1309)
            {
                CurrentFont = new Font8x12(),
            };

            graphics.Clear();
            graphics.DrawText(0, 0, "Loading Menu");
            graphics.Show();

            CreateMenu(graphics);

            Console.WriteLine("Create buttons...");

            up          = new PushButton(Device, Device.Pins.D14, ResistorMode.Disabled);
            up.Clicked += Up_Clicked;

            left          = new PushButton(Device, Device.Pins.D11, ResistorMode.Disabled);
            left.Clicked += Left_Clicked;

            right          = new PushButton(Device, Device.Pins.D10, ResistorMode.Disabled);
            right.Clicked += Right_Clicked;

            down          = new PushButton(Device, Device.Pins.D12, ResistorMode.Disabled);
            down.Clicked += Down_Clicked;

            menu.Enable();
        }
Пример #7
0
        public HackKitDisplay()
        {
            var config = new SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode3);

            _spiBus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            _display = new St7789(
                device: Device,
                spiBus: _spiBus,
                chipSelectPin: null,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00,
                width: 240, height: 240);

            _graphics = new GraphicsLibrary(_display);

            // my display is upside down"s
            _graphics.Rotation = GraphicsLibrary.RotationType._180Degrees;

            Console.WriteLine("Clear display");
            //_display.ClearScreen(250);
            //_display.Refresh();

            _graphics.Clear(true);

            //Console.WriteLine("Draw lines");
            //for (int i = 0; i < 30; i++) {
            //    _display.DrawPixel(i, i, true);
            //    _display.DrawPixel(30 + i, i, true);
            //    _display.DrawPixel(60 + i, i, true);
            //}

            _graphics.CurrentFont = new Font12x16();
            _graphics.DrawText(4, 4, "current temp: 26º", Color.FromHex("24abe3"));
            _graphics.DrawText(4, 20, "desired temp: 24º", Color.FromHex("EF7D3B"));
            _graphics.DrawText(4, 40, "all temps Canadian", Color.White);
            _graphics.Show();

            //Console.WriteLine("Show()");
            //_display.Show();
            //Console.WriteLine("shown.");
        }
Пример #8
0
        void TestDisplayGraphicsAPI()
        {
            graphics = new GraphicsLibrary(display);

            graphics.Clear();
            graphics.CurrentFont = new Font8x12();
            graphics.DrawText(0, 0, "Meadow F7");
            graphics.DrawRectangle(5, 14, 30, 10, true);

            graphics.Show();
        }
Пример #9
0
        public void DrawText(string text)
        {
            graphicsLibrary.Clear();
            graphicsLibrary.DrawRectangle(0, 0, 128, 32);
            graphicsLibrary.CurrentFont = new Font8x12();

            int x = (128 - (text.Length * 8)) / 2;

            graphicsLibrary.DrawText(x, 12, text);
            graphicsLibrary.Show();
        }
Пример #10
0
        public MeadowApp()
        {
            Console.WriteLine("Start...");
            var rgbLed = new RgbLed(
                Device,
                Device.Pins.OnboardLedRed,
                Device.Pins.OnboardLedGreen,
                Device.Pins.OnboardLedBlue);

            rgbLed.SetColor(RgbLed.Colors.Red);

            Console.Write("Initializing I2C...");
            displayI2C              = new Ssd1306(Device.CreateI2cBus(), 60, Ssd1306.DisplayType.OLED128x32);
            graphicsI2C             = new GraphicsLibrary(displayI2C);
            graphicsI2C.CurrentFont = new Font8x12();
            graphicsI2C.Clear();
            graphicsI2C.Stroke = 1;
            graphicsI2C.DrawRectangle(0, 0, 128, 32);
            graphicsI2C.DrawText(5, 12, "I2C WORKING");
            graphicsI2C.Show();
            Console.WriteLine("done");

            Console.Write("Initializing SPI...");
            displaySPI = new Ili9163(
                device: Device,
                spiBus: Device.CreateSpiBus(),
                chipSelectPin: Device.Pins.D14,
                dcPin: Device.Pins.D11,
                resetPin: Device.Pins.D10,
                width: 128, height: 160);
            graphicsSPI          = new GraphicsLibrary(displaySPI);
            graphicsSPI.Rotation = GraphicsLibrary.RotationType._90Degrees;
            graphicsSPI.Clear();
            graphicsSPI.Stroke = 1;
            graphicsSPI.DrawRectangle(0, 0, 160, 128);
            graphicsSPI.CurrentFont = new Font8x12();
            graphicsSPI.DrawText(7, 7, "SPI WORKING!", Color.White);
            graphicsSPI.Show();
            Console.WriteLine("done");

            temperatures = new List <AnalogTemperature>
            {
                new AnalogTemperature(Device, Device.Pins.A00, AnalogTemperature.KnownSensorType.LM35),
                new AnalogTemperature(Device, Device.Pins.A01, AnalogTemperature.KnownSensorType.LM35),
                new AnalogTemperature(Device, Device.Pins.A02, AnalogTemperature.KnownSensorType.LM35),
                new AnalogTemperature(Device, Device.Pins.A03, AnalogTemperature.KnownSensorType.LM35),
                new AnalogTemperature(Device, Device.Pins.A04, AnalogTemperature.KnownSensorType.LM35),
                new AnalogTemperature(Device, Device.Pins.A05, AnalogTemperature.KnownSensorType.LM35),
            };

            rgbLed.SetColor(RgbLed.Colors.Green);

            TestTemperatures();
        }
Пример #11
0
        private void DrawText(string message)
        {
            if (display != null)
            {
                display.Clear(true);
                display.CurrentFont = new Font8x8();
                display.DrawText(0, 0, 0, message);
                display.Show();
            }

            Debug.Print(message);
        }
Пример #12
0
        void TestST7565()
        {
            Console.WriteLine("TestST7565...");

            // 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, true);
            graphics.DrawText(5, 5, "ST7565");
            graphics.Show();
        }
Пример #13
0
        void ScrollText()
        {
            Thread.Sleep(2000);
            Console.WriteLine("ScrollText...");

            dotStarWing.Clear();

            string       text   = "MEADOW";
            List <Color> colors = new List <Color>();

            colors.Add(Color.Red);
            colors.Add(Color.White);
            colors.Add(Color.Blue);
            colors.Add(Color.Green);
            colors.Add(Color.Yellow);
            colors.Add(Color.Purple);

            int x          = 0;
            int colorIndex = 0;
            int scollWidth = (int)(-1 * (dotStarWing.Width + graphics.CurrentFont.Width + 8));
            int resetWidth = (int)(dotStarWing.Width + 2);

            while (true)
            {
                graphics.Clear();
                int offset = 0;
                colorIndex = 0;

                foreach (var chr in text)
                {
                    graphics.DrawText(x + offset, 0, chr.ToString(), colors[colorIndex]);
                    offset += graphics.CurrentFont.Width;
                    colorIndex++;

                    if (colorIndex >= colors.Count)
                    {
                        colorIndex = 0;
                    }
                }

                graphics.Show();

                x--;

                if (x < scollWidth)
                {
                    x = resetWidth;
                }

                Thread.Sleep(175);
            }
        }
Пример #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);
        }
Пример #15
0
        async Task TestTemperatures()
        {
            while (true)
            {
                int   tempIndex = 0;
                float?temp;

                for (int i = 0; i < 6; i++)
                {
                    temp = null;

                    if (tempIndex < temperatures.Count)
                    {
                        if ($"A0{i}" == temperatures[tempIndex].AnalogInputPort.Pin.ToString())
                        {
                            var conditions = await temperatures[tempIndex].Read();
                            temp = conditions.Temperature;
                        }
                    }

                    if (temp == null)
                    {
                        graphicsSPI.DrawRectangle(7, i * 17 + 25, 130, 12, Color.Black, true);
                        graphicsSPI.DrawText(7, i * 17 + 25, $"A0{i}: INACTIVE", Color.White);
                    }
                    else
                    {
                        graphicsSPI.DrawRectangle(7, i * 17 + 25, 130, 12, Color.Black, true);
                        graphicsSPI.DrawText(7, i * 17 + 25, $"{temperatures[tempIndex].AnalogInputPort.Pin}: {temp}", Color.White);
                        tempIndex++;
                    }

                    graphicsSPI.Show();
                    Thread.Sleep(100);
                }

                Thread.Sleep(3000);
            }
        }
Пример #16
0
        private void Sensor_Updated(object sender, Meadow.Peripherals.Sensors.Distance.DistanceConditionChangeResult e)
        {
            if (e.New == null || e.New.Distance == null)
            {
                return;
            }

            Console.WriteLine($"{e.New.Distance.Value}mm");

            graphics.DrawRectangle(0, 0, 135, 33, Color.Black, true);
            graphics.DrawText(0, 0, $"{e.New.Distance.Value}mm", Color.White, GraphicsLibrary.ScaleFactor.X2);
            graphics.Show();
        }
Пример #17
0
        private void DistanceUpdated(object sender, DistanceConditionChangeResult e)
        {
            if (e.New == null || e.New.Distance == null)
            {
                return;
            }

            Console.WriteLine($"{e.New.Distance.Value}mm");

            canvas.DrawRectangle(70, 90, 144, 40, Color.Black, true);
            canvas.DrawText(70, 90, $"{e.New.Distance.Value}mm", Color.White, GraphicsLibrary.ScaleFactor.X2);
            canvas.Show();
        }
Пример #18
0
        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);
        }
Пример #19
0
        private void DrawLabel(int x, int y, string text, FontBase font, Meadow.Foundation.Color?color)
        {
            FontBase oldFont = null;

            if (font != null)
            {
                oldFont = _graphicsLibrary.CurrentFont;
                _graphicsLibrary.CurrentFont = font;
            }
            if (color.HasValue)
            {
                _graphicsLibrary.DrawText(x, y, text, color.Value);
            }
            else
            {
                _graphicsLibrary.DrawText(x, y, text);
            }
            if (oldFont != null)
            {
                _graphicsLibrary.CurrentFont = oldFont;
            }
        }
Пример #20
0
        void Initialize()
        {
            Console.WriteLine("Initialize hardware...");

            Console.WriteLine("Create Display with SPI...");

            var config = new Meadow.Hardware.SpiClockConfiguration(6000, SpiClockConfiguration.Mode.Mode0);

            var bus = Device.CreateSpiBus(Device.Pins.SCK, Device.Pins.MOSI, Device.Pins.MISO, config);

            display = new Ssd1309
                      (
                device: Device,
                spiBus: bus,
                chipSelectPin: Device.Pins.D02,
                dcPin: Device.Pins.D01,
                resetPin: Device.Pins.D00
                      );

            Console.WriteLine("Create Graphics Library...");

            graphics             = new GraphicsLibrary(display);
            graphics.Rotation    = GraphicsLibrary.RotationType._270Degrees;
            graphics.CurrentFont = new Font8x12();

            graphics.Clear();
            graphics.DrawText(0, 0, "Hello");
            graphics.Show();

            Console.WriteLine("Create buttons...");

            portLeft  = Device.CreateDigitalInputPort(Device.Pins.D12, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown);
            portUp    = Device.CreateDigitalInputPort(Device.Pins.D13, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown);
            portRight = Device.CreateDigitalInputPort(Device.Pins.D07, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown);
            portDown  = Device.CreateDigitalInputPort(Device.Pins.D11, InterruptMode.EdgeFalling, ResistorMode.InternalPullDown);

            portRight.Changed += PortRight_Changed;
            portLeft.Changed  += PortLeft_Changed;
            portUp.Changed    += PortUp_Changed;
            portDown.Changed  += PortDown_Changed;

            /*     btnUp = new PushButton(Device, Device.Pins.D13);
             *   btnLeft = new PushButton(Device, Device.Pins.D12);
             *   btnDown = new PushButton(Device, Device.Pins.D11);
             *   btnRight = new PushButton(Device, Device.Pins.D10);
             *
             *   btnUp.Clicked += BtnUp_Clicked;
             *   btnLeft.Clicked += BtnLeft_Clicked;
             *   btnDown.Clicked += BtnDown_Clicked;
             *   btnRight.Clicked += BtnRight_Clicked;  */
        }
Пример #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();
        }
Пример #22
0
        public static void Main()
        {
            Debug.Print(Resources.GetString(Resources.StringResources.String1));

            Initialize();

            graphics.DrawText(0, 0, "Snake!!");
            graphics.Show();

            Thread.Sleep(500);

            game = new SnakeGame(84, 48);

            StartGameLoop();
        }
Пример #23
0
        public MeadowApp()
        {
            Initialize();

            PixelWalk();

            FourCorners();

            Thread.Sleep(2000);

            graphics.Rotation = GraphicsLibrary.RotationType._90Degrees;
            graphics.Clear();
            graphics.DrawText(0, 0, "M F7");
            graphics.Show();
        }
Пример #24
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();
        }
Пример #25
0
        private void UpdateDisplay()
        {
            display.Clear();

            if (isPlaying)
            {
                display.DrawText(0, 0, "XBuzzer - Play!");
                display.DrawText(0, 20, "Count: " + count);
            }
            else
            {
                display.DrawText(0, 20, "Count: " + count);

                string time = "Time:" + timePlayed.Minutes + ":";
                if (timePlayed.Seconds < 10)
                {
                    time += "0";
                }
                time += timePlayed.Seconds;

                display.DrawText(0, 0, time);
            }
            display.Show();
        }
Пример #26
0
        int BenchText(int num)
        {
            List <FontBase> AvailbleFonts = new List <FontBase>()
            {
                new Font8x8(), new Font8x12(), new Font4x8(), new Font12x20(), new Font12x16()
            };

            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();

            graphics.Stroke = 1;
            int f1 = 0;

            foreach (var font in AvailbleFonts)
            {
                graphics.CurrentFont = font;
                graphics.Clear(true);
                for (int i = 1; i < num / 3; i++)
                {
                    graphics.DrawText(rand.Next(displayWidth), rand.Next(displayHeight),
                                      "Meadow F7", RandColor(), GraphicsLibrary.ScaleFactor.X1);
                    graphics.DrawText(rand.Next(displayWidth), rand.Next(displayHeight),
                                      "Meadow F7", RandColor(), GraphicsLibrary.ScaleFactor.X2);
                    graphics.DrawText(rand.Next(displayWidth), rand.Next(displayHeight),
                                      "Meadow F7", RandColor(), GraphicsLibrary.ScaleFactor.X3);
                    graphics.Show();
                }
                int f0 = (int)stopWatch.Elapsed.TotalMilliseconds;
                f1 += f0;
                Console.WriteLine($"{num} Text Font{font.Width}x{font.Height} {f0}ms");
                stopWatch.Restart();
            }

            return(f1);
        }
Пример #27
0
        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;
        }
Пример #28
0
        async Task Start()
        {
            var dateTime = await WeatherService.GetTimeAsync();

            Device.SetClock(new DateTime(
                                year: dateTime.Year,
                                month: dateTime.Month,
                                day: dateTime.Day,
                                hour: dateTime.Hour,
                                minute: dateTime.Minute,
                                second: dateTime.Second));

            while (true)
            {
                DateTime clock = DateTime.Now;

                graphics.Clear();

                graphics.DrawText(0, 1, $"{clock:hh}");
                graphics.DrawText(0, 9, $"{clock:mm}");
                graphics.DrawText(0, 17, $"{clock:ss}");
                graphics.DrawText(0, 25, $"{clock:tt}");

                if (showDate)
                {
                    graphics.Clear();

                    graphics.DrawText(0, 1, $"{clock:dd}");
                    graphics.DrawText(0, 9, $"{clock:MM}");
                    graphics.DrawText(0, 17, $"{clock:yy}");

                    graphics.DrawHorizontalLine(0, 24, 7, true);

                    float temperature = analogTemperature.Read().Result.Temperature.Value;

                    graphics.DrawText(0, 26, $"{(int) temperature}");
                }

                graphics.Show();
                Thread.Sleep(1000);
            }
        }
Пример #29
0
 private void GgaParser_OnPositionReceived(object sender, Meadow.Peripherals.Sensors.Location.Gnss.GnssPositionInfo location)
 {
     port.Close();
     graphics.Clear();
     graphics.DrawText(0, 0, "Latitude:");
     graphics.DrawText(0, 11, $"{location.Position.Latitude?.Degrees} {location.Position.Latitude?.Direction}");
     graphics.DrawText(0, 22, "Longitude:");
     graphics.DrawText(0, 33, $"{location.Position.Longitude?.Degrees} {location.Position.Longitude?.Direction}");
     graphics.DrawText(0, 44, "Altitude:");
     graphics.DrawText(0, 55, $"{location.Position.Altitude}m");
     graphics.Show();
     port.Open();
 }
Пример #30
0
        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();
        }