This section is to explain how users can display images in different opacity level. This function is useful for making a dimming background to emphasize partial images (e.g. a pop-up window).
Related functions are listed below:
void LT768_DrawSquare_Fill // Draw a solid rectangle on the designated canvas layer
(
unsigned short X1 // Left-top X1 coordinate
,unsigned short Y1 // Left-top Y1 coordinate
,unsigned short X2 // Right-bottom X2 coordinate
,unsigned short Y2 // Right-bottom Y2 coordinate
,unsigned long ForegroundColor // Filled color
)
Example: Drawing an 1024x600 rectangle in Black (0x0000) color
LT768_DrawSquare_Fill(0, 0, 1024, 600, Black);
void LT768_BTE_Memory_Copy // Move LT768x SDRAM data from one layer to another
(
unsigned long S0_Addr // Starting address (SDRAM) of S0 picture
,unsigned short S0_W // Width of the S0 picture
,unsigned short XS0 // Left-top X coordinate of the S0 picture
,unsigned short YS0 // Left-top Y coordinate of the S0 picture
,unsigned long S1_Addr // Starting address (SDRAM) of S1 picture
,unsigned short S1_W // Width of the S1 picture
,unsigned short XS1 // Left-top X coordinate of the S1 picture
,unsigned short YS1 // Left-top Y coordinate of the S1 picture
,unsigned long Des_Addr // Starting address (SDRAM) of DT picture
,unsigned short Des_W // Width of the DT picture
,unsigned short XDes // Left-top X coordinate of the DT picture
,unsigned short YDes // Left-top Y coordinate of the DT picture
,unsigned int ROP_Code // Refer to "LT768x_AP-Note_V12_ENG.pdf", Table 10-2
,unsigned short X_W // Width of the active window
,unsigned short Y_H // Height of the active window
)
Example: Assume the picture size for both S0 and S1 is 1024 * 600
S0: Start address is 0, at (100, 100)
S1: Start address is 1024*600*2 of Display RAM, at (50, 50)
DT: Start address is 1024*600*2*2 of Display RAM, at (200, 200)
DT Display Window Size: 100*100
ROP Mode: 0x0C (Show S0)
LT768_BTE_Memory_Copy (
0, 1024, 100, 100, // S0
1024*600*2, 1024, 50, 50, // S1
1024*600*2*2, 1024, 200, 200, // DT
0x0C, // ROP
100, 100 // Data area: width * height
);
void BTE_Alpha_Blending // BTE memory copy with opacity setting
(
unsigned long S0_Addr // Starting address (SDRAM) of S0 picture
,unsigned short S0_W // Width of the S0 picture
,unsigned short XS0 // Left-top X coordinate of the S0 picture
,unsigned short YS0 // Left-top Y coordinate of the S0 picture
,unsigned long S1_Addr // Starting address (SDRAM) of S1 picture
,unsigned short S1_W // Width of the S1 picture
,unsigned short XS1 // Left-top X coordinate of the S1 picture
,unsigned short YS1 // Left-top Y coordinate of the S1 picture
,unsigned long Des_Addr // Starting address (SDRAM) of DT picture
,unsigned short Des_W // Width of the DT picture
,unsigned short XDes // Left-top X coordinate of the DT picture
,unsigned short YDes // Left-top Y coordinate of the DT picture
,unsigned short X_W // Width of the active window
,unsigned short Y_H // Height of the active window
,unsigned char alpha // Alpha blending level (0~31 levels)
)
Example: Assume the picture size for both S0 and S1 is 1024 * 600
S0: Start address is 0, at (0, 0)
S1: Start address is 1024*600*2, at (0, 0)
DT: Start address is 1024*600*2*2, at (50, 50)
Alpha Blending: 5 (0~31)
DT Display Window Size: 100*100
BTE_Alpha_Blending (
0, 1024, 0, 0, // S0
1024*600*2, 1024, 0, 0, // S1
1024*600*4, 1024, 50, 50, // DT
100, 100, // Data area: width * height
5 // Alpha value (0 ~ 31)
);
Following example demonstrates a restaurant menu on a a dimming background:
/*---------------------------------------------------------------------------------------*/
/* Function: BTE_Demo_1 */
/* */
/* Parameters: None */
/* Returns: None */
/* Description: Demonstrate BTE functions - Pop-up window with dimming background */
/*---------------------------------------------------------------------------------------*/
void BTE_Demo_1(void)
{
Select_Main_Window_16bpp(); // Set main window color depth
Main_Image_Start_Address(LAYER_0); // Set main window starting address - Display layer
Main_Image_Width(LCD_XSIZE_TFT); // Set main window width
Main_Window_Start_XY(0,0); // Set main window starting coordinate
Canvas_Image_Start_address(LAYER_0); // Set canvas starting address
Canvas_image_width(LCD_XSIZE_TFT); // Set canvas width
Active_Window_XY(0,0); // Set active window starting coordinate
Active_Window_WH(LCD_XSIZE_TFT,LCD_YSIZE_TFT); // Set active window width and height
// Clear display layer (SDRAM)
LT768_DrawSquare_Fill(0, 0, LCD_XSIZE_TFT, LCD_YSIZE_TFT, Black);
// Retrieve the background picture from flash and display it to the TFT panel
Canvas_Image_Start_address(LAYER_1);
LT768_DMA_24bit_Block(1, 0, 0, 0, LCD_XSIZE_TFT, LCD_YSIZE_TFT, LCD_XSIZE_TFT, 0x00000000);
LT768_BTE_Memory_Copy(
LAYER_1, LCD_XSIZE_TFT, 0, 0, // S0
LAYER_1, LCD_XSIZE_TFT, 0, 0, // S1
LAYER_0, LCD_XSIZE_TFT, 0, 0, // DT
0x0c, // ROP code, 0x0c -> DT = S0
LCD_XSIZE_TFT, LCD_YSIZE_TFT // Data area (width * height)
);
delay_ms(5000);
// Write "black" data to LAYER_3 -> These data will be used for BTE_Alpha_Blending function
Canvas_Image_Start_address(LAYER_2);
LT768_DrawSquare_Fill(0, 0, LCD_XSIZE_TFT, LCD_YSIZE_TFT, Black);
// Background dimming effect by BTE_Alpha_Blending command
BTE_Alpha_Blending(
LAYER_1, LCD_XSIZE_TFT, 0, 0, // S0
LAYER_2, LCD_XSIZE_TFT, 0, 0, // S1
LAYER_0, LCD_XSIZE_TFT, 0, 0, // DT
LCD_XSIZE_TFT, LCD_YSIZE_TFT, // Data area (width * height)
15 // Alpha value (0~31)
);
// (1) Set canvas starting address
// (2) Use DMA command to retrieve picture data (pop-up window) from Flash
// and then transmit those data to LT768x SDRAM from canvas starting address
Canvas_Image_Start_address(LAYER_0);
LT768_DMA_24bit_Block(1, 0, 291, 134, 442, 332, 442, 0x0012c000); // Display the pop-up window
}
This example uses two pictures which are stored in the external SPI Flash:
Picture 1: Background
Picture 2: Pop-up window
Running result is shown below:
Another running example is attached below for users reference, please contact me for the code if needed.