Esempio n. 1
0
        void ShowGrid()
        {
            int xOffset = 0;
            int yOffset = 0;
            int spacing = 15;

            for (int t = 0; t < 2000; t++)
            {
                display.Clear();

                for (int i = xOffset; i < display.Width; i += spacing)
                {
                    graphics.DrawVerticalLine(i, 0, (int)display.Height, true);
                }

                for (int j = yOffset; j < display.Height; j += spacing)
                {
                    graphics.DrawHorizontalLine(0, j, (int)display.Width, true);
                }

                xOffset = (xOffset + 1) % spacing;
                yOffset = (yOffset + 1) % spacing;

                display.Show();
            }
        }
Esempio n. 2
0
        void LineTest()
        {
            Console.WriteLine("Horizonal lines");

            graphics.Clear();

            for (int i = 1; i < 10; i++)
            {
                graphics.Stroke = i;
                graphics.DrawHorizontalLine(5, 20 * i, (int)(display.Width - 10), Color.Red);
            }
            graphics.Show();
            Thread.Sleep(1500);

            graphics.Clear();
            Console.WriteLine("Horizonal lines (negative)");
            for (int i = 1; i < 10; i++)
            {
                graphics.Stroke = i;
                graphics.DrawHorizontalLine((int)graphics.Width - 5, 20 * i, (int)(10 - graphics.Width), Color.Green);
            }
            graphics.Show();
            Thread.Sleep(1500);
            graphics.Clear();

            Console.WriteLine("Vertical lines");

            graphics.Clear();

            for (int i = 1; i < 10; i++)
            {
                graphics.Stroke = i;
                graphics.DrawVerticalLine(20 * i, 5, (int)(graphics.Height - 10), Color.Orange);
            }
            graphics.Show();
            Thread.Sleep(1500);
            graphics.Clear();

            Console.WriteLine("Vertical lines (negative)");
            for (int i = 1; i < 10; i++)
            {
                graphics.Stroke = i;
                graphics.DrawVerticalLine(20 * i, (int)(graphics.Height - 5), (int)(10 - graphics.Width), Color.Blue);
            }
            graphics.Show();
            Thread.Sleep(1500);
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
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);
        }