cancel
Showing results for 
Search instead for 
Did you mean: 

[SOLVED ] How I can generate the event MOUSEBUTTONDOWN from an external function ?

I receive the external event from infrared remote and I want to simulate the click on a specific button.

Here the port PA15 is used like IR input, this code has been add in the file stm32746g_discovery.c.

void EXTI15_10_IRQHandler(void)

{

 HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_15);

 if (HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_15)) return;

 BSP_LED_Toggle(LED_GREEN);

.....

[decode IR]

[click button]

}

void BSP_IR_Init()

{

 GPIO_InitTypeDef gpio_init_structure;

 __HAL_RCC_GPIOA_CLK_ENABLE();

 gpio_init_structure.Pin = GPIO_PIN_15;

 gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;

 gpio_init_structure.Pull = GPIO_PULLUP;

 HAL_GPIO_Init(GPIOA, &gpio_init_structure);

 HAL_NVIC_SetPriority(EXTI15_10_IRQn, 0, 0);

 HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);

}

in the file Screen1View.cpp

void Screen1View::setupScreen()

{

   #ifdef SIMULATOR

        printf("LED on\n");

   #else

        BSP_LED_Init(LED_GREEN);

        BSP_IR_Init();

...........

1 REPLY 1

Add the code to manage the event in this function and insert this in the same file of the other touch event like buttonUpClicked() so in the file Screen1View.cpp.

Declare in the file Screen1View.hpp with virtual void handleTickEvent();.

void Screen1View::handleTickEvent()

{

   if (key == 1) // external event received in my case the infrared receiver

   {

       touchgfx::Unicode::snprintf(IRBuffer, IR_SIZE, "Test IR");

       IR.setWildcard(IRBuffer);

       IR.resizeToCurrentText();

       IR.invalidate();

       buttonUpClicked();

       key = 0;

   }

}