2023-12-19 10:37 AM
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?
2023-12-19 11:21 AM
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...
2023-12-19 11:25 AM
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.
I use 2 Interactions for each screen (accept first and last screens) as NEXT_SCREEN & PREVIOUS_SCREEN
For NEXT_SCREEN Interaction , below is example
For PREVIOUS_SCREEN Interaction , below is example
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
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
keys.cpp
******************************
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.