2025-12-01 9:00 PM
I wrote the following code in TouchGFXHAL.cpp
__attribute__((section(".ram_d2")))
uint16_t cache[144*1024]; //288KB cache
void TouchGFXHAL::initialize()
{
// Calling parent implementation of initialize().
//
// To overwrite the generated implementation, omit the call to the parent function
// and implement the needed functionality here.
// Please note, HAL::initialize() must be called to initialize the framework.
registerTaskDelayFunction(&OSWrappers::taskDelay);
setFrameRefreshStrategy(REFRESH_STRATEGY_OPTIM_SINGLE_BUFFER_TFT_CTRL);
TouchGFXGeneratedHAL::initialize();
GFXAdapter::gfx_adapter_lcd_init();
Bitmap::setCache(cache, sizeof(cache));
Bitmap::clearCache();
Bitmap::cache(BITMAP_ELAINA_ID);
}
bool TouchGFXHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes){
// If requested data is located within the memory block we have assigned for ExtFlashSection,
// provide an implementation for data copying.
for(uint32_t i = 0; i < numBytes / 2; i++)
*((uint16_t *)dest + i) = 0xFFFF;
return true;
// if (src >= (void*)SD_START_ADDRESS&&src < (void*)SD_END_ADDRESS)
// {
// uint32_t dataOffset = (uint32_t)src - SD_START_ADDRESS;
// // In this example we assume graphics is placed in SD card, and that we have an appropriate function
// // for copying data from there.
// if (TF_ReadFile(IMAGE_PATH,dest,dataOffset,numBytes) != HAL_OK) {
// return HAL::blockCopy(dest, src, numBytes);
// }
// return true;
// }
// For all other addresses, just use the default implementation.
// This is important, as blockCopy is also used for other things in the core framework.
return HAL::blockCopy(dest, src, numBytes);
}
In order to test whether the blockCopy function is effective, the white value is directly returned at the beginning for testing, but neither breakpoint debugging nor actual phenomenon calls blockCopy, using cache () and cacheAll (), or calling clearCache () before calling cache () is useless.It is also useless to call cache () in the setupScreen of screenview.cpp
Solved! Go to Solution.
2025-12-01 9:27 PM
Solved,f a single picture exceeds the total size of the cache, the compressed picture can be called normally.
2025-12-01 9:27 PM
Solved,f a single picture exceeds the total size of the cache, the compressed picture can be called normally.