Hi there,
I am using matrix orbital EVE2-70A TPR tft display for my industrial project. when i run the calibration file i found without touch the calibration getting over and without touch REG_TOUCH_RZ I am getting 32627 it means display got touch. Please see the code below.
void Calibrate_Manual(uint16_t Width, uint16_t Height, uint16_t V_Offset, uint16_t H_Offset)
{
uint32_t displayX[3], displayY[3];
uint32_t touchX[3], touchY[3];
uint32_t touchValue = 0, storedValue = 0;
int32_t tmp, k;
int32_t TransMatrix[6];
uint8_t count = 0;
char num[2];
uint8_t touch_lock = 1;
uint32_t touchness=0;
// These values determine where your calibration points will be drawn on your display
displayX[0] = (Width * 0.15) + H_Offset;
displayY[0] = (Height * 0.15) + V_Offset;
displayX[1] = (Width * 0.85) + H_Offset;
displayY[1] = (Height / 2) + V_Offset;
displayX[2] = (Width / 2) + H_Offset;
displayY[2] = (Height * 0.85) + V_Offset;
while (count < 3)
{
// Send_CMD(CMD_DLSTART);
// Send_CMD(CLEAR_COLOR_RGB(64, 64, 64));
// Send_CMD(CLEAR(1,1,1));
API_LIB_BeginCoProList();
API_CMD_DLSTART(); // Tell co-processor to create new Display List
API_CLEAR_COLOR_RGB(64, 64, 64); // Specify color to clear screen to
API_CLEAR(1,1,1);
// Draw Calibration Point on screen
API_COLOR_RGB(255, 0, 0);
API_POINT_SIZE(20 * 16);
API_BEGIN(FTPOINTS);
API_VERTEX2F((uint32_t)(displayX[count]) * 16, (uint32_t)((displayY[count])) * 16);
API_COLOR_RGB(255, 255, 255);
API_CMD_TEXT((Width / 2) + H_Offset, (Height / 3) + V_Offset, 27, OPT_CENTER, "Calibrating");
API_CMD_TEXT((Width / 2) + H_Offset, (Height / 2) + V_Offset, 27, OPT_CENTER, "Please tap the dots");
num[0] = count + 0x31; num[1] = 0; // null terminated string of one character
API_CMD_TEXT(displayX[count], displayY[count], 27, OPT_CENTER, num);
API_END();
API_DISPLAY();
API_CMD_SWAP();
// Swap buffers in EVE to make this list active
API_LIB_EndCoProList(); // Finish the co-processor list burst write
API_LIB_AwaitCoProEmpty(); // wait here until the coprocessor has read and executed every pending command.
while(1)
{
SEGGER_RTT_printf(0,"%stouchvalue =%d\r\n",RTT_CTRL_BG_BRIGHT_GREEN,EVE_MemRead32(REG_TOUCH_RZ) & 0x7fff,RTT_CTRL_RESET);
touchValue = EVE_MemRead32(REG_TOUCH_DIRECT_XY); // Read for any new touch tag inputs
if(touchValue > 1877868500){
SEGGER_RTT_printf(0,"%stouchmatrix =%d\r\n",RTT_CTRL_BG_BRIGHT_GREEN,touchValue,RTT_CTRL_RESET);}
if(touch_lock)
{
if(touchValue & 0x80000000) // check if we have no touch
{
touch_lock = 0;
}
}
else
{
if (!(touchValue & 0x80000000)) // check if a touch is detected
{
touchValue = EVE_MemRead32(REG_TOUCH_DIRECT_XY);
touchX[count] = (touchValue>>16) & 0x03FF; // Raw Touchscreen Y coordinate
touchY[count] = touchValue & 0x03FF; // Raw Touchscreen Y coordinate
touch_lock = 1;
count++;
break; // leave while(1)
}
}
}
}
k = ((touchX[0] - touchX[2]) * (touchY[1] - touchY[2])) - ((touchX[1] - touchX[2]) * (touchY[0] - touchY[2]));
tmp = (((displayX[0] - displayX[2]) * (touchY[1] - touchY[2])) - ((displayX[1] - displayX[2])*(touchY[0] - touchY[2])));
TransMatrix[0] = CalcCoef(tmp, k);
tmp = (((touchX[0] - touchX[2]) * (displayX[1] - displayX[2])) - ((displayX[0] - displayX[2])*(touchX[1] - touchX[2])));
TransMatrix[1] = CalcCoef(tmp, k);
tmp = ((touchY[0] * (((touchX[2] * displayX[1]) - (touchX[1] * displayX[2])))) + (touchY[1] * (((touchX[0] * displayX[2]) - (touchX[2] * displayX[0])))) + (touchY[2] * (((touchX[1] * displayX[0]) - (touchX[0] * displayX[1])))));
TransMatrix[2] = CalcCoef(tmp, k);
tmp = (((displayY[0] - displayY[2]) * (touchY[1] - touchY[2])) - ((displayY[1] - displayY[2])*(touchY[0] - touchY[2])));
TransMatrix[3] = CalcCoef(tmp, k);
tmp = (((touchX[0] - touchX[2]) * (displayY[1] - displayY[2])) - ((displayY[0] - displayY[2])*(touchX[1] - touchX[2])));
TransMatrix[4] = CalcCoef(tmp, k);
tmp = ((touchY[0] * (((touchX[2] * displayY[1]) - (touchX[1] * displayY[2])))) + (touchY[1] * (((touchX[0] * displayY[2]) - (touchX[2] * displayY[0])))) + (touchY[2] * (((touchX[1] * displayY[0]) - (touchX[0] * displayY[1])))));
TransMatrix[5] = CalcCoef(tmp, k);
count = 0;
do
{
EVE_MemWrite32(REG_TOUCH_TRANSFORM_A + (count * 4), TransMatrix[count]); // Write to Eve config registers
// uint16_t ValH = TransMatrix[count] >> 16;
// uint16_t ValL = TransMatrix[count] & 0xFFFF;
// Log("TM%d: 0x%04x %04x\n", count, ValH, ValL);
count++;
}while(count < 6);
}