FTDI Community

Please login or register.

Login with username, password and session length.
Advanced Search  

News:

Welcome to the FTDI Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ FTDI Support


New Bridgetek Community is now open

Please note that we have created the Bridgetek Community to discuss all Bridgetek products e.g. EVE, MCU.

Please follow this link and create a new user account to get started.

Bridgetek Community

Author Topic: ME813A-WH50C Display - Skipping touch screen calibration at startup  (Read 11634 times)

jberkhout

  • Newbie
  • *
  • Posts: 41
    • View Profile

I would like to calibrate the touch screen once (via a setup menu function) and store calibration values, so they can be used at start-up, without the need to perform calibration at start-up.
Is it possible to skip or disable the touch screen calibration at startup?

Thank you very much for helping me out.

Regards from the Netherlands.
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: ME813A-WH50C Display - Skipping touch screen calibration at startup
« Reply #1 on: June 14, 2018, 11:54:38 AM »

Hello,

Thanks for your question.

Screen calibration is achieved with the CMD_CALIBRATE() function. Please see section 5.52 of the FT81x programmers guide:
http://brtchip.com/wp-content/uploads/Support/Documentation/Programming_Guides/ICs/EVE/FT81X_Series_Programmer_Guide.pdf

Normally this function is call during the main initialization loop of a EVE program.

From the 'SampleLayout' project in EVE Screen Designer (as you have previously mentioned that you are using ESD in another forum topic), within the 'Ft_Esd_App.c' file. The 'Ft_Gpu_CoCmd_Calibrate()' function sends the CMD_CALIBRATE command to the FIFO:
Code: [Select]
/* API to demonstrate calibrate widget/functionality */
ft_void_t App_CoPro_Widget_Calibrate()
{
ft_uint32_t NumBytesGen = 0, TransMatrix[6];
ft_uint16_t CurrWriteOffset = 0;
Ft_Gpu_CoCmd_Dlstart(&s_Host);
Ft_Gpu_Hal_WrCmd32(&s_Host, CLEAR_COLOR_RGB(64, 64, 64));
Ft_Gpu_Hal_WrCmd32(&s_Host, CLEAR(1, 1, 1));
Ft_Gpu_Hal_WrCmd32(&s_Host, COLOR_RGB(0xff, 0xff, 0xff));
/* Draw number at 0,0 location */
//Ft_App_WrCoCmd_Buffer(&s_Host, COLOR_A(30));
Ft_Gpu_CoCmd_Text(&s_Host, (FT_DispWidth / 2), (FT_DispHeight / 2), 27, OPT_CENTER, "Please Tap on the dot");
#if defined(FT_801_ENABLE) || defined(FT_811_ENABLE) || defined(FT_813_ENABLE)
Ft_Gpu_Hal_Wr8(&s_Host, REG_CTOUCH_EXTENDED, CTOUCH_MODE_COMPATIBILITY);
#endif
Ft_Gpu_CoCmd_Calibrate(&s_Host, 0);
/* Wait till coprocessor completes the operation */
Ft_Gpu_Hal_WaitCmdfifo_empty(&s_Host);
/* Print the configured values */
Ft_Gpu_Hal_RdMem(&s_Host, REG_TOUCH_TRANSFORM_A, (ft_uint8_t *)TransMatrix, 4 * 6); //read all the 6 coefficients
#ifdef MSVC_PLATFORM
ESD_print("Touch screen transform values are A 0x%x,B 0x%x,C 0x%x,D 0x%x,E 0x%x, F 0x%x",
TransMatrix[0], TransMatrix[1], TransMatrix[2], TransMatrix[3], TransMatrix[4], TransMatrix[5]);
#endif
}

If you export the ESD code to the FT9XX tool chain you can make the appropriate edits and recompile to upload to you FT9XX.

Best Regards,
FTDI Community
Logged

jberkhout

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: ME813A-WH50C Display - Skipping touch screen calibration at startup
« Reply #2 on: June 14, 2018, 02:24:21 PM »

Thank you very much!
Without calibration, the touchscreen has reversed (mirrored) Y values, i.e. bottom is top and top is bottom, while the X values are fine.
Is this a little bug?
Could I easily correct this without calibrating?
Logged

FTDI Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 892
    • View Profile
Re: ME813A-WH50C Display - Skipping touch screen calibration at startup
« Reply #3 on: June 14, 2018, 02:58:38 PM »

Hello,

It is not a bug, the calibration values just need to be set.
The calibration routine writes values into the REG_TOUCH_TRANSFORM_A - REG_TOUCH_TRANSFORM_F registers. you could run the calibration routine and once this has completed read the values in the applicable registers. You can use these values you write the REG_TOUCH_TRANSFORM_A - REG_TOUCH_TRANSFORM_F registers at the start of your program and your screen should be roughly calibrated. If it requires fine tuning after you can then call the calibration routine from your menu option.

Best Regards,
FTDI Community
Logged

jberkhout

  • Newbie
  • *
  • Posts: 41
    • View Profile
Re: ME813A-WH50C Display - Skipping touch screen calibration at startup
« Reply #4 on: June 30, 2018, 03:05:11 PM »

This is how I determined the six 32-bit calibration values, and preset them without the need to calibrate every time at start up:

Code: [Select]
    TFT.Calibrate();                                    // calibrate the touch screen

    // Read calibrate registers
    printf("// Calibration values:\n");
    printf("    ft_uint32_t canned_calibration_data[] = {\n");
    for(int i = 0; i < 24; i+=4) {
        printf("        ");
        printf("0x%08x", TFT.read_calibrate_reg32(i));
        if (i < 20)
            printf(",");
        printf("\n");
    }
    printf("    };\n");
    printf("    TFT.write_all_calibrate32(canned_calibration_data);\n");


ft_uint32_t FT813::read_calibrate_reg32(ft_uint8_t i) {
    return (Rd8(REG_TOUCH_TRANSFORM_A + i)) +           // lsb
           (Rd8(REG_TOUCH_TRANSFORM_A + i+1) << 8) +
           (Rd8(REG_TOUCH_TRANSFORM_A + i+2) << 16) +
           (Rd8(REG_TOUCH_TRANSFORM_A + i+3) << 24);    //  msb
}

ft_void_t FT813::write_all_calibrate32(ft_uint32_t data[6]) {
    unsigned int i;
    for(i = 0; i < 6; i++) {
        Wr8(REG_TOUCH_TRANSFORM_A + i*4, (data[i]) & 0xff);       // lsb
        Wr8(REG_TOUCH_TRANSFORM_A + i*4 + 1, (data[i] >> 8) & 0xff);
        Wr8(REG_TOUCH_TRANSFORM_A + i*4 + 2, (data[i] >> 16) & 0xff);
        Wr8(REG_TOUCH_TRANSFORM_A + i*4 + 3, (data[i] >> 24) & 0xff);   // msb
    }
}


After calibration this got printed to the serial console, which code is used instead of 'TFT.Calibrate();'.

Code: [Select]
    ft_uint32_t canned_calibration_data[] = {
        0x000109b0,
        0x0000023d,
        0x0000fa64,
        0xffffffcf,
        0xfffefc9a,
        0x01ee8754
    };
    TFT.write_all_calibrate32(canned_calibration_data);

I hope it helps somebody.
Logged