cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX X-Nucleo GFX01M1 integrate hardware button.

FTrom
Associate II

I´m usiing TouchGFX with X-Nucleo GFX01M1

Being a beginner I would as a first step to change the screen with the joystick on the board.

Checking an example I notiiced that the Action is set as:

0693W00000JNrFzQAL.pngand the interacion is set as

0693W00000JNrG4QAL.png 

with Run Simulation i could manage with the keyboard of the pc, pressing the numbers ( 4 to go left, 6 to go right, etc). Idem when i flash the example to the board i can use the joystick.

I have tried to do the same, coping the settings of the previos example and it does not work.

iI fact, can see where i should set the button to do a specific command.

0693W00000JNrGEQA1.png0693W00000JNrG9QAL.png 

Checking a second example. the interaction setting is different.... there is no action and the interaction is completly different.

0693W00000JNrGYQA1.pngI had not generated any code, so I woder if the examples are running with the code in background and mine still need a code or my setting is worng. 

Thanks in advance

Fausto

3 REPLIES 3
Romain DIELEMAN
ST Employee

Hi,

You need to set the GPIOs yourself in user code to be able to use them. Those demos have the joystick implemented, but the TBS for the STM32G0 nucleo does not.

To configure it I would just suggest to open your project in STM32CubeMX and compare it with the ioc file for one of the demos to see what gpios to set.

The Aircon demo is the most recent of the two demos but I would use the other one as base for your code if you are new to TouchGFX and STM32 mcus/environment ("better" structure and "cleaner" implementation).

/Romain

Hi Roman,

The GPIOs are configurated.

As you can see once a button of the joystick are pressed the ScrenViewBase recognize it. Unfortunatly the next spep is tearDownScreen.

0693W00000JOUkDQAX.png0693W00000JOUkIQAX.pngand in the end crash

0693W00000JOUkcQAH.png 

following the a part of the code:

the Screen1ViewBase.cpp and hpp

void Screen1ViewBase::handleKeyEvent(uint8_t key)
{
    if(56 == key)
    {
        //Interaction1
        //When hardware button 56 clicked call virtual function
        //Call PressedUp
        PressedUp();
    }
    if(54 == key)
    {
        //Interaction2
        //When hardware button 54 clicked call virtual function
        //Call PressedRight
        PressedRight();
class Screen1ViewBase : public touchgfx::View<Screen1Presenter>
{
public:
    Screen1ViewBase();
    virtual ~Screen1ViewBase() {}
    virtual void setupScreen();
    virtual void handleKeyEvent(uint8_t key);
 
    /*
     * Virtual Action Handlers
     */
    virtual void PressedUp()
    {
        // Override and implement this function in Screen1
    }

Screen1View.cpp and hpp

:

void Screen1View::handleKeyEvent()
{
	int a=0;
		a+1;
}
 
void Screen1View::PressedLeft()
{
int a=0;
a+=1;
}
class Screen1View : public Screen1ViewBase
{
public:
    Screen1View();
    virtual ~Screen1View() {}
    virtual void setupScreen();
    virtual void tearDownScreen();
    virtual void handleKeyEvent();
protected:
    virtual void PressedUp();
    virtual void PressedRight();
    virtual void PressedDown();
    virtual void PressedLeft();
 
};

thanks in advance

Fausto

Hum that tearDown issue sounds odd. Does it work in the simulator or does it crash only on target ?

Quick question, have you modified the Screen1ViewBase with user code ? You shouldn't as it will always be overwritten when generating code from TouchGFX Designer.

(just a tip to not call two variables "a" when working with C++. Initialize them in the screen1View.hpp, like int32_t a, b; ) Didn't know that "a+1" worked, never tried it so good to know 😅.

/Romain