FTDI Community

General Category => Discussion - Software => Topic started by: Farid on April 18, 2018, 06:21:54 PM

Title: Loading an image with FT813 issues
Post by: Farid on April 18, 2018, 06:21:54 PM
I am trying to load a JPEG image using the function below. if I call this function in my code, my whole program stops working, can anyone tells me what I am doing wrong here?


cmd_loadimage(&logo[0],0L,404,0);

void cmd_loadimage(uint8_t img[], uint32_t ptr, uint32_t length, uint32_t opt)
{   
   uint32_t i;

   ft800memWrite32(RAM_CMD + cmdOffset, CMD_LOADIMAGE);
   cmdOffset = incCMDOffset(cmdOffset, 4);
   ft800memWrite32(RAM_CMD + cmdOffset, ptr);
   cmdOffset = incCMDOffset(cmdOffset, 4);
   ft800memWrite32(RAM_CMD + cmdOffset, opt);
   cmdOffset = incCMDOffset(cmdOffset, 4);
   
   for (i = 0; i < length; i++)
   {
     ft800memWrite8(RAM_CMD + cmdOffset, img);   
      cmdOffset++;
   }

}
Title: Re: Loading an image with FT813 issues
Post by: Farid on April 20, 2018, 12:46:23 AM
Hi guys!

Can anyone comment on my previous question. below is how I called cmd_loadimage inside main.

int main()
{
cmdOffset= WaitCmdFifoEmpty();

ft800memWrite32(RAM_CMD + cmdOffset, (CMD_DLSTART));   // Start the display list
cmdOffset = incCMDOffset(cmdOffset, 4);                        // Update the command pointer

ft800memWrite32(RAM_CMD + cmdOffset, DL_CLEAR_RGB);   // same as CLEAR_COLOR_RGB(0, 0, 0) Start the display list
cmdOffset = incCMDOffset(cmdOffset, 4);      
   
ft800memWrite32(RAM_CMD + cmdOffset, (DL_CLEAR_RGB | WHITE));   // same as CLEAR_COLOR_RGB(0, 0, 0) Start the display list
cmdOffset = incCMDOffset(cmdOffset, 4);      
              
ft800memWrite32(RAM_CMD + cmdOffset, CLEAR(1,1,1)); 
cmdOffset = incCMDOffset(cmdOffset, 4);   

cmd_loadimage(&logo[0],0L,404,0);

ft800memWrite32(RAM_CMD + cmdOffset, BITMAP_SOURCE(0L)); 
cmdOffset = incCMDOffset(cmdOffset, 4);   

ft800memWrite32(RAM_CMD + cmdOffset, BITMAP_LAYOUT(RGB565, 200, 65)); 
cmdOffset = incCMDOffset(cmdOffset, 4);   

ft800memWrite32(RAM_CMD + cmdOffset, BITMAP_SIZE(NEAREST, BORDER, BORDER, 200, 65)); 
cmdOffset = incCMDOffset(cmdOffset, 4);   

ft800memWrite32(RAM_CMD + cmdOffset, BEGIN(BITMAPS));       
cmdOffset = incCMDOffset(cmdOffset, 4);   

ft800memWrite32(RAM_CMD + cmdOffset, VERTEX2II(77, 90, 0, 0));                                 
cmdOffset = incCMDOffset(cmdOffset, 4);   

ft800memWrite32(RAM_CMD + cmdOffset, DISPLAY());       
cmdOffset = incCMDOffset(cmdOffset, 4);   
      
ft800memWrite32(RAM_CMDcmdOffset,CMD_SWAP);                                                                         cmdOffset = incCMDOffset(cmdOffset, 4);   
      
ft800memWrite16(REG_CMD_WRITE, (cmdOffset));  // Update the ring buffer pointer so the graphics processor starts executing
}            
Title: Re: Loading an image with FT813 issues
Post by: FTDI Community on April 20, 2018, 09:31:30 AM
Hi,

We have a summary of how to load the data in the application note below (see pages 18 and 19 especially)

http://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_008_FT81x_Creating_a_Simple_Library_For_PIC_MCU.pdf (http://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_008_FT81x_Creating_a_Simple_Library_For_PIC_MCU.pdf)

In the code below, you would need to take account of the circular nature of the buffer so that the data does not run beyond the end of the 4K buffer. You would also need to check the read and write pointers to ensure that there is sufficient space in the buffer. Hopefully the flow chart and sample code linked in the application note above will help.
 
Code: [Select]
   for (i = 0; i < length; i++)
   {
     ft800memWrite8(RAM_CMD + cmdOffset, img);   
      cmdOffset++;
   }

Best regards, FTDI Community
Title: Re: Loading an image with FT813 issues
Post by: Farid on May 01, 2018, 12:55:38 AM
hello,

I have managed to display a start Icon on my LCD using the hex data defined in uint8_t home_start_icon[]. Below is how I did that:

However, I have a home icon saved as a png image and I converted it to a hex file which I used in an array, and I followed same sequence in displaying the start Icon, but it not display when I run the code. Could anyone say what I need to change in the code below so that that png icon is displayed. I tried changing format from L4 to ARGB4, but no success.

void Display(void)   
{   
uint16_t length=0;
   
WaitCmdFifoEmpty();                //wait for FIFO read/write
   
ft813memWrite32(RAM_CMD + cmdOffset, CMD_INFLATE); 
cmdOffset = incCMDOffset(cmdOffset, 4);

ft813memWrite32(RAM_CMD + cmdOffset, START_ICON_ADDR); 
cmdOffset = incCMDOffset(cmdOffset, 4);
   
length=sizeof(home_start_icon);
cmd_WrCmdBuf(home_start_icon,length);                         //Load from RAM
WaitCmdFifoEmpty();                //wait for FIFO read/write
      
   
/** Start a new Display list ***********************************/
ft813memWrite16(REG_CMD_DL, 0);   // Start the display list
   
ft813memWrite32(RAM_CMD + cmdOffset, (CMD_DLSTART));   // Start the display list
cmdOffset = incCMDOffset(cmdOffset, 4);
         
ft813memWrite32(RAM_CMD + cmdOffset, (DL_CLEAR_RGB |BLUE));   // same as CLEAR_COLOR_RGB(0, 0, 0) Start the display list
cmdOffset = incCMDOffset(cmdOffset, 4); 
      
ft813memWrite32(RAM_CMD + cmdOffset, CLEAR(1,1,1))  ;
cmdOffset = incCMDOffset(cmdOffset, 4);
      
ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_HANDLE(START_ICON_HANDLE));
cmdOffset = incCMDOffset(cmdOffset, 4);
   
ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_SOURCE(START_ICON_ADDR));
cmdOffset = incCMDOffset(cmdOffset, 4);
   
ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_LAYOUT(L4, 16, 32));//L4   
//ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_LAYOUT(ARGB4, 140, 70));//L4
cmdOffset = incCMDOffset(cmdOffset, 4);
   
ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_SIZE(NEAREST, BORDER, BORDER, 32, 32));
//ft813memWrite32(RAM_CMD + cmdOffset, BITMAP_SIZE(NEAREST, BORDER, BORDER, 70, 140));
 cmdOffset = incCMDOffset(cmdOffset, 4);

ft813memWrite32(RAM_CMD + cmdOffset, COLOR_RGB(255,25,0));     //used for making colors                                                                                 
cmdOffset = incCMDOffset(cmdOffset, 4);

ft813memWrite32(RAM_CMD +  cmdOffset,BEGIN(BITMAPS));      
cmdOffset = incCMDOffset(cmdOffset, 4);

ft813memWrite32(RAM_CMD +  cmdOffset,VERTEX2II(450,240,START_ICON_HANDLE,4));      
cmdOffset = incCMDOffset(cmdOffset, 4);
   
ft813memWrite32(RAM_CMD +  cmdOffset,END());      
cmdOffset = incCMDOffset(cmdOffset, 4);
      
LCD_Display();
}

void LCD_Display(void)
{
      
ft813memWrite32(RAM_CMD + cmdOffset, (DL_DISPLAY));      // Instruct the graphics processor to show the list
cmdOffset = incCMDOffset(cmdOffset, 4);                        // Update the command pointer

ft813memWrite32(RAM_CMD + cmdOffset, (CMD_SWAP));         // Make this list active
cmdOffset = incCMDOffset(cmdOffset, 4);                        // Update the command pointer

ft813memWrite16(REG_CMD_WRITE, (cmdOffset));         
}
Title: Re: Loading an image with FT813 issues
Post by: FTDI Community on May 01, 2018, 11:05:50 AM
Hi Farid,

Could you tell us what is in your code for cmd_WrCmdBuf(home_start_icon,length);

What do you see when it fails, does it show as a black box in the screen of the same size that you expected for the image?

Best Regards, FTDI Community


Title: Re: Loading an image with FT813 issues
Post by: Rudolph on May 25, 2018, 09:48:36 AM
However, I have a home icon saved as a png image and I converted it to a hex file which I used in an array, and I followed same sequence in displaying the start Icon, but it not display when I run the code. Could anyone say what I need to change in the code below so that that png icon is displayed. I tried changing format from L4 to ARGB4, but no success.

Did you convert the .png to a hex file or did you convert it with the image-convert utility?
If you are trying to load a plain .png there is a chance that there is nothing wrong with your code since EVE is a bit picky about PNGs in generell.

Also this might help: https://github.com/RudolphRiedel/FT800-FT813
https://github.com/RudolphRiedel/FT800-FT813/tree/master/example_projects/FT8xx_Test_90CAN_FT813_EVE2-35G

This is a bit specific as it is for AVR and a EVE2-35G module from Matrix Orbital, however this example is a bit smaller than my others
and it includes loading and displaying of a .png image.

Although, while PNG has adantages over JPG for icons - it should compress a little better and is lossless - loading PNGs is really slow compared to JPG.

Best Regards, Rudolph
Title: Re: Loading an image with FT813 issues
Post by: Ulthien on November 15, 2018, 10:30:03 AM
Hi,

We have a summary of how to load the data in the application note below (see pages 18 and 19 especially)

http://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_008_FT81x_Creating_a_Simple_Library_For_PIC_MCU.pdf (http://brtchip.com/wp-content/uploads/Support/Documentation/Application_Notes/ICs/EVE/BRT_AN_008_FT81x_Creating_a_Simple_Library_For_PIC_MCU.pdf)

In the code below, you would need to take account of the circular nature of the buffer so that the data does not run beyond the end of the 4K buffer. You would also need to check the read and write pointers to ensure that there is sufficient space in the buffer. Hopefully the flow chart and sample code linked in the application note above will help.
 
Code: [Select]
   for (i = 0; i < length; i++)
   {
     ft800memWrite8(RAM_CMD + cmdOffset, img);   
      cmdOffset++;
   }

Best regards, FTDI Community

As pointed to by my collegue (pun half-intended? :P)

Code: [Select]
   for (i = 0; i < length; i++)
   {
     ft800memWrite8(RAM_CMD + cmdOffset, *img++);   
      cmdOffset++;
   }

or you are writing the same byte out whole of the loop...
Title: Re: Loading an image with FT813 issues
Post by: FTDI Community on November 15, 2018, 01:42:59 PM
Hi,

Thanks for your pointers  ;)  You are correct, this should increment the image data pointer too to work correctly.

However, this code snippet (taken from the original post) is also missing a few other things -it would also need the wrap-around at RAM_CMD + 4095 and also a check of free space in order to make it work reliably. If sending more than 4K of data, it would also be necessary to split the data into chunks and send the next chunk when there is enough free space.

You can find full examples in the sample code which covers all of these additional requirements.

Best Regards, FTDI Community