cancel
Showing results for 
Search instead for 
Did you mean: 

Read images from external Flash and use them in touchGFX (the images are written at runtime) STM32f746 Discovery

KIlia.1
Associate II

I want to use the external flash in order to save some images at runtime ( the images are coming from Sd card) .

Is there any Example code that i can see ?

8 REPLIES 8
Alexandre RENOUX
Principal

Hello,

This is not directly related to TouchGFX.

If there is an example regarding how to save images from SD Card to Flash, it should be in the F7 Cube FW Package at the following location : STM32Cube_FW_F7_V1.16.0\Projects\STM32746G-Discovery

Unfortunately we do not have an example made by the TouchGFX team.

On the other hand, it is possible to use images from SD card without going through the external Flash by using Dynamic Bitmaps https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/dynamic-bitmaps/

/Alexandre

KIlia.1
Associate II

Dr Alexandre,

Thanks for you reply, i have seen those and i have already tested dynamic bitmaps from SD.

But, in my application i need to read images from SD, store them to an external addressable qspi flash, and then read them from the flash and use them into TouchGFX.

My questions are:

  1. In which address should i write the images.
  2. How to Create a bitmap using this data.

/Konstantinos

Hello,

  1. Wherever it's not used already.
  2. You cannot create a bitmap at runtime, if not a dynamic bitmap, because this would involve recompiling the application to save the data in the Flash.

Again, the best idea in my opinion is to use dynamic bitmap and load image in the RAM directly from SD card.

/Alexandre

KIlia.1
Associate II

Dr Alexandre,

And what about the case i want to receive some images through Canbus Or Uart instead of SD ?

I found This document, it describes that in those situations i can use blockCopy function.

Is this the wright way ?

and how to create a bitmapId using this function ?

https://support.touchgfx.com/docs/development/ui-development/scenarios/using-non-memory-mapped-flash/

/Konstantinos

Alexandre RENOUX
Principal

Hello,

For SD card, UART or CAN bus, the principle is the same. You implement the interface you want, to receive the image in RAM with the info such as height, width and color format.

At the beginning, you create a dynamic bitmap matching the characteristics of the image you want to send.

Then you copy the data received (the image) into your dynamic bitmap, using something like memcopy , that you can then use to display the image on screen.

/Alexandre

KIlia.1
Associate II

Dr Alexandre,

I am coming back with an other question.

I am using the the images directly from SD card using bmp file Loader, and works perfectly if i want to cash One image every time.

(

1) Delete previous Dynamic Bitmap ,

2) Create a new one ,

3)Pass the data from Sd using BMPFileLoader::readBMP24File(Bitmap Id),(BMPFileLoader::FileHdl f));

4)Use the Bitmap

)

The problem is that using this procedure i have to wait for readBMP24File every time i want to use an image.

I tried to :

1)create multiple Bitmaps,

2)Store the Bitmap IDs in a buffer,

3)Pass the data from Sd card using BMPFileLoader to every Bitmap ID ,

4)Use them in the order i need.

I started configuring the Cache in Cube

Bitmap Cashe Address : 0xC02EE000

Bitmap Cashe Size : 4616000

Bitmap Objects Count : 3

My Bitmaps Are 800*480 so this space is enough.

( I calculated that i need ( (400*480*3+1600) * 3 ) = 3.460.800 )

Results:

Bitmap IDs Are Valid

The Loader seems to work fine

I can use only the First And the Last Bitmap , whenever i try to use the Second one i get a Hart Fault.

I tried to store 4 Bitmaps (fixed the cube parameters) and i could only use the First and the Fourth one.

Is there any way to fix this ?

yours sincerely

Konstantinos

Alexandre RENOUX
Principal

I'm not sure I completely understand your issue. Could you provide the code related to your issue ?

/Alexandre

KIlia.1
Associate II

of course !!

In presenter i Create the Bitmaps

#include <gui/screen1_screen/Screen1View.hpp>
#include <gui/screen1_screen/Screen1Presenter.hpp>
 
#include "gui/common/Ui_Attributes.h"
 
static BitmapId bmpIdArray[5]= {BITMAP_INVALID};
static uint8_t  bitmapExists =0;
static uint8_t  counter =0;
static uint8_t  test =0;
 
 
Screen1Presenter::Screen1Presenter(Screen1View& v)
    : view(v),bmpId(BITMAP_INVALID)
{
	for(uint8_t i=0;i<3;i++){
 
		if (HAL::lcd().bitDepth() == 16)
		{
			bmpId = Bitmap::dynamicBitmapCreate(800/*width*/, 480/*height*/, Bitmap::RGB565);	//Hardcoded Values for debug Reasons Only
		}
		else
		{
			bmpId = Bitmap::dynamicBitmapCreate(800/*width*/, 480/*height*/, Bitmap::RGB888);   //Hardcoded Values for debug Reasons Only
		}
 
		if(bmpId != BITMAP_INVALID){
			bmpIdArray[i] =bmpId;
		}
		else{
			//nothing to do
		}
 
	}
}

LoadBitmap Function is called every time the Sd card Task , Finds the next Bitmap.

void Screen1Presenter::LoadBitmap(BMPFileLoader::FileHdl f)
{
	
	static uint8_t  locCounter =0;
	
	/*Start Debug Block of code*/
	if(locCounter > 2){
		return;
	}
		
	/*End Debug Block of code*/
	
	
	
	/*Do Not Delete the previous Bitmap*/
	
    //if we have loaded a bitmap already, delete it
//    if (bmpId != BITMAP_INVALID)
//    {
//        Bitmap::dynamicBitmapDelete(bmpId);
//    }
 
 
	/*Read the file from SD*/
    //find the width and height in the file header
    uint16_t width, height;
    BMPFileLoader::getBMP24Dimensions(f, width, height);
 
 
   bmpId = bmpIdArray[locCounter];	//locCounter the index of the Array Used for Debug Reasons Only
 
    if (bmpId != BITMAP_INVALID)
    {
        //read the bitmap file into the dynamic bitmap
        BMPFileLoader::readBMP24File(Bitmap(bmpIdArray[locCounter]/*bmpId*/), (BMPFileLoader::FileHdl)f);
 
 
//        view.showBitmap(bmpId);
    }
 
    locCounter++;
}

showBitmap Function Shows the Bitmap.

void Screen1View::showBitmap(BitmapId id)
{
 
	touchgfx::Image* ptr =NULL;
 
 
	ptr = &image1;
 
 
	ptr->setVisible(false);
 
    Bitmap bitmap(id);
	
    ptr->setBitmap(Bitmap(id));
 
 
    ptr->setXY(0,0);
 
    //make visible (image is invisible first time)
    ptr->setVisible(true);
    //invalidate bitmap to ensure new picture is drawn
    ptr->invalidate();
}

All 3 Bitmaps Id are valid

BMPFileLoader is void so i think it works fine

Whenever i use the First or the Last Bitmap i created everything works fine,

But i get Hard Fault if i use the Second one

if you need more information please let me know