674
« on: April 16, 2019, 02:27:09 PM »
Hello,
The example included in AN_303 uses old source code form out main 'SampleApp', this has been updated to use the 'Gpu_Hal_WrMemFromFlash' function in place of the 'Ft_App_LoadRawFromFile'. This should be defined in the GPU_HAL.cpp file in your project:
void SAMAPP_GPU_DXT1() {
//load each .raw file into graphics RAM from directory ‘test’
//RAM_G is starting address in graphics RAM, for example 00 0000h
uint16_t imgWidth = 128, imgHeight = 128, c0_c1_width = 32, c0_c1_height = 32, c0_c1_stride = c0_c1_width * 2, b0_b1_width = imgWidth, b0_b1_height = imgHeight, b0_b1_stride = b0_b1_width/ 8, szPerFile = 2048;
#if defined(ARDUINO_PLATFORM) || defined(FT900_PLATFORM) || defined(FT93X_PLATFORM)
Gpu_Hal_WrMemFromFlash(phost, RAM_G, SAMAPP_Tomato_DXT1_C0_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile, SAMAPP_Tomato_DXT1_C1_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile * 2, SAMAPP_Tomato_DXT1_B0_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile * 3, SAMAPP_Tomato_DXT1_B1_Data_Raw, szPerFile);
#endif
Gpu_CoCmd_Dlstart(phost);
App_WrCoCmd_Buffer(phost, CLEAR(1, 1, 1));
App_WrCoCmd_Buffer(phost, COLOR_RGB(255, 255, 255));
#if defined(MSVC_PLATFORM) || defined(MSVC_FT800EMU)
Gpu_Hal_WrMemFromFlash(phost, RAM_G, SAMAPP_Tomato_DXT1_C0_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile, SAMAPP_Tomato_DXT1_C1_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile * 2, SAMAPP_Tomato_DXT1_B0_Data_Raw, szPerFile);
Gpu_Hal_WrMemFromFlash(phost, RAM_G + szPerFile * 3, SAMAPP_Tomato_DXT1_B1_Data_Raw, szPerFile);
#endif
Gpu_CoCmd_LoadIdentity(phost);
Gpu_CoCmd_SetMatrix(phost);
App_WrCoCmd_Buffer(phost, SAVE_CONTEXT());
//B0&B1 handle
App_WrCoCmd_Buffer(phost, BITMAP_HANDLE(1));
App_WrCoCmd_Buffer(phost, BITMAP_SOURCE(RAM_G + szPerFile*2));
App_WrCoCmd_Buffer(phost, BITMAP_LAYOUT(L1, b0_b1_stride, b0_b1_height)); //L1 format stride is 1 bit per pixel
App_WrCoCmd_Buffer(phost,
BITMAP_SIZE(NEAREST, BORDER, BORDER, imgWidth, imgHeight)); //draw in full size
//C0&C1 handle
App_WrCoCmd_Buffer(phost, BITMAP_HANDLE(2));
App_WrCoCmd_Buffer(phost, BITMAP_SOURCE(RAM_G));
App_WrCoCmd_Buffer(phost, BITMAP_LAYOUT(RGB565, c0_c1_stride, c0_c1_height)); //RGB565 format stride is 2 bytes per pixel
App_WrCoCmd_Buffer(phost,
BITMAP_SIZE(NEAREST, BORDER, BORDER, imgWidth, imgHeight)); //draw in full size
// start drawing bitmaps
App_WrCoCmd_Buffer(phost, BEGIN(BITMAPS));
App_WrCoCmd_Buffer(phost, BLEND_FUNC(ONE, ZERO));
App_WrCoCmd_Buffer(phost, COLOR_A(0x55));
App_WrCoCmd_Buffer(phost, VERTEX2II(DispWidth / 2 - b0_b1_width / 2, DispHeight / 2 - b0_b1_height / 2, 1, 0));
App_WrCoCmd_Buffer(phost, BLEND_FUNC(ONE, ONE));
App_WrCoCmd_Buffer(phost, COLOR_A(0xAA));
App_WrCoCmd_Buffer(phost, VERTEX2II(DispWidth / 2 - b0_b1_width / 2, DispHeight / 2 - b0_b1_height / 2, 1, 1));
App_WrCoCmd_Buffer(phost, COLOR_MASK(1, 1, 1, 0));
Gpu_CoCmd_Scale(phost, 4 * 65536, 4 * 65536);
Gpu_CoCmd_SetMatrix(phost);
App_WrCoCmd_Buffer(phost, BLEND_FUNC(DST_ALPHA, ZERO));
App_WrCoCmd_Buffer(phost, VERTEX2II(DispWidth / 2 - b0_b1_width / 2, DispHeight / 2 - b0_b1_height / 2, 2, 1));
App_WrCoCmd_Buffer(phost, BLEND_FUNC(ONE_MINUS_DST_ALPHA, ONE));
App_WrCoCmd_Buffer(phost, VERTEX2II(DispWidth / 2 - b0_b1_width / 2, DispHeight / 2 - b0_b1_height / 2, 2, 0));
App_WrCoCmd_Buffer(phost, END());
App_WrCoCmd_Buffer(phost, RESTORE_CONTEXT());
//reset the transformation matrix because its not part of the context, RESTORE_CONTEXT() command will not revert the command.
Gpu_CoCmd_LoadIdentity(phost);
Gpu_CoCmd_SetMatrix(phost);
App_WrCoCmd_Buffer(phost, COLOR_RGB(255, 0, 0));
Gpu_CoCmd_Text(phost, (DispWidth / 2), 50, 31, OPT_CENTER, "DXT1: 8KB.");
Gpu_CoCmd_Text(phost, (DispWidth / 2), 80, 31, OPT_CENTER,
"Original: 32KB.");
App_WrCoCmd_Buffer(phost, DISPLAY());
//swap the current display list with the new display list
Gpu_CoCmd_Swap(phost);
//write to the FT800 FIFO command buffer - bitmap will appear after this command
App_Flush_Co_Buffer(phost);
Gpu_Hal_WaitCmdfifo_empty(phost);
Gpu_Hal_Sleep(3000);
}
Best Regards,
FTDI Community