BRT Community

Please login or register.

Login with username, password and session length
Advanced search  

News:

Welcome to the Bridgetek Community!

Please read our Welcome Note

Technical Support enquires
please contact the team
@ Bridgetek Support

Please refer to our website for detailed information on all our products - Bridgetek - Bridging Technology

Author Topic: BT817 Calibration has strange matrix, sometimes don't work.  (Read 8887 times)

KarolBob

  • Newbie
  • *
  • Posts: 3
  • :)
    • View Profile
BT817 Calibration has strange matrix, sometimes don't work.
« on: February 16, 2024, 12:30:17 PM »

Hi there.  :)
This is my first post on this forum, so I would like to say hello to everyone. Also, I want to express my gratitude to Rudolph for his amazing work. Big thanks for that!
I'm using RVT101HVBNWC00-B with BT817Q:
Sometimes i have strange calibration matrix value, only with 0 or 65535 values:
Quote
TransMatrix1 = 65536;
TransMatrix2 = 0;
TransMatrix3 = 0;
TransMatrix4 = 0;
TransMatrix5 = 65536;
TransMatrix6 = 0;
Sometimes it works well, other times it doesn't. This is my source code:
Code: [Select]
void restore_calibrate_matrix(void)
{
uint32_t TransMatrix[6];
eeprom_busy_wait();
TransMatrix[0] = eeprom_read_dword(&TransMatrix1);
// check if eeprom is emptyi 0xFFFFFFFF = 2^32 = 4294967295
if(TransMatrix[0] == 0xFFFFFFFF || is_clear(CALIBRATE_PIN,CALIBRATE))
{
        //
        Touch_Panel_Calibrate();
}
// jesli zapisane bylo cos innego niz fabryczna wartosc to pobierz reszte
else
{
char buff[20];
uart0_puts_P(PSTR("\rTransMatrix[0] = "));
uart0_puts(ultoa(TransMatrix[0],buff,10));
eeprom_busy_wait();
TransMatrix[1] = eeprom_read_dword(&TransMatrix2);
eeprom_busy_wait();
TransMatrix[2] = eeprom_read_dword(&TransMatrix3);
eeprom_busy_wait();
TransMatrix[3] = eeprom_read_dword(&TransMatrix4);
eeprom_busy_wait();
TransMatrix[4] = eeprom_read_dword(&TransMatrix5);
eeprom_busy_wait();
TransMatrix[5] = eeprom_read_dword(&TransMatrix6);
eeprom_busy_wait();
EVE_memWrite32(REG_TOUCH_TRANSFORM_A, TransMatrix[0]);
EVE_memWrite32(REG_TOUCH_TRANSFORM_B, TransMatrix[1]);
EVE_memWrite32(REG_TOUCH_TRANSFORM_C, TransMatrix[2]);
EVE_memWrite32(REG_TOUCH_TRANSFORM_D, TransMatrix[3]);
EVE_memWrite32(REG_TOUCH_TRANSFORM_E, TransMatrix[4]);
EVE_memWrite32(REG_TOUCH_TRANSFORM_F, TransMatrix[5]);
//disp_transMatrix(TransMatrix);
}
}
//
void Touch_Panel_Calibrate(void) 
{
uint32_t TransMatrix[6];
EVE_cmd_dl(CMD_DLSTART); // Start the display list
    EVE_cmd_dl(CMD_COLDSTART);
EVE_cmd_dl(DL_CLEAR_RGB | GRAY);
EVE_cmd_dl(DL_CLEAR | CLR_COL | CLR_STN | CLR_TAG); // Clear the screen - this and the previous prevent artifacts between lists
make_bigger_fonts();
    char txt[50];
    strcpy_P(txt,PSTR("Dotknij wskazane\npunkty na ekranie")); // in english "touch the indicated points"
    EVE_cmd_text((EVE_HSIZE/2),(EVE_VSIZE/2), 3, EVE_OPT_CENTER, txt);
EVE_cmd_calibrate();
EVE_cmd_dl(DL_DISPLAY); // Instruct the graphics processor to show the list
EVE_cmd_dl(CMD_SWAP); // Make this list active
while(EVE_busy() == 1);
TransMatrix[0] = EVE_memRead32(REG_TOUCH_TRANSFORM_A);
TransMatrix[1] = EVE_memRead32(REG_TOUCH_TRANSFORM_B);
TransMatrix[2] = EVE_memRead32(REG_TOUCH_TRANSFORM_C);
TransMatrix[3] = EVE_memRead32(REG_TOUCH_TRANSFORM_D);
TransMatrix[4] = EVE_memRead32(REG_TOUCH_TRANSFORM_E);
TransMatrix[5] = EVE_memRead32(REG_TOUCH_TRANSFORM_F);
save_matrix(TransMatrix);
disp_transMatrix(TransMatrix);
    uart0_send_trans_matrix(TransMatrix);
}
//
void save_matrix(uint32_t *TransMatrix)
{
// eeprom write -> update block :))
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix1, TransMatrix[0]);
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix2, TransMatrix[1]);
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix3, TransMatrix[2]);
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix4, TransMatrix[3]);
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix5, TransMatrix[4]);
eeprom_busy_wait();
eeprom_write_dword(&TransMatrix6, TransMatrix[5]);
eeprom_busy_wait();
}
//
void disp_transMatrix(uint32_t *TransMatrix)
{
uint8_t i = 6;
page_start();
    uint16_t y = EVE_VSIZE/2;   // połowa ekranu
    uint8_t dy = 30;            // odstęp pomiedzy wierszami w osi oY
    y = y - (3*dy);             // zaczynam o 3 wiersze wcześniej
for(i=0; i<6; i++)
{
EVE_cmd_number(EVE_HSIZE/2,y,30,EVE_OPT_CENTER,TransMatrix[i]);
        y += dy;
}
    y += dy;
    char txt[50];
    strcpy_P(txt,PSTR("Dotknij ekranu lub nacisnij przycisk aby wyjsc")); // in english: "touch the screen to exit"
    EVE_cmd_text(EVE_HSIZE/2,y,31,EVE_OPT_CENTER,txt);
page_stop();
_delay_ms(500); //while(1){};

    while(0 == EVE_memRead8(REG_TOUCH_TAG) && is_set(CALIBRATE_PIN,CALIBRATE));
//while(is_set(CALIBRATE_PIN,CALIBRATE)){}; // czekam na ponowne nacisniecie przycisku
}
void uart0_send_trans_matrix(uint32_t * TransMatrix)
{
    char buff[16];
    for(uint8_t i=0; i<6; i++)
    {
        //EEMEM uint32_t TransMatrix1 = 33612304;
        uart0_puts_P(PSTR("\rEEMEM uint32_t TransMatrix"));
        uart0_puts(utoa(i+1,buff,10));
        uart0_puts_P(PSTR(" = "));
        uart0_puts(ultoa(TransMatrix[i],buff,10));
        uart0_puts_P(PSTR(";"));
    }
    //uart0_puts_P(PSTR("\r test="));    uart0_puts(ultoa(UINT32_MAX,buff,10));
}
In the main function, I simply call the 'restore_calibrate_matrix' function. This function reads the calibration matrix from EEPROM. If EEPROM is empty (i.e., it has a value of 0xFFFFFFFF), I invoke the screen calibration and then save the new calibration matrix values to EEPROM. However, if EEPROM contains any saved values, it reads the consecutive 'TransMatrix[n]' and then saves them to 'REG_TOUCH_TRANSFORM_n'.

I feel that one panel, the older one, works perfectly fine while the newer one has the problems described above.

Regards
Karol
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: BT817 Calibration has strange matrix, sometimes don't work.
« Reply #1 on: February 19, 2024, 03:48:01 PM »

Hello,

Thank you for your post.

I note you mention an older screen does not present this issue, are both of these screens the same RVT101HVBNWC00-B model?

On the occasion of the issue occurring does a re-run of the calibration routine result in accurate matrix values, or for example do you need to power cycle the board?

Have you noted any issues around the CTP connector to the displays main PCB?

Best Regards,
BRT Community
Logged

KarolBob

  • Newbie
  • *
  • Posts: 3
  • :)
    • View Profile
Re: BT817 Calibration has strange matrix, sometimes don't work.
« Reply #2 on: February 19, 2024, 07:59:44 PM »

Thank you for your response to my questions.
I note you mention an older screen does not present this issue, are both of these screens the same RVT101HVBNWC00-B model?

It turned out that the issue also occurs on the older/newer RVT101HVBNWC00-B panel. Currently, I am working on the project, and every time I power it on and restore the saved calibration matrix from EEPROM, I still have to perform calibration. I trigger the calibration with a button on the PCB.

On the occasion of the issue occurring does a re-run of the calibration routine result in accurate matrix values, or for example do you need to power cycle the board?
Running the calibration function solves the problem with the touchscreen panel. It seems like I mostly have to do this almost every time I power it on.

Have you noted any issues around the CTP connector to the displays main PCB?
I haven't noticed any problems with the CTP connector. When I used 7" panels with CTP before, everything worked fine. I'll add that I have the screen rotated 180 degrees, but that shouldn't be an issue.

PS. Perhaps the problem lies elsewhere, for example, I might be experiencing buffer overflow - I need to carefully check the source code again.
Regards,
Karol
Logged

BRT Community

  • Administrator
  • Hero Member
  • *****
  • Posts: 746
    • View Profile
Re: BT817 Calibration has strange matrix, sometimes don't work.
« Reply #3 on: February 20, 2024, 03:11:02 PM »

Hello,

Thank you for the clarifications, I think in the case that both the older version of the same display and the fact that rerunning the calibration routine results in the display working as expected means we can rule out an issue with the I2C data coming from the touch controller. And similarly it would rule out a hardware issue such as the CTP connector being misaligned.

I would be interested to know if the saved matrix values that you are noting are captured before you write them into the EERPOM or afterwards? This, as you have noted, may be related to an overflow issue or potentially an endianness issue.

Best Regards,
BRT Community
Logged

Rudolph

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
Re: BT817 Calibration has strange matrix, sometimes don't work.
« Reply #4 on: February 20, 2024, 05:58:43 PM »

Also, I want to express my gratitude to Rudolph for his amazing work. Big thanks for that!

Thank you!


This made me realize that I probably never tried to calibrate my RVT101HVBNWC00-B. :-)
The touch worked ok as is.

Quote
TransMatrix1 = 65536;
TransMatrix2 = 0;
TransMatrix3 = 0;
TransMatrix4 = 0;
TransMatrix5 = 65536;
TransMatrix6 = 0;

These are the reset values for the registers, I am getting the same values here with no calibration.

The values I am getting after calibration are all over the place:
REG_TOUCH_TRANSFORM_A : 0x0000FF2F
REG_TOUCH_TRANSFORM_B : 0xFFFFFEAB
REG_TOUCH_TRANSFORM_C : 0x0005CACE
REG_TOUCH_TRANSFORM_D : 0xFFFFFCAA
REG_TOUCH_TRANSFORM_E : 0x00010116
REG_TOUCH_TRANSFORM_F : 0x00044696


And now I know again why I usually keep the RVT101HVBNWC00-B up on the shelf. :-)
It is big.
It is bright.
It is big.
Logged