LT768x supports 2 sets of Picture-in-Picture feature (PIP-1 & PIP-2). Users can display sub-image on the main screen without overwriting the image data of the main display window. If PIP-1 and PIP-2 are overlapping, then the PIP-1 image is always on the top of PIP-2.
Related functions are listed below:
void LT768_PIP_Init // Initialize Picture-In-Picture function
(
unsigned char On_Off // 0: Disable 1: Eanble
,unsigned char Select_PIP // 1: Use PIP1 2: Use PIP2
,unsigned long PAddr // Starting address of the PIP
,unsigned short XP // X coordinate of the PIP, must be dividable by 4
,unsigned short YP // Y coordinate of the PIP, must be dividable by 4
,unsigned long ImageWidth // Width of the base image
,unsigned short X_Dis // X coordinate of the display window
,unsigned short Y_Dis // Y coordinate of the display window
,unsigned short X_W // Width of the display window, must be dividable by 4
,unsigned short Y_H // Height of the display window, must be dividable by 4
)
void LT768_Set_DisWindowPos // Set the PIP display position
(
unsigned char On_Off // 0: Disable 1: Enable
,unsigned char Select_PIP // 1: Use PIP1 2: Use PIP2
,unsigned short X_Dis // X coordinate of the display window
,unsigned short Y_Dis // Y coordinate of the display window
)
Below example is to display two moving icons on the main window. Following steps explain how this effect can be done:
Step 1: Load picture data from SPI flash to LT768x SDRAM
Main window image:
PIP1 image
PIP2 image
Step 2: Intialize PIP function
LT768_PIP_Init(1,1,LAYER_1,0,0,136,0,173,136,136); // intialize PIP1
LT768_PIP_Init(1,2,LAYER_2,0,0,276,524,137,276,206); // intialize PIP2
Step 3: Set PIP window position
Users may change a PIP image display position by assigning its left-top coordinate.
In the example here, two "for" loops are used to demonstrate moving icons.
for(int i = 0; i < 524; i += 2)
{
LT768_Set_DisWindowPos(1, 1, i, 173); // Move PIP1 from left to right
LT768_Set_DisWindowPos(1, 2, 524-i, 137); // Move PIP2 from right to left
delay_ms(15);
}
for(int i = 0; i < 524; i += 2)
{
LT768_Set_DisWindowPos(1, 1, 524-i, 173); // Move PIP1 from right to left
LT768_Set_DisWindowPos(1, 2, i, 137); // Move PIP2 from left to right
delay_ms(15);
}
Reference codes are listed below:
/*----------------------------------------------------------------------------------------*/
/* Function: PIP_Demo */
/* */
/* Parameters: None */
/* Returns: None */
/* Description: Display two sub-images(icon) by PIP functions */
/*----------------------------------------------------------------------------------------*/
void PIP_Demo(void)
{
Select_Main_Window_16bpp(); // Set main window color depth
Main_Image_Start_Address(LAYER_0); // Set main window start address - Display layer
Main_Image_Width(LCD_XSIZE_TFT); // Set main window width
Main_Window_Start_XY(0,0); // Set main window start coordinate
Canvas_Image_Start_address(LAYER_0); // Set canvas start address
Canvas_image_width(LCD_XSIZE_TFT); // Set canvas width
Active_Window_XY(0,0); // Set active window start coordinate
Active_Window_WH(LCD_XSIZE_TFT,LCD_YSIZE_TFT); // Set active window area
// Load the background picture to display layer
LT768_DMA_24bit_Block(1,0,0,0,LCD_XSIZE_TFT,LCD_YSIZE_TFT,LCD_XSIZE_TFT,0);
// Load 1st sub-image
Canvas_Image_Start_address(LAYER_1);
Canvas_image_width(134);
LT768_DMA_24bit_Block(1,0,0,0,136,136,136,0x000bb800);
// Load 2nd sub-image
Canvas_Image_Start_address(LAYER_2);
Canvas_image_width(276);
LT768_DMA_24bit_Block(1,0,0,0,276,206,276,0x000c4880);
// Initialize PIP-1
LT768_PIP_Init(1,1,LAYER_1,0,0,136,0,173,136,136);
LT768_PIP_Init(1,2,LAYER_2,0,0,276,524,137,276,206);
// Display two PIPs in loop
while(1)
{
for(int i = 0; i < 524; i += 2)
{
LT768_Set_DisWindowPos(1, 1, i, 173); // Move PIP1 from left to right
LT768_Set_DisWindowPos(1, 2, 524-i, 137); // Move PIP2 from right to left
delay_ms(15);
}
for(int i = 0; i < 524; i += 2)
{
LT768_Set_DisWindowPos(1, 1, 524-i, 173); // Move PIP1 from right to left
LT768_Set_DisWindowPos(1, 2, i, 137); // Move PIP2 from left to right
delay_ms(15);
}
}
}
Running result is shown below: