Read LCD memory

Hello,

Is there a way to read something from the LCD memory? I would like to read a small piece of the memory, replace it with something else and the replace it back again.

Kind regards

pjwl

Which LCD?

I have an 5.0 TFT display 800x480 connected to the Fez Cobra.

I have an picture on this screen and I would like to read about 50x50 pixels from this picture, then add an button on this place and after the button is pressed, I will copy the 50x50 pixels back, so the picture is okay.

The bitmap data is not avaible here in the code, so I must read it from the LCD memory of the EMX module.

Anyone has an idea?

Keep the image in a buffer, Bitmap.DrawImage the section you need out to a new image, copy back when done. See Pyxis 2 or Gadgetos for examples.

Thank you I will have a look to that

Hello,

I have looked into it but found not what I could use.

What I found was that you can read out of the LCD_BASE_UP register where the start adress is of the LCD memory. But how can I acces this LCD memory in C# or must I use the RLP?

If you want to access the internal LCD buffer you are going to need to use RLP.

I don’t understand why you do not have access to the bitmap which was originally used
to place the image on the screen. It seems to me you had access to it
at some time?

How about giving us the whole story? What are trying to do, and why are having a problem?

Hello,

It is for a little game for witch I thinking of, you must push the right buttons to see the picture behind it.

So I will draw an picture on the screen and then some buttons, but when the right button is pressed the data from the picture must be restored behind that button. So when i initalize i must read first the picture data from the position of the button into a buffer, so the restoring would be faster. Otherwise I must write the picture and then the buttons back, this could be seen on the screen and slower things down.

What library are you using for the buttons?

Check YouTube for my Game Slate videos. If you’re clever you can use those regular bitmaps and still get over 90FPS, that’s the way I do it at the moment.

1 Like

I make my own buttons and do not use an library.

I will have a look to the Youtube video, thanks for the anwser

Hello,

I have being bussy with reading out the LCD memory, but I still have problems.

I’m doing this in the native code:

static unsigned short screenBackup[128];

int BackUpScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
unsigned int i;

unsigned short *screenBuffer = (unsigned long *)LCD_UPBASE;		

for(i = 0; i < 128; i++)
{
	screenBackup[i] = screenBuffer++;
}

return 0;

}

int RestoreScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
unsigned int i;

unsigned long *screenBuffer = (unsigned long *)LCD_UPBASE;		

for(i = 0; i < 128; i++)
{
	screenBuffer++ = screenBackup[i];
}

return 0;

}

but when i use this, the change is that the board crash and hangs it self, so what i do wrong?

the code must be:
int BackUpScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
unsigned int i;

unsigned short *screenBuffer = (unsigned short*)LCD_UPBASE;		//Lees adres waar de LCD memory begint

for(i = 0; i < 10; i++)
{
	screenBackup[i] = screenBuffer++;
}

return 0;

}

int RestoreScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
unsigned int i;

unsigned short*screenBuffer = (unsigned short*)LCD_UPBASE;		//Lees adres waar de LCD memory begint

for(i = 0; i < 128; i++)
{
	screenBuffer++ = screenBackup[i];
}

return 0;

}

sorry for the mistake, but this will also not work, what do I wrong

please always use code tags

Sorry Gus:

Here is with code tags:


nt BackUpScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{
	unsigned int i;
	
	unsigned short *screenBuffer = (unsigned short *)LCD_UPBASE;		
	
	for(i = 0; i < 10; i++)
	{
		screenBackup[i] = *screenBuffer++;
	}
	
	return 0;
}

int RestoreScreen(unsigned int * generalArray, void **args, unsigned int argsCount, unsigned int *argSize)
{	
	unsigned int i;
	
	unsigned short *screenBuffer = (unsigned short *)LCD_UPBASE;		
	
	for(i = 0; i < 128; i++)
	{
		*screenBuffer++ = screenBackup[i];
	}
	
	return 0;
}


do you know that memcpy will be a LOT faster than using your loop?

Thanks Gus for you reply, I’m gonna use that one.

But there is another problem, when I call my RLP code, it never returns and stays in the RLP code:


 public void Show(string name)
        {
            Display LCD = new Display();
         
            //Init RLP
            Debug.Print("Init RLP..");
            byte[] elf_file = Resources.GetBytes(Resources.BinaryResources.RLP_test);
            RLP.LoadELF(elf_file);                                                      //load file
            RLP.InitializeBSSRegion(elf_file);                                          //global variabels to zero
            RLP.Procedure BackUpScreen = RLP.GetProcedure(elf_file, "BackUpScreen");    //get some procedure
          
            //We don't need this any more
            elf_file = null;
            Debug.Print("RLP init done");

          
            //Call procedure om de backuppen
            Debug.Print("Call backup screen");
            BackUpScreen.Invoke();

            Debug.Print("Backup done, wait");

When BackUpScreen is called, it goes the RLP code, but never returns, must I send a value to the RLP ?

Hello I solved the problem and can now read the LCD screen memory and it freeze not more.

But what I see is something else.

I have a class called messagebox, in this class i have show function, in this function I load the RLP to make the backup and restore, but when i call this from my main loop i see that the lcd screen is cleared, this is strange because i don’t call the clear command.

what can this be? must the RLP be called in the main loop?