cancel
Showing results for 
Search instead for 
Did you mean: 

How to display image from QSPI flash?

Priyank
Senior

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
JohanAstrup
ST Employee

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

View solution in original post

3 REPLIES 3

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

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

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?

JohanAstrup
ST Employee

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