cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX integration with Middlewares : USB Mass Storage and microSDCard.

Karan 123
Senior

Hi,

I am working on below setup:

Software Tool Chain:

STM32CubeMX 5.6.0

TouchGFX 4.13.0 Designer

STM32CubeIDE 1.3.0

STM32F746G Discovery Kit v3.0.1 (AT)

Hardware:

STM32F746G-DISCO (Discovery Board)

USB Mass Storage Drive (32 GB)

microSDCard (64 GB)

I have gone through below link studied and implemented examples given there.

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/

with ADC and UART with TouchGFX.

I got (think) the most efficient way is to use TouchGFX Ecosystem with FreeRTOS MVP .

Now I have to integrate Middleware like USB Mass Storage Device , SDCARD FAT32 +exFAT

with TouchGFX GUI.

Unfortunately, There is no example so for on touchgfx.com.

In my application, I have to copy File from USB Mass Storage to SDCard with TouchGFX GUI (Scroll List) with Add/remove feature .

USB Mass Storage and SDCard with FATFS + exFAT works well without TouchGFX .

How to I transfer "File Names" from USB Mass Storage to TouchGFX GUI scroll list?

So for simplicity, I have created array in main.c then try to transfer to GUI Scroll List Items.

But so far there is no example I have seen on touchgfx website, Is this the prefect/right method of not ?

I have written some steps as attachment .

Please advice how to proceed this ..

Thank in advance ..

--

Karan

17 REPLIES 17
Karan 123
Senior

I mean to say that how to propagate data (Array -2D) File Name in my case :

From

Application data (File Names) -> Model -> Presenter -> view -> Scroll List Items(Custom Container)

and

Scroll List Item -Select any one) (Custom Container) -> view -> Presenter -> Model -> Application

For further processing..

Alexandre RENOUX
Principal

Hello,

I don't completely understand your problem.

Can you read from your USB storage and write to your SDCard ? Can you access the names of the files stored in the USB storage ?

If you can, then the documentation you linked yourself should help you bring this information to your UI (https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/).

You are talking about if it's the perfect method but does your method works ? Why do you think your method is not correct ?

/Alexandre

Thanks for your time and reply.

"I don't completely understand your problem."

->The problem is integration with Middleware with TouchGFX . I have worked on GUI application development with some others MCUs (not ST) and their libraries but without RTOS .

Can you read from your USB storage and write to your SDCard ? Can you access the names of the files stored in the USB storage ?

->Yes , I am able to read files names from USB storage and then save the SDCard perfectly with Serial Terminal as Output and mechanical Push Button without TouchGFX.

https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/

The above is good reference interfacing TouchGFX with Mechanical User button , LED only exchange single bit only with FreeRTOS Queue .

I have also managed to interface LED and Hardware Push Button with TouchGFX Button and ​TextArea Successfully with FreeRTOS Queue.

I am seeking example program or How I can do

To propagate data (Array -2D) File Name in from Application data (File Names) -> Model -> Presenter -> view -> Scroll List Items(Custom Container). 

and Scroll List Item -Select any one) (Custom Container) -> view -> Presenter -> Model -> Application

For further processing..

"You are talking about if it's the perfect method but does your method works ? Why do you think your method is not correct ?"

->But I don't have any experience on RTOS ( FreeRTOS in this case ) . Quite new for propagating the data (Array -2D) File Name in my case.

Because of no experience , I have not tested yet.

Thanks for your concern..Hope Now I am clear to you..

--

Karan

Hello,

Yes I think I understand your problem more.

From what I can see the only thing that is not explained in the Backend Communication Documentation page ( https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/ ) is the sending of strings in a queue from your secondary task to your Model::tick() because the examples show only simple data communication like a button state or a led state.

We don't have any examples where we send arrays of strings from one task to another.

Therefore, to send a string you need to create your queue accordingly like:

xQueueCreate(9, sizeof(char)); // 9 corresponds to size of string
 
const char *fileName1=�?Hello.png�?;
 
/* Queue a pointer. */
 
xQueueSend(gui_msg_q, &fileName1, 0);

For an array of strings, I guess doing as follows would work:

xQueueCreate(MaxStringNamelength, sizeof(char));
 
const char fileNames[nbOfFiles][MaxStringNamelength]={�?Hello.png�?, "TouchGFX.txt",...};
 
/* Queue a pointer. */
 
for(...)
{
    xQueueSend(gui_msg_q, &fileNames[i], 0);
}

Anyway you should also try your approach nonetheless and see if it reports any errors.

You can also remove FreeRTOS if you are more comfortable like this. TouchGFX can run on bare metal.

/Alexandre

Hi,

As , USBMSDQueueTXRoutine() is called in side the StartTaskUSBTx .

Do I need to delete osThreadTerminate(USBTxTaskHandle) or anything method ? To avoid indefinite send to queue ?

