/** * @brief Configures and gets Touch screen position. * @param None * @retval None */ static void GetPosition(void) { static uint32_t color_width; static uint32_t color; if (BSP_LCD_GetXSize() == 640) { color_width = 36; } else { color_width = 19; } /* Get Touch screen position */ BSP_TS_GetState(&TS_State); /* Read the coordinate */ x = Calibration_GetX(TS_State.x); y = Calibration_GetX(TS_State.y); if ((TS_State.TouchDetected) & (x > (67 + Radius)) & (y > (7 + Radius) ) & ( x < (BSP_LCD_GetXSize()-(7 + Radius )) ) & (y < (BSP_LCD_GetYSize()-(67 + Radius )) )) { BSP_LCD_FillCircle((x), (y), Radius); } else if ((TS_State.TouchDetected) & (x > 0 ) & ( x < 50 )) { if ((TS_State.TouchDetected) & ( y > 0 ) & ( y < color_width )) { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); Update_Size(Radius); } else if ((TS_State.TouchDetected) & ( y > color_width ) & (y < (2 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (2 * color_width)) & (y < (3 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (3 * color_width)) & (y < (4 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_LIGHTMAGENTA); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (4 * color_width)) & (y < (5 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (5 * color_width)) &(y < (6 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (6 * color_width)) &(y < (7 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_BROWN); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (7 * color_width)) & (y < (8 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_RED); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (8 * color_width)) & (y < (9 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKMAGENTA); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (9 * color_width)) & (y < (10 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_CYAN); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (10 * color_width)) & (y < (11 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (11 * color_width)) & (y < (12 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_BLACK); Update_Size(Radius); } else if ((TS_State.TouchDetected) & (y > (12 * color_width)) & (y < (13 * color_width))) { /* Get the current text color */ color = BSP_LCD_GetTextColor(); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); /* Clear the working window */ BSP_LCD_FillRect(68, 8, (BSP_LCD_GetXSize() - 75), (BSP_LCD_GetYSize() - 75)); BSP_LCD_SetTextColor(color); } else { x = 0; y = 0; } Update_Color(); } else if ((TS_State.TouchDetected) & (x > 70 ) & (y > (12 * color_width)) & (y < (13 * color_width)) & ( x < 120 )) { Radius = 20; Update_Size(Radius); } else if ((TS_State.TouchDetected) & (x > 120 ) & (y > (12 * color_width)) & (y < (13 * color_width)) & ( x < 170 )) { Radius = 15; Update_Size(Radius); } else if ((TS_State.TouchDetected) & (x > 170 ) & (y > (12 * color_width)) & (y < (13 * color_width)) & ( x < 220 )) { Radius = 10; Update_Size(Radius); } else if ((TS_State.TouchDetected) & (x > 220 ) & (y > (12 * color_width)) & (y < (13 * color_width)) & ( x < 270 )) { Radius = 5; Update_Size(Radius); } else if ((TS_State.TouchDetected) & (x > 270 ) & (y > (12 * color_width)) & (y < (13 * color_width)) & ( x < 320 )) { Radius = 2; Update_Size(Radius); } else if ((TS_State.TouchDetected) & (((x > (BSP_LCD_GetXSize()-5) ) & (y > (12 * color_width)) & (y < (13 * color_width))) | (( x < 55 ) & ( y < 5 )))) { TS_State.x = 0; TS_State.y = 0; } else if ((TS_State.TouchDetected) & (x > 320) & (y > (BSP_LCD_GetYSize() - 50)) & (x < 370) & (y < BSP_LCD_GetYSize() )) { Save_Picture(); } }
/** * @brief Configures and gets Touch screen position. * @param None * @retval None */ static void GetPosition(void) { static uint32_t color_width; static uint32_t color; uint16_t x, y; color_width = 35; /* Get Touch screen position */ BSP_TS_GetState(&TS_State); if(TS_State.touchDetected) { /* A touch occured, read the touch coordinates */ /* Get X and Y position of the first touch post calibrated */ x = TouchScreen_Get_Calibrated_X(TS_State.touchX[0]); y = TouchScreen_Get_Calibrated_Y(TS_State.touchY[0]); if((x > (90 + Radius)) & (y > (7 + Radius) ) & ( x < (BSP_LCD_GetXSize() - (7 + Radius ))) & (y < (BSP_LCD_GetYSize() - (95 + Radius )))) { BSP_LCD_FillCircle((x), (y), Radius); } else if((x > 0 ) & ( x < 90 )) { if((y > 0 ) & (y < color_width )) { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); Update_Size(Radius); } else if((y > color_width ) & (y < (2 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); Update_Size(Radius); } else if((y > (2 * color_width)) & (y < (3 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); Update_Size(Radius); } else if((y > (3 * color_width)) & (y < (4 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_LIGHTMAGENTA); Update_Size(Radius); } else if((y > (4 * color_width)) & (y < (5 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN); Update_Size(Radius); } else if((y > (5 * color_width)) &(y < (6 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); Update_Size(Radius); } else if((y > (6 * color_width)) &(y < (7 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_BROWN); Update_Size(Radius); } else if((y > (7 * color_width)) & (y < (8 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_RED); Update_Size(Radius); } else if((y > (8 * color_width)) & (y < (9 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKMAGENTA); Update_Size(Radius); } else if((y > (9 * color_width)) & (y < (10 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_CYAN); Update_Size(Radius); } else if((y > (10 * color_width)) & (y < (11 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); Update_Size(Radius); } else if((y > (11 * color_width)) & (y < (12 * color_width))) { BSP_LCD_SetTextColor(LCD_COLOR_BLACK); Update_Size(Radius); } else if((y > (12 * color_width)) & (y < (14 * color_width))) { /* Get the current text color */ color = BSP_LCD_GetTextColor(); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); /* Clear the working window */ BSP_LCD_FillRect(97, 8, 694, 374); BSP_LCD_SetTextColor(color); } else { x = 0; y = 0; } Update_Color(); } else if((x > 100) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 170)) { Radius = 15; Update_Size(Radius); } else if((x > 170) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 240)) { Radius = 10; Update_Size(Radius); } else if((x > 240) & (y > (BSP_LCD_GetYSize() - 90)) & (y < (BSP_LCD_GetYSize()) ) & ( x < 310)) { Radius = 5; Update_Size(Radius); } else if(((x > (BSP_LCD_GetXSize()-5) ) & (y > (14 * color_width)) & (y < (15 * color_width))) | ((x < 90) & (y < 5))) { TS_State.touchX[0] = 0; TS_State.touchY[0] = 0; } else if((x > 320) & (y > (BSP_LCD_GetYSize() - 90)) & (x < 410) & (y < BSP_LCD_GetYSize() - 5)) { Save_Picture(); } } }
/** * @brief Configures and gets Touch screen position. * @param None * @retval None */ static void GetPosition(void) { static uint32_t x = 0, y = 0; static uint32_t color_heigh; static uint32_t color; static TS_StateTypeDef TS_State; /* Heigh of color pen */ color_heigh = 20; /* Get Touch screen position */ BSP_TS_GetState(&TS_State); /* Read the coordinate */ x = Calibration_GetX(TS_State.X); y = Calibration_GetX(TS_State.Y); if ((TS_State.TouchDetected) & ( x > 0 ) & ( x < 50 )) { /* User selects one of the color pens */ if ((TS_State.TouchDetected) & ( y > 0 ) & ( y < color_heigh )) { BSP_LCD_SetTextColor(LCD_COLOR_WHITE); } else if ((TS_State.TouchDetected) & ( y > color_heigh ) & ( y < (2*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_YELLOW); } else if ((TS_State.TouchDetected) & ( y > (2*color_heigh) ) & ( y < (3*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_ORANGE); } else if ((TS_State.TouchDetected) & ( y > (3*color_heigh) ) & ( y < (4*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_LIGHTMAGENTA); } else if ((TS_State.TouchDetected) & ( y > (4*color_heigh) ) & ( y < (5*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_DARKGREEN); } else if ((TS_State.TouchDetected) & ( y > (5*color_heigh) ) &( y < (6*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); } else if ((TS_State.TouchDetected) & ( y > (6*color_heigh) ) &( y < (7*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_BROWN); } else if ((TS_State.TouchDetected) & ( y > (7*color_heigh) ) & ( y < (8*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_RED); } else if ((TS_State.TouchDetected) & ( y > (8*color_heigh) ) & ( y < (9*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_DARKMAGENTA); } else if ((TS_State.TouchDetected) & ( y > (9*color_heigh) ) & ( y < (10*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_CYAN); } else if ((TS_State.TouchDetected) & ( y > (10*color_heigh) ) & ( y < (11*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_DARKBLUE); } else if ((TS_State.TouchDetected) & ( y > (11*color_heigh) ) & ( y < (12*color_heigh) )) { BSP_LCD_SetTextColor(LCD_COLOR_BLACK); } else if ((TS_State.TouchDetected) & ( y > (12*color_heigh) ) & ( y < (13*color_heigh) )) { /* Clear screen and reinitialize color and size */ /* Get the current text color */ color = BSP_LCD_GetTextColor(); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); /* Clear the working window */ BSP_LCD_FillRect(68, 8, 164, 245); BSP_LCD_SetTextColor(color); radius = 2; } else { x = 0; y = 0; } Update_ColorSize(); } else if ((TS_State.TouchDetected) & ( x > 65 ) & ( y > (BSP_LCD_GetYSize()-48)) & ( y < (BSP_LCD_GetYSize()) ) & ( x < 85 )) { radius = 10; Update_ColorSize(); } else if ((TS_State.TouchDetected) & ( x > 100 ) & ( y > (BSP_LCD_GetYSize()-48) ) & ( y < (BSP_LCD_GetYSize()) ) & ( x < 110 )) { radius = 5; Update_ColorSize(); } else if ((TS_State.TouchDetected) & ( x > 133 ) & ( y > (BSP_LCD_GetYSize()-48) ) & ( y < (BSP_LCD_GetYSize()) ) & ( x < 137 )) { radius = 2; Update_ColorSize(); } else if (((TS_State.TouchDetected) & ( x > (BSP_LCD_GetXSize()-5) ) & ( y > (12*color_heigh) ) & ( y < (13*color_heigh) )) | (( x < 55 ) & ( y < 5 ))) { x = 0; y = 0; } else if ((TS_State.TouchDetected) & ( x > (67 + radius)) & ( y > (7 + radius) ) & ( x < (BSP_LCD_GetXSize()-(7 + radius )) ) & ( y < (BSP_LCD_GetYSize()-(67 + radius )) )) { BSP_LCD_FillCircle((x), (y), radius); } else if ((TS_State.TouchDetected) & ( (x > 150) & ( y > (BSP_LCD_GetYSize() - 50) )) & ( x < 200 ) & ( y < (BSP_LCD_GetYSize()) )) { Save_Picture(); } }