G120 LCD image switching

Hi,

I have a NewHaven LCD panel connected to the G120 and have configured it to run ok. I can put images on the display ok, but when outputting bitmaps there appears to be tearing. It’s almost like it takes time to render a Bitmap

Any ideas on the best way to quickly switch between two images without tearing?

Currently doing this:



            // flash test
            Bitmap bon = new Bitmap(Resources.GetBytes(Resources.BinaryResources._6a), Bitmap.BitmapImageType.Jpeg);
            Bitmap boff = new Bitmap(Resources.GetBytes(Resources.BinaryResources._6), Bitmap.BitmapImageType.Jpeg);
            while (true)
            {
                Thread.Sleep(200);

                lcd.DrawImage(0, 0, bon, 0, 0, 800, 480);
                lcd.Flush();

                Thread.Sleep(200);

                lcd.DrawImage(0, 0, boff, 0, 0, 800, 480);
                lcd.Flush();
            }
 

Sleep time doesn’t make much difference.

Thanks

Maybe your clock is not set correctly? What is it? What is the display resolution?

@ Gus - The panel is NHD-5.0-800480TF-ATXL-CTP

I have a pixel clock rate set to 20,000 which I assume maps to 20MHz.

Resolution is 800x480 which is similar to the GHI CP7 which is what I select as the base display in the settings and then modify the various Porch/Polarity etc. to work.

All seem correct so I am not sure. It is very quick on smaller displays. I do not remember how it was on the cp7. Maybe somebody else can try.

Bumped it up to 29MHz and it still gets a tear line. Kind of like when there is no display sync on an LCD and the image is changing mid draw.

Can you show the LCD settings you use? I use this display in a number of systems without any issues at all.

How long are your cables connecting it?

Can you show a picture of the tearing?

Hi Dave,

Settings are in the attachment. Cables are standard screen cables and then custom PCB with pretty short traces from G120 to the header.

Will try and capture a screenshot of tearing and upload in a minute.

Thanks, Dave

Sample of it tearing can be seen here:

[url]https://1drv.ms/v/s!AgGg4fyu1VonwPtxOQKGWseyjVIafA[/url]

Note: This is two of the same image, with a different brightness level. Same thing happens with different images.

This is an easy fix. The CP7 timings are all wrong for the 5".

Use this code in your programme. Call it during startup and it will make the changes and reboot. If the settings are not changed it will remain the same and run normally. This is ideal as the settings get wiped when you update the firmware.


private static void InitDisplay()
{
    //
    // Because we might reflash, we have to reprogramme the Display Driver
    // as this will be wiped out when we reflash the firmware.
    //
    Display.Width = 800;
    Display.Height = 480;
    Display.HorizontalSyncPulseWidth = 48;
    Display.HorizontalBackPorch = 88;
    Display.HorizontalFrontPorch = 40;
    Display.VerticalSyncPulseWidth = 3;
    Display.VerticalBackPorch = 32;
    Display.VerticalFrontPorch = 13;
    Display.PixelClockRateKHz = 25000;
    Display.OutputEnableIsFixed = true;
    Display.OutputEnablePolarity = true;
    Display.HorizontalSyncPolarity = true;
    Display.VerticalSyncPolarity = true;
    Display.PixelPolarity = false;
    Display.Type = Display.DisplayType.Lcd;

    if (Display.Save())      // Reboot required?
    {
        PowerState.RebootDevice(false);
    }
}

Hi Dave,

Thanks. I have just loaded that but it looks the same to me.

Any other ideas?

Thanks, Dave

[quote=“dpilcher”]4
Thanks. I have just loaded that but it looks the same to me.
[/quote]

How have you got the LCD connected up? How long are your cables?

Did it reboot the first time you called the function?

The panel comes with cables built in. They are around 2-3 inches. These go to a SMT header and traces are about an inch to the module.

It appears to reboot on every startup now, which is odd as I’d expect the settings to remain saved. But if I use Fez Config to save bad settings it does reboot to a “working” screen, so they are being applied. I can read them from FezConfig too, although very oddly that sometimes reads old values and sometimes new. It is almost as if the firmware has two places the settings are maintained and depending on the read time, you get the ‘previously saved from fez’ settings and other times the ‘code assigned’ settings.

My code should only reboot on change. The first time it runs it will make the changes and then any subsequent run should just bypass the reboot option.

I’ve seen Fezconfig have issues reading and sometime needs 2 or 3 times to pick up the LCD settings.

What if you use Fezconfig to use the settings I gave you?