Third Preview of TinyCLR OS Core Features

This is for TE35 we tested.

For different screen that supported by GHI, you can use their setting same as FEZ config shows.


static void TestLCD()
        {
            var displayController = DisplayController.GetDefault();

            displayController.ApplySettings(new LcdControllerSettings { Width = 320, Height = 240, HorizontalBackPorch = 27, HorizontalFrontPorch = 51, HorizontalSyncPolarity = false, HorizontalSyncPulseWidth = 41, OutputEnableIsFixed = true, OutputEnablePolarity = true, PixelClockRate = 15000000, PixelPolarity = true, VerticalBackPorch = 8, VerticalFrontPorch = 16, VerticalSyncPolarity = false, VerticalSyncPulseWidth = 10 });




            var background = Resources.GetBitmap(Resources.BitmapResources.Background);
            var font = Resources.GetFont(Resources.FontResources.small);
            var screen = Graphics.FromHdc(displayController.Hdc);

            screen.DrawLine(new Pen(Color.White, 2), 10, 10, 30, 10);
            screen.Flush();

            Thread.Sleep(1000);

            screen.Clear(Color.Black);
            screen.Flush();

            Thread.Sleep(1000);

            screen.DrawImage(background, 0, 40);
            screen.FillEllipse(new SolidBrush(Color.FromArgb(100, 0xFF, 0, 0)), 0, 0, 100, 100);
            screen.FillRectangle(new SolidBrush(Color.FromArgb(100, 0, 0, 0xFF)), 0, 100, 100, 100);
            screen.DrawEllipse(new Pen(Color.Blue), 100, 0, 100, 100);
            screen.DrawRectangle(new Pen(Color.Red), 100, 100, 100, 100);
            screen.DrawLine(new Pen(Color.Green, 5), 250, 0, 220, 240);
            screen.DrawString("Hello, world", font, new SolidBrush(Color.White), 10, 220);

            var i = 0;
            screen.DrawLine(new Pen(Color.Black, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.White, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Gray, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Red, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Green, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Blue, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Yellow, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Purple, 4), 260 + i, 10, 260 + i, 50); i += 4;
            screen.DrawLine(new Pen(Color.Teal, 4), 260 + i, 10, 260 + i, 50); i += 4;

            screen.Flush();

            using (var bmp = new Bitmap(2, 2))
            {
                var graphics = Graphics.FromImage(bmp);

                graphics.DrawLine(new Pen(Color.White, 1), 0, 0, 1, 0);

                using (var stream = new MemoryStream())
                {
                    bmp.Save(stream, ImageFormat.MemoryBmp);

                    var byteArray = stream.ToArray();
                }
            }

        }
2 Likes