void StartTaskUSBTx(void const * argument)
{
  /* USER CODE BEGIN StartTaskUSBTx */
  /* Infinite loop */
  for(;;)
  {
    USBMSDQueueTXRoutine();
    osDelay(100);
  }
  /* USER CODE END StartTaskUSBTx */
}
 
 
 
// Step No. 3  in USBMassStorage.c
 
#define MaxQueueSize               11
#define MaxElementsPerQueue        20
 
extern  osMessageQId  messageQ_USB ;
char TxBuffer[MaxQueueSize][MaxElementsPerQueue]=
{
	 "BANSAL.bmp"     , "HELLO.png"   ,
     "TouchGFX.txt"   , "STM32F7.doc" ,
     "SCROLL.bmp"     , "NEW.xlsx"    ,
     "LIST2.jpg"      , "GOOD.bmp"    ,
     "ABC.png"        , "XYZ.bmp"
} ;
 
 
void USBMSDInit()
{
	// main.c
 
}
void USBMSDQueueTXRoutine()
{
	unsigned char i;
	printf("\n\rTask2, Filling the data onto queue");
 
	HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
	for(i=0;i<5;i++)
	{
		if(pdTRUE == xQueueSend(messageQ_USB ,TxBuffer[i],(TickType_t)100  ) )
		{
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
			 printf("\n\rTask2: Successfully sent the data");
		}
		else
		{
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
			printf("\n\rSending Failed");
		}
	}
	HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
	//  osThreadTerminate(USBTxTaskHandle);    ???  .. Please Advice
 
}

void Model::tick()
{
		  HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
		  printf("\n\rTask1, Reading the data from queue");
 
		  for(int i=0;i<5;i++)
		  {
			  if(pdTRUE == xQueueReceive(messageQ_USB,RxBuffer[i],(TickType_t)100 ))
				{
					HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
					printf("\n\rBack in task1, Received data is:%s",RxBuffer[i]);
 
					USBRx(RxBuffer[i]) ;
				}
				else
				{
					HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_RESET) ;
					printf("\n\rBack in task1, No Data received");
				}
			}
			HAL_GPIO_WritePin(LED_GPIO_Port , LED_Pin , GPIO_PIN_SET) ;
 
			osThreadTerminate(USBRxTaskHandle);   // ????  Please advice 
 
}

When fileNames (RxBuffer) string received by queue ..,

Can you give check below and add/correct that how to do

-> Model -> Presenter -> view -> Scroll List Items(Custom Container) ?

//fileNames string recevied by queue ..
 
//  Step No. 4 in Screen1Presenter.cpp
void Model::USBRx(char temp_RxBuffer[] )
{
  //fileNames
   modelListener-> USBRx(temp_RxBuffer);
}
//  Step No. 5 in Screen1Presenter.cpp
void Screen1Presenter::USBRx(char temp_RxBuffer[] )
{
             //fileNames
	   view.USBRx(temp_RxBuffer) ;
	   touchgfx_printf("In USBRx View \n");
}
// Step No. 6 in Screen1View:.cpp
void Screen1View::USBRx(char temp_RxBuffer[])
{
	// How to Update Here.. ?????????????
	// For Container List Items.
	touchgfx_printf("temp_RxBuffer = %s\n" ,temp_RxBuffer ) ;
}
// Step No. 7
extern char Rx_Buffer1[11][20] ;
MenuElement::MenuElement():
	index(0),
    selected(false)
{
 
}
void MenuElement::initialize()
{
    MenuElementBase::initialize();
}
void  MenuElement::UpdateFileNameArrayInMasterList(int no)
{
        memset( &textArea3Buffer , 0 , TEXTAREA3_SIZE) ;
    	touchgfx_printf("setNumber = %d\n" ,no) ;
 
    	// Unicode::itoa(no,textArea3Buffer, TEXTAREA3_SIZE , 10)  ;
       	Unicode::strncpy(textArea3Buffer ,(char *) Rx_Buffer1[no] , TEXTAREA3_SIZE -1 ) ;
}

I want to do as below:

0693W000001caV5QAI.png

"You can also remove FreeRTOS if you are more comfortable like this. TouchGFX can run on bare metal"

I think I should go for FreeRTOS to take full advantage of TouchGFX and STM32746 MCU ? Please advice ..

--

Karan

When i get around to it i'll show you how to convert ascii->unicode/unicode->ascii and send it through a freertos message queue using a struct with various members grabbing the values on the other side and propagating it to your ui.

Hi Martin,

​Thanks for Update but didn't get you.

--

Karan​

Hi,

@Alexandre RENOUX (ST Employee) And

@Martin KJELDSEN (ST Employee)

Waiting for reply..

--

Karan

Hi,

I am really stuck at here. Please Update Or any tutorial link. How to do so?

--

Karan​