Skip to main content
Martin KJELDSEN
Principal III
March 12, 2019
Question

Interfacing with hardware in TouchGFX Applications

  • March 12, 2019
  • 10 replies
  • 6210 views

Due to popular demand, here's the information we have on interfacing with peripherals on an STM32F769-DISCO board in a TouchGFX Application.

I have two resources for this:

  1. Video: I did a webinar last year on this topic where we create an application using v4.9.3 of the TouchGFX designer and interact with push buttons through a GUI + turn on an LED using a TouchGFX Button: https://www.youtube.com/watch?v=jQO7zhX0e0Q
  2. Article: https://support.touchgfx.com/docs/development/ui-development/touchgfx-engine-features/backend-communication/. Here are the direct links for the demos i did in TouchGFX 4.9.3 (should be upgradeable) using GPIO and EXTI approach: EXTI, GPIO.

Disclaimer: The examples in the article are not maintained throughout new versions of TouchGFX.

Feel free to comment if you have any issues. Thank you!

Best regards,

Martin

This topic has been closed for replies.

10 replies

smoha
Visitor II
March 28, 2019

hello

i can't download the sample code (Error 404)..

I'm working on stm32f469ni-discovery

and trying to connect model.cpp to Main.cpp with Queue ..

with help my .. I really like to work on TouchGFX

0690X0000089AZBQA2.png

Martin KJELDSEN
Principal III
March 28, 2019

Hi @smoha​,

We're in the process of migrating files to a different server. I will fix this first thing tomorrow and let you know, allright?

Best regards,

Martin

smoha
Visitor II
March 29, 2019

Thank you martin .. I'm waiting for it ..

Martin KJELDSEN
Principal III
March 29, 2019

Try now.

smoha
Visitor II
March 29, 2019

still not..(Error 404).... but i found a sample code for STM32F746 and used it for STM32F469 .. and its working ..

https://github.com/vkeiper/TouchGfxStm32F746Disco1

Martin KJELDSEN
Principal III
March 29, 2019

Can you please provide the full link that isn't working for you? (in text, not a screenshot)

smoha
Visitor II
March 29, 2019

thank you. its working now

PJain
Visitor II
June 10, 2019

Hi @Martin KJELDSEN​ ,

Could you please provide the project file of the hardware integration project demonstrated in the Youtube webinar video? I went through the link in the comment section but it's broken.

Thanks,

Prateek Jain

Martin KJELDSEN
Principal III
June 11, 2019

Hi @PJain​,

Download the projects from Methods 3 and 4 in this article:

https://touchgfx.zendesk.com/hc/en-us/articles/205074561-Connecting-the-UI-to-your-system

/Martin

PJain
Visitor II
June 11, 2019

Hi @Martin KJELDSEN​ ,

Thanks for the quick reply. I am using STM32469I-DISCO board and trying to replicate the results from the video. Referencing from the project file you pointed out, I was able to resolve most of the errors (I had to make a change in the makefile as well). I think I am almost there, the last piece of code I am stuck at is the following error:

C:\Users\pjain\Desktop\MyApplication1/target/main.cpp:107: undefined reference to `led_task'

collect2.exe: error: ld returned 1 exit status

When I disable the xTaskCreate for led_task in main.cpp, the code is compiled and uploaded to the MCU (without any hw integration). I am not sure why am I getting this error. I have defined void led_task(void* params) in ledtask.h and also included the ledtask.h in main.cpp

PFA my project for your reference. Please let me know if you have any solution/workaround to this error.

Thanks,

Prateek

Martin KJELDSEN
Principal III
June 17, 2019

The task definition is in a seperate file. Are you sure you're compiling this file? It's in the target/ folder and is called "ledtask.c"

/Martin

PJain
Visitor II
June 17, 2019

Thanks for pointing that I out, I forgot to include ledtask.c in Makefile!

Also, I had to add $(application_path)/target in the include path as well on line 171 of Makefile (I don't know if it's the right thing to do it but without it, ledtask.h is not being recognized in Model.cpp file).

Now, I am able to compile my code :) but the display is not working properly (PFA the image). If I disable the led_task, the display works fine (without hw integration). I even tried disabling the code inside the led_task but the issue is persistent. I don't know if it's something to do with the Makefile. PFA my project for reference.0690X000008iqJ4QAI.jpg

RCair
Visitor II
June 17, 2019

Olá,

no arquivo (target/main,cpp) deveria estar

extern "C"

{

#include "ledtask.c"

#include "btntask.c"

}

não tenho certeza!

Martin KJELDSEN
Principal III
June 17, 2019

Not sure i follow you, cmelo. Could you say that in english?

/Martin

NMung.1
Associate
August 6, 2020

Hello everyone, I've started developing a custom board based on stm32f767IGTX MCU with LDTC display (800*480), it's now two months since I've started. so far so good...I just want help on how to had more buttons via the buttoncontroller class and how to add them into the touchgfx application (touchgfx template). bellow you will find the class for buttoncontroller that handle the physical button too...but I am stuck on How to add more physical buttons. If you gotta time, your help will be great.

thank you....

class F767ButtonController : public touchgfx::ButtonController
{
	virtual void init() { }
 
 
	/**
	* Implement all the hardware buttons handlers by the defining the port address and carrier name
	*/
	void delay(int d)
	{
		int i; 
	/**for loop counter for the timer, if your using crusial Real time application please implement
	 * find a better to implement this delay function for more accuraccy.
	 */
		for (i= 0; i < (d*10000); i++)
		{
			float a = 0.0f; // local variable a for the for custom time to monitor the tigger state
			a += (i / 0.1f);
		}
	}
 
 
	virtual bool debounce(bool last)
	{
		
		bool current = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13); //Read the button state
		if (last != current) //if it's different…
		{
			delay(1000);
			current = HAL_GPIO_ReadPin(GPIOC, GPIO_PIN_13); //read it again
		}
		return current; //return the current value
	}
 
 
	virtual bool sample(uint8_t& key)
	{
 
		bool lastButton = false;
		bool currentButton = false;
 
		currentButton = debounce(lastButton); //read deboucned state
		if (lastButton == false && currentButton == true) //if it was pressed...
		{
			key = 1; //toggle the state of the button
 
			return true;
		}
 
		lastButton = currentButton; //reset button value
 
		return false;	
	}
 
private:
 
};

Romain DIELEMAN
ST Employee
August 6, 2020

Hi,

I would recommend creating a new topic with maybe a link to this one. This question might otherwise be lost in the older comments.

/Romain

NMung.1
Associate
August 6, 2020

Thank you very much Romain, I am really a "newbie"....do you mind to tell =) me how to create a new topic?

Martin KJELDSEN
Principal III
August 10, 2020

Go to https://community.st.com/s/topic/0TO0X0000003iw6WAA/touchgfx

and press the "Ask a question" button =) Also, maybe clarify what you mean by "adding more physical buttons". Do you mean in hardware or in software?

/Martin