Levetop / LT768x Coding - Libraries & Examples (3)

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.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
LT7681/7683/7686(LT768x)是三款高效能 TFT-LCD 图形加速显示芯片。 其主要的功能就是协助 MCU 将所要显示到 TFT 屏的内容传递给 TFT 驱动 器(Driver),并且提供图形加速、PIP(Picture-in-Picture)、几何图形 绘图等功能,除了提升显示效率外,还大大的降低 MCU 处理图形显示所花 费的时间,而 LT768x 也支持非常宽广的显示分辨率,可以由 320*240 (QVGA)到 1280*1024(SXGA),显示屏则支持 16/18/24bits 的 RGB 接口。LT768x 支持各种 MCU 接口,包括 SPI、I2C 的串口,或者是 8 位、16 位并 行接口。为了达到多层次高分辨率的显示效果,LT768x 内建 128Mb 显示内 存,可以支持从每像素 1bit 的 2 灰阶到高达每像素 24bits 的 16M 颜色显示。同时要减少动画显示的 MCU 在 软件操作上的负担,LT768x 内建几何绘图引擎,支持画点、画线、画曲线、椭圆、三角形、矩形、圆角矩形等 功能,同时内嵌的硬件图形加速引擎(BTE)提供了命令类型的图形操作,如显示旋转、画面镜射、画中画(PIP/ 子母画面)及图形混合透明显示等功能,大大提升了产品的显示效能,因而能够极大程度地减轻 MCU 的软件运行 负担,如果使用高速的 SPI 接口更能减少 MCU I/O 口的需求,而不必为了 TFT 屏而去升级 MCU。LT768x 强大的 显示功能非常适合用在有 TFT-LCD 屏的电子产品上,如家电、多功能事务机、工业设备、工业控制、电子仪器、 医疗设备、人机接口、检测设备等产品。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值