This section is to explain how users may implement scrolling image effects by utilizing a simple BTE_MEMORY_COPY function.
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
)
In this example, three SDRAM layers are used.
LAYER_0: display layer whose data will be displayed onto the LCD.
LAYER_3: buffer layer for storing the data of the scrolling picture.
LAYER_2: buffer layer for storing the scrolled result
An 800x480 picture is loaded to LAYER_0 and used as the background, and a 420x322 picture is loaded to LAYER_3.
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 to show the basemap
LT768_DMA_24bit_Block(1,0,0,0,LCD_XSIZE_TFT,LCD_YSIZE_TFT,LCD_XSIZE_TFT,0);
// Load the target picture to LAYER_3, picture resolution: 420x322
Canvas_Image_Start_address(LAYER_3);
Canvas_image_width(420);
LT768_DMA_24bit_Block(1,0,0,0,420,322,420,0x000bb800); // 0x000bb800 is the start address of the picture in Flash.
After the pictures are loaded to LT768x SDRAM layers, we can then use BTE_MEMORY_COPY function to move the picture data, and create the scrolling effect.
The concept is as shown below:
The scrolling steps are implemented as described below:
Step 1: Copy the top 3 rows of the picture stored in LAYER_3 to LAYER_2
Step 2: Copy the rest of the rows of the picture stored in LAYER_3 to LAYER_2
Step 3: Copy the new formed picture data in LAYER_2 to LAYER_3
Step 4: Copy the new formed picture data in LAYER_2 to LAYER_0 (display layer)
Step 5: Run Step 1 ~ 5 in loop to form the scrolling effect.
Users may adjust the number of rows in Step 1 and Step 2 to control the scrolling speed.
Demo code is listed below:
void Scrolling_Picture(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 800x480 picture to display layer to show as the background
LT768_DMA_24bit_Block(1,0,0,0,LCD_XSIZE_TFT,LCD_YSIZE_TFT,LCD_XSIZE_TFT,0);
// Load the 420x322 picture to LAYER_3
Canvas_Image_Start_address(LAYER_3);
Canvas_image_width(420);
LT768_DMA_24bit_Block(1,0,0,0,420,322,420,0x000bb800); // 0x000bb800 is the start address of the picture in Flash.
while(1)
{
// Use LAYER_2 as the buffer layer of LAYER_3, and move the data every 3 rows at a time
//
// 1. Copy the top 3 rows data of the scrolling picture on LAYER_3 to the bottom of the picture in LAYER_2
LT768_BTE_Memory_Copy(LAYER_3, 420, 0, 0,
LAYER_3, 420, 0, 0,
LAYER_2, 420, 0, 322-3,
0x0c, 420, 3);
// 2. Copy the rest of the picture data on LAYER_3 to the top of LAYER_2
LT768_BTE_Memory_Copy(LAYER_3, 420, 0, 3,
LAYER_3, 420, 0, 3,
LAYER_2, 420, 0, 0,
0x0c, 420, 322-3);
// 3. Copy the processed data back to LAYER_3, for next loop processing
LT768_BTE_Memory_Copy(LAYER_2, 420, 0, 0,
LAYER_2, 420, 0, 0,
LAYER_3, 420, 0, 0,
0x0c, 420, 322);
// 4. Copy the processed data to LAYER_0 for displaying
LT768_BTE_Memory_Copy(LAYER_2, 420, 0, 0,
LAYER_2, 420, 0, 0,
LAYER_0, 800, 190, 90,
0x0c, 420, 322);
}
}
Running result is shown below: