2020-12-28 06:11 AM
Normally I can display all projects of touchgfx (which can be stored in internal memory) on my touchscreen without any problem.
For a larger project I needed to use a SD card. For this purpose, I compiled all the images into a .bin file and then saved it to SD card. I try to use blockcopy function as shown below but all I get is just a black screen.
To sum up, I dont know how to call the images. it will be appreciated if someone correct the mistakes or shift me to the the correct way.
bool TouchGFXHAL::blockCopy(void* RESTRICT dest, const void* RESTRICT src, uint32_t numBytes)
{
uint32_t dataOffset = (uint32_t)src;
if (dataOffset >= 0x9A000000 && dataOffset < 0xA0000000)
{
int fd;
if(f_mount(&myFatFs,SDPath,1) == FR_OK)
{
if (f_open(&myFile,"images.bin",FA_OPEN_EXISTING | FA_READ) == FR_OK)
{
fd = open("images.bin", O_RDONLY, 0);
dataOffset = dataOffset - 0x9A000000;
lseek(fd, dataOffset, SEEK_SET);
read(fd, (uint8_t *)dest, numBytes);
close(fd);
}
return true;
}
else { return false;}
}
else
{ return HAL::blockCopy(dest, src, numBytes); }
}
for initialization ;
void TouchGFXHAL::initialize()
{
uint16_t* cacheStartAddr = (uint16_t *) malloc(0x3000000);
uint32_t cacheSize = 0x3000000;
Bitmap::removeCache();
Bitmap::setCache(cacheStartAddr,cacheSize,1024);
Bitmap::cacheAll();
}
2020-12-28 11:29 AM
You debug your code fread?
2020-12-29 01:26 AM
I saw that it enters the Bitmap::cacheAll(); but does not pass it over and stays there.
and it doesnot enter the blockcopy function.
2020-12-29 02:57 AM
void TouchGFXHAL::initialize()
{
// Calling parent implementation of initialize().
//
// To overwrite the generated implementation, omit call to parent function
// and implemented needed functionality here.
// Please note, HAL::initialize() must be called to initialize the framework.
TouchGFXGeneratedHAL::initialize();
}
2020-12-29 03:03 AM
Sorry I forgot to paste it (TouchGFXGeneratedHAL::initialize();) into the code section of the question. it is already there.
2020-12-29 03:05 AM
void TouchGFXHAL::initialize()
{
TouchGFXGeneratedHAL::initialize();
uint16_t* cacheStartAddr = (uint16_t *) malloc(0x1400000);
uint32_t cacheSize = 0x1400000; //20 MB, as example
Bitmap::removeCache();
Bitmap::setCache(cacheStartAddr,cacheSize,1024);
Bitmap::cacheAll();
}
2020-12-29 03:43 AM
Maybe you dont understand cache please apply Caching Bitmaps | TouchGFX Documentation
or turn off caching and solve SDCARD first...
2020-12-29 04:24 AM
To clear the problem, which part have you stucked in?
Reading data from sd card?
Coping data from sd card to ram?
Display the image?
Match the image into touchgfx?
2020-12-30 02:08 AM
I think the problem is related to the initialization coz after executing the cacheAll() , it doesnot get out from the initialize function. so it seems I need to understand caching process or find a sample code.
2020-12-30 03:17 AM
Realy your LD file and clibs can alloc this?
uint16_t* cacheStartAddr = (uint16_t *) malloc(0x1400000);
uint32_t cacheSize = 0x1400000; //20 MB, as example