Regarding caliberation of LCD touch screen

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

  • Regarding caliberation of LCD touch screen

    Hi segger,
    I am using segger's evaluation kit for learning purpose.Here, we have 7 inch LCD screen(800*480) resolution.
    Here, we are facing a problem with touch caliberation ,like if i touch some where in the LCD it will point to some other location.
    Please can you tell me how to configure touch caliberation properly.


    Regards,
    venkat
  • Hello, venkat

    I suppose you should measure voltage on your ADC(2 channeles for x and y coordinate) touching your screen on it's borders. In my calibration operation user should touch his screen in left top and right bottom corner to perform calibration. Then you should configure several defines in LCDConf.c using received voltage values. In my project it seems like this:

    C Source Code

    1. #define TOUCH_AD_LEFT 4015 // ADC on X, left top corner
    2. #define TOUCH_AD_RIGHT 464 // ADC on X, right bottom corner
    3. #define TOUCH_AD_TOP 3600 // ADC on Y, left top corner
    4. #define TOUCH_AD_BOTTOM 754 // ADC on Y, right bottom corner

    Every LCD has his own characteristics, so you need to perform this action for every new display. The good idea is to write runtime-calibrate part of code. There was sample for emWin somewhere.

    Best regards,
    Anton

    The post was edited 4 times, last by vard ().

  • Hi,
    I have done changes in LCDconf.c file as you mentioned in the last reply.


    #define TOUCH_BOARD_800_480_AD_LEFT 166

    #define TOUCH_BOARD_800_480_AD_RIGHT 3898

    #define TOUCH_BOARD_800_480_AD_TOP 3693

    #define TOUCH_BOARD_800_480_AD_BOTTOM 232

    This analog values got with the help of sample touchsample.c ,then also touch caiberation is not happening properly.

    Is there any extra things to be done for the same.
    please reply.

    regrds,
    Venkat
  • Hello, venkat

    Check if you call function GUI_TOUCH_Calibrate() during initialization in _InitController() (it is in LCDConf.c). Check if you call this function with your defined macros TOUCH_BOARD_800_480_AD_LEFT and other, not with standart macro TOUCH_AD_LEFT and others,. Also check other parameters of this function.

    Best regards
    Anton
  • Hi Anton,
    Pasted the code, please look into this.

    The analog values we got from the display screen by running the touchcalibration program and also in init function we can see that GUI_TOUCH_Calibrate function is getting called and its taking the appropriate values what we defined in macros.


    //
    // Touch controller settings for 7" display board
    //

    #define TOUCH_BOARD_800_480_AD_LEFT 166
    #define TOUCH_BOARD_800_480_AD_RIGHT 3898
    #define TOUCH_BOARD_800_480_AD_TOP 3693
    #define TOUCH_BOARD_800_480_AD_BOTTOM 232



    /*********************************************************************
    *
    * _InitTouch
    *
    * Function description:
    * Initializes the touch screen.
    */
    static void _InitTouch(void) {
    U32 TouchOrientation;
    U8 Config[3];
    U8 TouchHasSwapXY;
    int TouchADLeft;
    int TouchADRight;
    int TouchADTop;
    int TouchADBottom;

    //
    // Init ports and SSP interface as needed for touch
    //
    LPC_GPIO0->DIR |= (1 << TOUCH_CS_BIT); // P0.20 as output (touch controller CS)
    _InitSSP(SSP_MODE_TS);
    Config[0] = REF_ON;
    Config[1] = (READ_12BIT_SER(ADS_A2A1A0_vaux) | ADS_PD10_ALL_ON);
    Config[2] = PWRDOWN;
    TS_CS_SET();
    _SSP_Send(Config, 3);
    TS_CS_CLR();
    //
    // Set touch orientation and calibrate touch
    //
    if (_Display == DISPLAY_TRULY_240_320) {
    //
    // 3.2" Truly display
    // Swap XY for touch as touch does not have the same orientation as the display
    //
    if (LCD_GetSwapXYEx(0)) {
    TouchHasSwapXY = 0;
    } else {
    TouchHasSwapXY = 1;
    }
    //
    // Calibrate touch
    //
    TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorYEx(0)) | // XY swapped
    (GUI_MIRROR_Y * LCD_GetMirrorXEx(0)) | // XY swapped
    (GUI_SWAP_XY * TouchHasSwapXY) ;
    GUI_TOUCH_SetOrientation(TouchOrientation);
    if (TouchHasSwapXY) {
    GUI_TOUCH_Calibrate(GUI_COORD_X, TOUCH_AD_OFFS, YSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_LEFT, TOUCH_TRULY_240_320_AD_RIGHT);
    GUI_TOUCH_Calibrate(GUI_COORD_Y, TOUCH_AD_OFFS, XSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_TOP , TOUCH_TRULY_240_320_AD_BOTTOM);
    } else {
    GUI_TOUCH_Calibrate(GUI_COORD_Y, TOUCH_AD_OFFS, XSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_LEFT, TOUCH_TRULY_240_320_AD_RIGHT);
    GUI_TOUCH_Calibrate(GUI_COORD_X, TOUCH_AD_OFFS, YSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_TOP , TOUCH_TRULY_240_320_AD_BOTTOM);
    }
    } else {
    //
    // LCD board other than truly
    //
    if (_Display == DISPLAY_BOARD_480_272) {
    TouchADLeft = TOUCH_BOARD_480_272_AD_LEFT;
    TouchADRight = TOUCH_BOARD_480_272_AD_RIGHT;
    TouchADTop = TOUCH_BOARD_480_272_AD_TOP;
    TouchADBottom = TOUCH_BOARD_480_272_AD_BOTTOM;
    } else if (_Display == DISPLAY_BOARD_800_480) {
    TouchADLeft = TOUCH_BOARD_800_480_AD_LEFT;
    TouchADRight = TOUCH_BOARD_800_480_AD_RIGHT;
    TouchADTop = TOUCH_BOARD_800_480_AD_TOP;
    TouchADBottom = TOUCH_BOARD_800_480_AD_BOTTOM;

    } else {
    while (1); // Touch not supported
    }
    //
    // Calibrate touch
    //
    TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) |
    (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) |
    (GUI_SWAP_XY * LCD_GetSwapXYEx (0)) ;
    GUI_TOUCH_SetOrientation(TouchOrientation);
    GUI_TOUCH_Calibrate(GUI_COORD_X, TOUCH_AD_OFFS, XSIZE_PHYS - TOUCH_AD_OFFS, TouchADLeft, TouchADRight);
    GUI_TOUCH_Calibrate(GUI_COORD_Y, TOUCH_AD_OFFS, YSIZE_PHYS - TOUCH_AD_OFFS, TouchADTop , TouchADBottom);
    }
    //
    // Start touch timer
    //
    OS_CREATETIMER(&_TouchTimer, _ExecTouch, TOUCH_TIMER_INTERVAL);
    }
  • Hello venkat,
    I suggest this part of code is a original calibration from sample you used in your work

    C Source Code

    1. //
    2. // Calibrate touch
    3. //
    4. TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorYEx(0)) | // XY swapped
    5. (GUI_MIRROR_Y * LCD_GetMirrorXEx(0)) | // XY swapped
    6. (GUI_SWAP_XY * TouchHasSwapXY)
    7. ;
    8. GUI_TOUCH_SetOrientation(TouchOrientation);
    9. if (TouchHasSwapXY)
    10. {
    11. GUI_TOUCH_Calibrate(GUI_COORD_X, TOUCH_AD_OFFS, YSIZE_PHYS - TOUCH_AD_OFFS,
    12. TOUCH_TRULY_240_320_AD_LEFT,
    13. TOUCH_TRULY_240_320_AD_RIGHT);
    14. GUI_TOUCH_Calibrate(GUI_COORD_Y,
    15. TOUCH_AD_OFFS, XSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_TOP ,
    16. TOUCH_TRULY_240_320_AD_BOTTOM);
    17. } else {
    18. GUI_TOUCH_Calibrate(GUI_COORD_Y,
    19. TOUCH_AD_OFFS, XSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_LEFT,
    20. TOUCH_TRULY_240_320_AD_RIGHT);
    21. GUI_TOUCH_Calibrate(GUI_COORD_X,
    22. TOUCH_AD_OFFS, YSIZE_PHYS - TOUCH_AD_OFFS, TOUCH_TRULY_240_320_AD_TOP ,
    23. TOUCH_TRULY_240_320_AD_BOTTOM);
    24. }
    Display All

    Replace it with you calibration procedure, from the end of code part, you've shown. And please, check all the parameters of called functions. I suggest your display has size 800x480.Try this.

    C Source Code

    1. #define XSIZE_PHYS 800#define YSIZE_PHYS 480GUI_TOUCH_Calibrate(GUI_COORD_X, 0, XSIZE_PHYS, TOUCH_BOARD_800_480_AD_LEFT , TOUCH_BOARD_800_480_AD_RIGHT);GUI_TOUCH_Calibrate(GUI_COORD_Y, 0, YSIZE_PHYS, TOUCH_BOARD_800_480_AD_TOP, TOUCH_BOARD_800_480_AD_BOTTOM);

    Best regards
    Anton
  • RE: Regarding caliberation of LCD touch screen

    Hi Venkat,

    solution:

    Source Code

    1. // TouchOrientation = (GUI_MIRROR_X * LCD_GetMirrorXEx(0)) |
    2. // (GUI_MIRROR_Y * LCD_GetMirrorYEx(0)) |
    3. // (GUI_SWAP_XY * LCD_GetSwapXYEx (0)) ;
    4. TouchOrientation = (GUI_MIRROR_X) | (GUI_MIRROR_Y);


    Regards,
    v.medic