GUI_GetKey() and BUTTON_IsPressed() behavior

This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

  • GUI_GetKey() and BUTTON_IsPressed() behavior

    Hi all I am experimenting for a new applications.
    I wrote a simple application to test the hardware it only displays a button and triggers an event if pressed.

    Touch screen controller is the AD7846 and its routines are implemented in GUI_X_Touch.c returning ADC readings in MEASURE_X and MEASURE_Y functions.

    GUI_TOUCH_Exec(); is polled in an interrupt routing that fires every 20mS (GPIO toggle is for debug...)

    C Source Code

    1. void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
    2. if (htim->Instance == TIM6){
    3. GUI_TOUCH_Exec();
    4. HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_5);
    5. }
    6. }


    than this is the main function (only relevant part shown).
    Well: if to check the button pressing I use if(BUTTON_IsPressed(hButton) == 1) the program works, if, like in many example I use (GUI_GetKey() == GUI_ID_BUTTON0) the program got stuck and also the interrupt routine does not fire anymore (no led toggle). You can only reset the MCU.

    What I can see with the debugger is that the GUI_GetKey() function never returns true. BTW the program never arise a fault exception, so I cannot explain the ISR lockup.

    Any advice? :)

    Many thanks.



    C Source Code

    1. int main(void)
    2. {
    3. HAL_Init();
    4. SystemClock_Config();
    5. MX_GPIO_Init();
    6. MX_I2C2_Init();
    7. MX_CRC_Init();
    8. MX_FSMC_Init();
    9. MX_SPI1_Init();
    10. MX_RTC_Init();
    11. MX_TIM6_Init();
    12. GUI_Init();
    13. HAL_TIM_Base_Start_IT(&htim6);
    14. CALIBRATION_Check();
    15. GUI_SetBkColor(GUI_BLACK);
    16. GUI_Clear();
    17. hButton = BUTTON_CreateEx(110,110,100,40,0,WM_CF_SHOW,0, GUI_ID_BUTTON0);
    18. BUTTON_SetText(hButton, "Click me...");
    19. GUI_Exec();
    20. while (1) {
    21. if (BUTTON_IsPressed(hButton)) {
    22. BUTTON_Delete(hButton);
    23. GUI_ClearRect(0,0,479,271);
    24. GUI_SetColor(GUI_RED);
    25. GUI_DispStringAt("CIAO", 16, 16);
    26. break;
    27. }
    28. GUI_Delay(10);
    29. while(1){}
    30. }
    Display All