Skip to main content
CHech.1
Associate III
September 1, 2021
Question

handleKeyEvent() - where is it called from?

  • September 1, 2021
  • 1 reply
  • 2248 views

Hi,

I'm working with STM32L496AG Discovery's built-in joystick and trying to understand how the Designer receives input from it (I configured a Hardware Button Trigger).

By looking at the code, it seems like the following method is a dead end:

//Handles when a key is pressed
void Screen1ViewBase::handleKeyEvent(uint8_t key)

The Cube IDE says it is not referenced anywhere.

Should I assume that it is interrupt based, and that the hardware calls this method directly?

If so, how can I "tell the hardware/interrupt" to call another method?

If not, then how\where is it called and why can't I find it using the IDE?

Thanks in advance!

1 reply

MM..1
Chief III
September 1, 2021

This handler is invoked when a key (or button) event has been detected by the system.

Parameters:

cThe key or button pressed.

Perfect way for understand and test is place to this for example

if (key == ´A´) ...

and when run simulator press A on keyboard PC.

How to invoke this for GPIO or EXTI is showed in examples. But simply in handletickevent check GPIO and call handleKeyEvent(´A´)

CHech.1
CHech.1Author
Associate III
September 1, 2021

Thank you for the answer.

I may have been not clear.

I understand what happens "in the method", what I don't understand is how is it called.

The IDE says it isn't called anywhere, although it is definitely called as I programmed a menu screen which is navigable using the joystick, and the "goLeft()/goRight()" methods that are used in it are called only from the handleKeyEvent() method.

So, I'd like to know how "the system detects an event" as you said, and where does it happen.

As I thought all interrupts must first pass through "EXTI9_5_IRQHandler" or similar methods in "stm32lxx_it.c" , but none of these leads to handleKeyEvent().

Again, thank you!

MM..1
Chief III
September 3, 2021

I dont check, but in normal is called from Application class. And in older releases TouchGFX i invoke this semihardware buttons by call

if (HAL_GPIO_ReadPin(SW_PWR_GPIO_Port, SW_PWR_Pin) == GPIO_PIN_RESET && filter == false && timeout1.t == 0)
 {
 filter = true;
 static_cast<FrontendApplication*>(Application::getInstance())->handleKeyEvent(85);
 }