7inch display rotate

Hi, Any feedback is appreciated.
I am rotating the display to have it as a portrait.
But it is not working, I tried different thing but it did not help
Has anyone tried it

            displayController.SetConfiguration(new ParallelDisplayControllerSettings
            {                       //Use this to test
                //Width = 800,
                //Height = 480,
                Width = 480,
                Height = 800,
                DataFormat = DisplayDataFormat.Rgb565,
                Orientation = DisplayOrientation.Degrees270,
                PixelClockRate = 33000000,
                PixelPolarity = false,
                DataEnablePolarity = false,
                DataEnableIsFixed = false,
                HorizontalFrontPorch = 40,
                HorizontalBackPorch = 40,
                HorizontalSyncPulseWidth = 48,
                HorizontalSyncPolarity = false,
                VerticalFrontPorch = 13,
                VerticalBackPorch = 31,
                VerticalSyncPulseWidth = 1,
                VerticalSyncPolarity = false,
            });

I can’t remember but I think you do not swap width and height. Only rotate.

I tried both. Once you rotate half the screen is black, something is wrong. I think it does not cover unto 800 pixels it stops at 480. Would you check on your side please

When you draw, do you use a 480x800 bitmap? Can you share a simple sample code please?

Code…

using GHIElectronics.TinyCLR.Devices.Display;
using Color = GHIElectronics.TinyCLR.UI.Media.Color;
using GHIElectronics.TinyCLR.UI;
using GHIElectronics.TinyCLR.UI.Media;
using GHIElectronics.TinyCLR.UI.Controls;

namespace SCTouch
{
    class Program : Application
    {
        static public System.Drawing.Font font_t = Resources.GetFont(Resources.FontResources.Text_mb);
        static public int LCD_Height = 0;
        static public int LCD_Width = 0;
        static public Program app;
        public static Canvas canvas = null;
        static public Color C_TealD = Color.FromRgb(0, 102, 102);

        public Program(DisplayController d) : base(d)
        {
        }

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

            displayController.SetConfiguration(new ParallelDisplayControllerSettings
            {
                Width = 480,
                Height = 800,
                DataFormat = DisplayDataFormat.Rgb565,
                Orientation = DisplayOrientation.Degrees270,
                PixelClockRate = 33000000,
                PixelPolarity = false,
                DataEnablePolarity = false,
                DataEnableIsFixed = false,
                HorizontalFrontPorch = 40,
                HorizontalBackPorch = 40,
                HorizontalSyncPulseWidth = 48,
                HorizontalSyncPolarity = false,
                VerticalFrontPorch = 13,
                VerticalBackPorch = 31,
                VerticalSyncPulseWidth = 1,
                VerticalSyncPolarity = false,
            });

            LCD_Height = displayController.ActiveConfiguration.Height;
            LCD_Width = displayController.ActiveConfiguration.Width;

            displayController.Enable();

            var brush_w = new System.Drawing.SolidBrush(System.Drawing.Color.FromArgb(0xD3, 0xD3, 0xD3));   //Grey
            Resources.BitmapResources img_ID = Resources.BitmapResources.Pelican_R_1;

            var image = Resources.GetBitmap(img_ID);
            var screen = System.Drawing.Graphics.FromHdc(displayController.Hdc);

            screen.Clear();
            screen.DrawImage(image, 0, 0);
            screen.DrawString($"Test", font_t, brush_w, 10, 10);
            screen.Flush();

            app = new Program(displayController);
            app.Run(Program.CreateWindow(displayController));
        }

        private static Window CreateWindow(DisplayController display)
        {
            Window window = new Window();

            window.Height = (int)display.ActiveConfiguration.Height;
            window.Width = (int)display.ActiveConfiguration.Width;

            window.Background = new SolidColorBrush(C_TealD);
            window.Visibility = Visibility.Visible;
            window.Child = Elements();

            return window;
        }
        private static UIElement Elements()
        {
            canvas = new Canvas();

            return canvas;
        }
    }
}

I guess this tool is not used nowadays to set LCD settings

When you draw, do you use a 480x800 bitmap? Can you share a simple sample code please?

Yes…I took the same picture and rotated it in paint

I think this is where the problem is. The display configuration needs to be same as the display, 800x480 but the window need to be 480x800 because you rotated it.

1 Like

It did not help, you can see the below to display a splash screen is also cutoff; this is before the window

Which board did you use ? and which display ?

Hi, sorry for delay answer.

I am not sure if your code here is the one you are using to test. if so it doesn’t work because:

  • No backlight pin, unless your lcd doesn’t need it.
  • 800x480 config: I am not sure if it is right configuration. Does it work when no rotation?
  • You run UI after drawing text, image so UI will overwrite them
  • Last, and very important:,
screen.DrawImage(image, 0, 0);
screen.DrawString($"Test", font_t, brush_w, 10, 10);

When rotate 270, x=0 (or x=10), y = 0 (or y = 10) will be out of the screen (at the bottom) that you can’t see.
To see the text, try with this

screen.DrawString($"Test 270", font_t, brush_w, 740, 250);   (x = 740, y = 250).

We are not sure what screen you are using, below is 800x480 for our UD700-Dev and should work with most LCD 800x480.

var displayController = DisplayController.GetDefault();

displayController.SetConfiguration(new ParallelDisplayControllerSettings
{
    Width = 800,
    Height = 480,
    DataFormat = DisplayDataFormat.Rgb565,
    Orientation = DisplayOrientation.Degrees270, //Rotate display.
    PixelClockRate = 40000000,
    PixelPolarity = false,
    DataEnablePolarity = false,
    DataEnableIsFixed = false,
    HorizontalFrontPorch = 200,
    HorizontalBackPorch = 1,
    HorizontalSyncPulseWidth = 87,
    HorizontalSyncPolarity = true,
    VerticalFrontPorch = 101,
    VerticalBackPorch = 29,
    VerticalSyncPulseWidth = 3,
    VerticalSyncPolarity = true
});

We just run the test and it works, you must have same result :).

Custom board with 800x480 7 inch display

I have 800x480 7inch display and if not rotated works ok.
When 270 degree rotated. I can see the text at 10,10 because the height is 800

Is it possible to just draw the items rotated 270 degrees in the first place?

The timing data has to match with the default orientation of the LCD which is in the case of the 800x480 horizontal with 800 as the width. Some LCD panels used with phones and tablets are portrait as default so have different timing.

Check the data sheet for your LCD to get the correct timing but it sounds like the LCD works in landscape mode but fails with rotate which is a software function that should handle this in the background.

Out of curiosity, does the display work with 180 deg rotation? If it does, I suspect the issue is in the display drivers.

180 rotation flips the image and it look good
I do not think it is a LCD issue

I think it is a driver issue, it does not allow height more than 480 pixels. When I rotate the height is 800 pixels.
Hi @Dat I know you are helping me, but can you try on your board and see

Finally I have something working

Width = 800,
Height = 800,
Orientation = DisplayOrientation.Degrees270, //Rotate display.

The screen update is slow

I tried increasing, but it did not help
PixelClockRate = 50000000,

I thought you get it working, what issue do you have now?

Yes because the rotation is done using software. The system runs at the same speed but only when you flush the screen then the software starts moving the pixels.

Then is it possible not to rotate and create the window rotated
Will it also end up being the same speed