Skip to main content

TouchGFX Graphical User Interface with STM32



 Introduction :

               TouchGFX is an advanced GUI tool offering everything you need to create cutting-edge GUIs. TouchGFX is an advanced, free-of-charge GUI optimized for STM32 microcontrollers. TouchGFX accelerates the HMI-of-Things revolution through the creation of stunning smartphone user interfaces on embedded devices ranging from simple low-color UI applications up to high-resolution and high-color UI applications. TouchGFX is optimized for STM32 microcontrollers, needing only a limited amount of memory for running smooth GUIs.


TouchGFX is distributed as an X-CUBE-TOUCHGFX zip file which has the following components inside:

  • TouchGFX Designer - Build a UI through a Windows-based GUI Builder
  • TouchGFX Generator - Create a custom TouchGFX HAL through CubeMX
  • TouchGFX Engine - The TouchGFX C++ framework that drives the UI application

Installation :

First of all, you need to download X-CUBE-TOUCHGFX from the ST.com official website .After you follow following link to installation process.

https://support.touchgfx.com/docs/introduction/installation

First Screen  after installing, you see it.




We are using  STM32F429I-Discovery Board so select it from Template as shown below pic.


First  this is introduction screen for creating project is as below.

TouchGFX Screen

screens : screen panel show you created screens, and widgets nest added to that screen. from ➕  you can add screen as per your requirement.

Widgets : From this menu you can create button, text area , different type of control for screen, you just have to drags and drop control. its properties you can change it. 

Interaction : This is tool work for interaction with widgets for any action like click, drag, touch...and trigger event.

Now We are creating one Simple Project  using STM32F429I - Discovery Board As shown as below.

STM32F4 TouchGFX

Create simple project as drag and drop facility available on TouchGFX as show below

TouchGFX Screen


 

After creating screen need to write interaction event for change Button and Toggle Button for that we are adding interaction. First select event from drop down of Trigger, we are selecting Button is clicked ,select source widget for which your creating event from choose clicked source drop down list. select virtual function call from Action drop down list. last write virtual function name as per your choice in Action text area. Last but not least is interaction name. you can also change it as per your choice.




     Model-View-Presenter Design Pattern

 TouchGFX follows the Model-View-Presenter (MVP) design pattern as described in Model-View-Presenter Design Pattern. The TouchGFX screen concept ties into the overall Model-View-Presenter architecture by classes that inherit from the View and Presenter classes in TouchGFX. So when adding a new screen to your application in TouchGFX Designer it creates both a new specific View class and a Presenter class to represent that particular screen.
The content and responsibility of the MVP classes in a TouchGFX application are as follows.



Model-View-Presenter and external communication


Model:

The Model class is a singleton class which is always alive and has two purposes:


1. Store state information for the UI. The Views and Presenters are deallocated when switching screen, so they cannot be used to store information which should be kept across screen transitions. Use the Model for this instead.

2. Act as an interface towards the backend system, relaying events to and from the currently active

screen. The Model class is automatically setup to have a pointer to the currently active presenter. When changes occur in the Model the current active Presenter is notified of the change. This is done via methods in the ModelListener interface in the application.
New applications generated by the Designer will automatically have a Model class ready to be used by the UI.


View: 

The View class (or more specifically, a class that derives from the TouchGFX View class) contains the widgets that are shown in this view as member objects. It also contains a setupScreen and a
tearDownScreen function, which gets automatically called when this screen is entered/exited. Typically you would configure your widgets in the setupScreen function.

Your View will also contain a pointer to the associated Presenter. This pointer is set up automatically by the framework. Using this pointer you can communicate UI events like button clicks to the Presenter.


Presenter: 

Your Presenter class (again, a class that derives from the TouchGFX Presenter class) is responsible for the business logic of the currently active screen. It will receive "backend" events from the Model, and UI events from the View and decide which action to take. For instance, if an alarm event is received from the Model, the Presenter might decide to tell the View that an alarm popup dialog should be displayed.

Now Its time to Run simulator to preview than after run generate generate code button to create code. 

After it open brows folder for hierarchies structure to show as shown in below.

Project Folder 

After that open STM32CubeIDE Folder -> Open .Project file to STM32CubeIDE. As Shown below.

Project open in STM32CubeIDE


As shown in project Hierarchy we have to implement virtual function for interaction which we have created BackcolorChange()  and ONOFFLED();

we need to do it in sceen1View files.

In gui folder ----> Screen1View.cpp file .

we have declare function in Screen1View.hpp file  as shown below.

    virtual void BackcolorChange();

    virtual void ONOFFLED();

after that define both function in Screen1View.cpp file.



  
void Screen1View::BackcolorChange()
{

   boxWithBorder1.setColor(boxWithBorder1.getColor()+1234);
   boxWithBorder1.invalidate();

}

void Screen1View::ONOFFLED()
{

   HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_13);
   HAL_Delay(200);
}


Comments

Popular posts from this blog

ARDUINO PORTENTA H7 Tutorial

Portena H7 simultaneously run high level code along with real time tasks. H7 main processor is the STMICROELECTRONICS dual core STM32H747  including an ARM CORTEX -M7 running at 480 MHz and ARM COTEXT M4 running at 240MHz. The two core communicate via a Remote Procedure call mechanism that allows calling functions on the other processor seamlessly. The  Portenta H7  simultaneously runs high level code along with real time tasks, since it includes two processors that can run tasks in parallel. For example, it is possible to execute Arduino compiled code along with MicroPython one and have both cores to communicate with one another. The Portenta functionality is two-fold, it can either be running like any other embedded microcontroller board or as the main processor of an embedded computer. There are many features in one module  STM32H747 dual-core processor 8 MB SDRAM 16 MB  NOR FLASH 10/100 ETHERNET PHY USB HIGH SPEED SECURE ELEMENT WIFI/ BLUETOOTH MODULE UFL CO...

Getting Started with mmWave Sensor MR60BHA1 and Arduino

Introduction : The MR60BHA1 mmWave Sensor is a compact and efficient radar sensor that utilizes millimeter-wave technology to detect objects, measure distance, and track motion. With its high precision and low power consumption , this sensor is ideal for applications in robotics, automation, and security systems. . Millimeter-wave (mmWave) sensors operate at extremely high frequencies, typically in the 30GHz to 300GHz range, allowing them to detect objects with great accuracy regardless of lighting conditions. Unlike optical sensors, mmWave sensors can penetrate fog, dust, and even certain materials, making them reliable in harsh environments. The MR60BHA1 is one such sensor that operates at 60GHz , providing precise motion detection and range measurement capabilities. By integrating the MR60BHA1 with an Arduino , users can develop a variety of projects, such as human presence detection , security systems , and robotic navigation . In this blog, we will explore how to interface...

Exploring Color Sensing with Arduino: A Journey into the World of RGB Detection

                           In today's tech-driven world, the Arduino platform continues to empower enthusiasts and professionals alike to explore the realms of electronics and programming. One fascinating avenue within this domain is color sensing using Arduino boards. With the integration of RGB sensors, Arduino opens up a world of possibilities for projects ranging from color sorting machines to ambient light displays. Let's delve into the exciting world of color sensing with Arduino and discover its applications, principles, and how you can embark on your own creative endeavors. Understanding Color Sensing       At the heart of color sensing lies the ability to distinguish between different wavelengths of light. RGB (Red, Green, Blue) sensors are commonly used for this purpose. These sensors typically consis...