2025-05-01 10:59 AM
Hi I've been trying to display an image on the GUI using an image (hex array) stored in the QSPI flash (memory mapped). I've taken a look at some of the documentation such as Loading Images at Runtime & Dynamic Bitmaps.
void LandingView::loadImageFromQSPI(Image& imageWidget)
{
BitmapId bmpId = Bitmap::dynamicBitmapCreateExternal(
185,
43,
(const void*)0x90FC0000,
Bitmap::RGB565
);
if (bmpId != BITMAP_INVALID)
{
imageWidget.setBitmap(Bitmap(bmpId));
imageWidget.invalidate(); // To trigger redraw
}
}
FrontendApplication::FrontendApplication(Model& m, FrontendHeap& heap)
: FrontendApplicationBase(m, heap)
{
Bitmap::setCache(touchgfxCache, sizeof(touchgfxCache));
}
When debugging, I keep getting BITMAP_INVALID? I've made sure I'm in memory mapped mode.
Solved! Go to Solution.
2025-05-06 3:59 AM
Hello @Priyank.
To understand the context, is the goal to display an image that TouchGFX is unaware of when you generate code? If not, there is no need to use a dynamic bitmap, as the flash is memory-mapped.
However, if you intend to dynamically load an image from external flash at runtime, then you are correct in using dynamicBitmapCreateExternal(). In this case, you need to specify the numberOfDynamicBitmaps in setCache() as it defaults to 0. When calling setCache() with numberOfDynamicBitmaps greater than 0, a copy of the bitmap database is stored in RAM. This allows it to be modified at runtime. Therefore, you should write something like this:
Bitmap::setCache(touchgfxCache, sizeof(touchgfxCache), 10);
Best regards,
Johan
2025-05-01 11:07 AM
Dump the memory content at 0x90FC0000 visible to the MCU, perhaps the first 64 or 128 bytes to a serial terminal, so someone can make an assessment as to whether this is consistent with the described bitmap, or NOT
2025-05-02 10:29 AM - edited 2025-05-02 10:29 AM
I was able to get the image to load however the problem is that the bmpId from dynamicBitmapCreate is default to 0 since it is the first dynamic bitmap created. When I then set the image to the bmpId, it sets it to the bitmap = 0 from the bitmap database. Essentially there is a crossover between the ID of dynamic and static bitmaps, so the wrong image gets displayed. Any suggestions?
2025-05-06 3:59 AM
Hello @Priyank.
To understand the context, is the goal to display an image that TouchGFX is unaware of when you generate code? If not, there is no need to use a dynamic bitmap, as the flash is memory-mapped.
However, if you intend to dynamically load an image from external flash at runtime, then you are correct in using dynamicBitmapCreateExternal(). In this case, you need to specify the numberOfDynamicBitmaps in setCache() as it defaults to 0. When calling setCache() with numberOfDynamicBitmaps greater than 0, a copy of the bitmap database is stored in RAM. This allows it to be modified at runtime. Therefore, you should write something like this:
Bitmap::setCache(touchgfxCache, sizeof(touchgfxCache), 10);
Best regards,
Johan