AnsweredAssumed Answered

Getting the touch functionality working with Stemwin on STM32F7 discovery board?

Question asked by 123.abc on Mar 27, 2016
Latest reply on Apr 11, 2018 by Luis Pereira
Hi all, I am trying to use the stemwin library on STM32F7 discovery board. I have been able to get it to display what I want, but have not been successful in getting the touch functionality working. I can see the X and Y values change ,but the callback functions never get called.

I have an interrupt routine that calls the GUI_Touch_StoreStateEx() function. I have checked the Touch_X_Pos  and Touch_Y_Pos variables and they correspond to the area of LCD that was touched with the (0,0) indicating the top left position.
void EXTI15_10_IRQHandler(void)
{
    GUI_PID_STATE State;
     
    if(__HAL_GPIO_EXTI_GET_IT(GPIO_PIN_13) != RESET)
    {
     
        HAL_I2C_Mem_Read(&hi2c3, 0x70, 0x04, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Temp , 1, 1000);
        Touch_Y_Pos = (uint16_t) (Temp);
        HAL_I2C_Mem_Read(&hi2c3, 0x70, 0x03, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Temp , 1, 1000);
        Touch_Y_Pos = Touch_Y_Pos | (((uint16_t) (Temp & 0x0F))<<8);
        Touch_Event = (Temp & 0xC0) >> 6;
 
        HAL_I2C_Mem_Read(&hi2c3, 0x70, 0x06, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Temp , 1, 1000);
        Touch_X_Pos = (uint16_t) (Temp);
        HAL_I2C_Mem_Read(&hi2c3, 0x70, 0x05, I2C_MEMADD_SIZE_8BIT, (uint8_t*)&Temp , 1, 1000);
        Touch_X_Pos = Touch_X_Pos | (((uint16_t) (Temp & 0x0F))<<8);
         
         
        if (Touch_Event==2)
        {
            State.x = Touch_X_Pos;
            State.y = Touch_Y_Pos;
            State.Pressed = 1;
               GUI_TOUCH_StoreStateEx(&State);
            //HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
        }
        else if (Touch_Event ==1)
        {
            State.Pressed = 0;
            State.x = -1;
            State.y = -1;
            GUI_TOUCH_StoreStateEx(&State);
            //GUI_TOUCH_StoreState(-1,-1);
        }
         
         
        __HAL_GPIO_EXTI_CLEAR_IT(GPIO_PIN_13);
         
        Touch_Event_Previous = Touch_Event;
    }



Here is a snippet of my main routine and the callback functions.

Window_1  = WM_CreateWindow(0, 0, 480, 272,WM_CF_SHOW | WM_CF_STAYONTOP, &cbForegroundWin, 0);
 
SPINBOX_Delay_in_s = SPINBOX_CreateEx(170, 0, 50, 25, Window_1,WM_CF_SHOW,SPINBOX_Delay_in_s_ID, 0, 10);
SPINBOX_Delay_in_us = SPINBOX_CreateEx(170, 25, 75, 25, Window_1,WM_CF_SHOW,SPINBOX_Delay_in_s_ID, 0, 1000000);
SPINBOX_Sensitivity = SPINBOX_CreateEx(170, 50, 50, 25, Window_1,WM_CF_SHOW,SPINBOX_Delay_in_s_ID, 0, 100);
 
BUTTON_Start =  BUTTON_CreateEx(166, 245, 70, 35, Window_1, WM_CF_SHOW, 0, BUTTON_Start_ID);
WM_SetCallback(BUTTON_Start, BUTTON_Start_Callback);
BUTTON_Stop =   BUTTON_CreateEx(235, 245, 70, 35, Window_1, WM_CF_SHOW, 0, BUTTON_Stop_ID);
BUTTON_SetText(BUTTON_Start, "START");
BUTTON_SetText(BUTTON_Stop, "STOP");
GUI_Exec();
void cbForegroundWin(WM_MESSAGE * pMsg)
{
    count = count + 1;
    int Id;
    int NCode;
     
    switch (pMsg->MsgId)
        {
             
    case WM_PAINT:
        GUI_SetFont(&GUI_Font8x16);
        GUI_SetColor(GUI_WHITE);
        GUI_SetTextMode(GUI_TM_NORMAL);
        GUI_DispStringAt("Delay ( in s )     :", 1, 8);
        GUI_DispStringAt("Delay ( in us )    :", 1, 35);
        GUI_DispStringAt("Sensitivity (in %) :", 1, 60);
        break;
     
    case WM_NOTIFY_PARENT:
        HAL_GPIO_TogglePin(GPIOI, GPIO_PIN_1);
        Id    = WM_GetId(pMsg->hWinSrc);
    NCode = pMsg->Data.v;
        switch(Id){
            case BUTTON_Start_ID:
                switch(NCode) {
                    case WM_NOTIFICATION_CLICKED:
                        break;
                    case WM_NOTIFICATION_RELEASED:
                        break;
                    case WM_TOUCH:
                        break;
                    default:
                        break;
                }
            }
         
     default:
        WM_DefaultProc(pMsg);
     
     }
}
 
void BUTTON_Start_Callback(WM_MESSAGE * pMsg)
{
    count = count + 1;
    switch (pMsg->MsgId)
        {
            default:
                BUTTON_Callback(pMsg);
                break;
        }

}



Outcomes