cancel
Showing results for 
Search instead for 
Did you mean: 

TouchGFX ButtonController Location

cvanbeek
Associate III

I'm creating a TouchGFX project on custom hardware and I'm a little confused about where to set the button controller for physical buttons.  As far as I can tell from the documentation, the custom button controller needs to be initialized in TouchGFXConfiguration.cpp and attached to the HAL in touchgfx_init():

static UserButtonController ubc;

void touchgfx_init()
{
    Bitmap::registerBitmapDatabase(BitmapDatabase::getInstance(), BitmapDatabase::getInstanceSize());
    TypedText::registerTexts(&texts);
    Texts::setLanguage(0);

    FontManager::setFontProvider(&fontProvider);

    FrontendHeap& heap = FrontendHeap::getInstance();
    /*
     * we need to obtain the reference above to initialize the frontend heap.
     */
    (void)heap;

    /*
     * Initialize TouchGFX
     */
    hal.initialize();
    hal.setButtonController(&ubc);
}

However, the top of `TouchGFXConfiguration.cpp` explicitly says "This file is generated by TouchGFX Generator 4.23.0. Please, do not edit!".  Additionally, the Version Control Wiki specifically says not to check in the generated folder into version control, which includes TouchGFXConfiguration.cpp.

Where should we actually be setting up the ButtonController?

2 REPLIES 2
MM..1
Chief III

Button controller is simply cpp implementaton called every tick, then you can use more simple handle hw keys in

void Model::tick()
{


...
if(HAL_GPIO_ReadPin(SW2_GPIO_Port, SW2_Pin) == GPIO_PIN_RESET) do somethink

good is add non blocking handle press and release here...

INaee.1
Senior

Hi cvanbeek ..

i am referring you one of my previous post which is close related to your requirement.

Bellow is copy / paste of my said post .

Hope it will help you .

******************************

Hi ...

For screen changing in sequence or jumping to any screen , Interaction feature is used.

INaee1_0-1703013662449.jpeg

 

I use 2 Interactions for each screen (accept first and last screens) as NEXT_SCREEN & PREVIOUS_SCREEN

For NEXT_SCREEN Interaction , below is example

INaee1_1-1703013662648.jpeg

 

For PREVIOUS_SCREEN Interaction , below is example

INaee1_2-1703013662606.jpeg

 

Tip: To keep the codes uniforms for each screen transition , name the screens like , 

Screen_01 , Screen_02 , Screen_03 etc

for each ScreenViewBase.cpp , the transition will be added like below

INaee1_3-1703013662473.jpeg

 

Now , need to code the keys read feature any one of followings

1. Simple GPIO keys without interrupt

2. SPI IO Expander Keys with interrupt

3. I2C IO Expander Keys with interrupt

I will show you 1 example > Simple GPIO keys without interrupt

keys.hpp

INaee1_4-1703013662555.jpeg

 

keys.cpp

INaee1_5-1703013662703.jpeg

 

INaee1_6-1703013662775.jpeg

 

******************************

Don't hesitate if more info required , Just Ping me ... 8)8)

bellow is one of my dev board with STM32H745 with SPI I/O Expander for Hardware Keys and many more options.

_legacyfs_online_stmicro_images_0693W00000dDVHjQAO.png