resistance threshold touch value of eve2-70A
Moderator: Mods
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
resistance threshold touch value of eve2-70A
Hi there i am doing industrial project on eve2-70A tpr. i trying to calibrate the touch pad . i am using sample code from github basic library eve2. i am trying to adjust the reisistance threshold value i went from 700 - 14700. how much it should around threshold value please reply.
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
Re: resistance threshold touch value of eve2-70A
I am getting this max value of REG_TOUCH_RZ when i touch the screen.
touchvalue =-1877868544
touchvalue =-795864576
touchvalue =1080576009
touchvalue =-41112
touchvalue =1749551360
touchvalue =-2133815278
touchvalue =-1811939328
touchvalue =-1877868544
touchvalue =1208549376
touchvalue =-16432
touchvalue =-1811939328
touchvalue =-16432
touchvalue =-2037121024
touchvalue =1111706112
touchvalue =1128923136
touchvalue =-209
touchvalue =-16432
touchvalue =-1543241728
touchvalue =883164160
touchvalue =-245
touchvalue =-245
touchvalue =1128923136
touchvalue =33488663
touchvalue =441582080
touchvalue =16777216
touchvalue =-233
touchvalue =883164160
touchvalue =-161
touchvalue =-1877868544
touchvalue =-795864576
touchvalue =1080576009
touchvalue =-41112
touchvalue =1749551360
touchvalue =-2133815278
touchvalue =-1811939328
touchvalue =-1877868544
touchvalue =1208549376
touchvalue =-16432
touchvalue =-1811939328
touchvalue =-16432
touchvalue =-2037121024
touchvalue =1111706112
touchvalue =1128923136
touchvalue =-209
touchvalue =-16432
touchvalue =-1543241728
touchvalue =883164160
touchvalue =-245
touchvalue =-245
touchvalue =1128923136
touchvalue =33488663
touchvalue =441582080
touchvalue =16777216
touchvalue =-233
touchvalue =883164160
touchvalue =-161
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
Re: resistance threshold touch value of eve2-70A
also matrix data from
REG_TOUCH_DIRECT_XY
touchmatrix =2110628
touchvalue =-1877868544 when i pressed first time
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
I get the data from above register after i run calibrate manual like this
65534
0
0
0
0
65534
0
the code is 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)
{
touchness = EVE_MemRead32(REG_TOUCH_RZ + RAM_REG);
touchValue = EVE_MemRead32(REG_TOUCH_DIRECT_XY + RAM_REG); // Read for any new touch tag inputs
if(touchness > 8443000){
SEGGER_RTT_printf(0,"%stouchvalue =%d\r\n",RTT_CTRL_BG_BRIGHT_GREEN,touchness,RTT_CTRL_RESET);}
if(touchValue > 33926){
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 + RAM_REG);
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 + RAM_REG + (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);
}
REG_TOUCH_DIRECT_XY
touchmatrix =2110628
touchvalue =-1877868544 when i pressed first time
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
touchmatrix =2110628
I get the data from above register after i run calibrate manual like this
65534
0
0
0
0
65534
0
the code is 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)
{
touchness = EVE_MemRead32(REG_TOUCH_RZ + RAM_REG);
touchValue = EVE_MemRead32(REG_TOUCH_DIRECT_XY + RAM_REG); // Read for any new touch tag inputs
if(touchness > 8443000){
SEGGER_RTT_printf(0,"%stouchvalue =%d\r\n",RTT_CTRL_BG_BRIGHT_GREEN,touchness,RTT_CTRL_RESET);}
if(touchValue > 33926){
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 + RAM_REG);
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 + RAM_REG + (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);
}
-
- Matrix Orbital
- Posts: 742
- Joined: Thu Dec 13, 2001 4:00 pm
- Location: Earth.... I think..
- Contact:
Re: resistance threshold touch value of eve2-70A
Regardless of the touch calibration matrix, the output of the `REG_TOUCH_RZ` register should be in between 0 and 32767.
if you go by the letter of the data sheet you should and it with 0x7fff but I admit I've never seen bits 16-31 being anything other than 0
the fact that you are reading values way out of range i'd validate you are reading the register right.
Adjusting our basic example like this:
gives me the following values
if you go by the letter of the data sheet you should and it with 0x7fff but I admit I've never seen bits 16-31 being anything other than 0
the fact that you are reading values way out of range i'd validate you are reading the register right.
Adjusting our basic example like this:
Code: Select all
int main()
{
FT81x_Init(DEMO_DISPLAY, DEMO_BOARD, DEMO_TOUCH); //Initialize the EVE graphics controller. Make sure to define which display
//you are using in the MatrixEveConf.h
ClearScreen(); //Clear any remnants in the RAM
//If you are using a touch screen, make sure to define what
//variant you are using in the MatrixEveConf.h file
if (Display_Touch() != TOUCH_TPN)
{
Calibrate();
}
MakeScreen_MatrixOrbital(30); //Draw the Matrix Orbital Screen
uint8_t pressed = 0;
while (1)
{
printf("Pressure : %d\n", rd32(REG_TOUCH_RZ + RAM_REG) & 0x7fff); //<---- this is the only changed line of code
#ifdef _MCS_VER
if (_kbhit())
break;
#endif
uint8_t Tag = rd8(REG_TOUCH_TAG + RAM_REG); // Check for touches
switch (Tag)
{
case 1:
if (!pressed)
{
MakeScreen_MatrixOrbital(120); //Blue dot is 120 when not touched
pressed = 1;
}
break;
default:
if (pressed)
{
pressed = 0;
MakeScreen_MatrixOrbital(30); //Blue dot size is 30 when not touched
}
break;
}
}
HAL_Close();
}
gives me the following values
Code: Select all
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 639
Pressure : 639
Pressure : 639
Pressure : 661
Pressure : 661
Pressure : 661
Pressure : 643
Pressure : 643
Pressure : 637
Pressure : 637
Pressure : 637
Pressure : 628
Pressure : 628
Pressure : 628
Pressure : 624
Pressure : 624
Pressure : 624
Pressure : 627
Pressure : 627
Pressure : 630
Pressure : 630
Pressure : 630
Pressure : 640
Pressure : 640
Pressure : 640
Pressure : 643
Pressure : 643
Pressure : 643
Pressure : 643
Pressure : 643
Pressure : 644
Pressure : 644
Pressure : 644
Pressure : 639
Pressure : 639
Pressure : 639
Pressure : 634
Pressure : 634
Pressure : 634
Pressure : 634
Pressure : 634
Pressure : 636
Pressure : 636
Pressure : 636
Pressure : 624
Pressure : 624
Pressure : 624
Pressure : 626
Pressure : 626
Pressure : 626
Pressure : 612
Pressure : 612
Pressure : 608
Pressure : 608
Pressure : 608
Pressure : 604
Pressure : 604
Pressure : 604
Pressure : 611
Pressure : 611
Pressure : 611
Pressure : 610
Pressure : 610
Pressure : 607
Pressure : 607
Pressure : 607
Pressure : 608
Pressure : 608
Pressure : 608
Pressure : 611
Pressure : 611
Pressure : 611
Pressure : 625
Pressure : 625
Pressure : 629
Pressure : 629
Pressure : 629
Pressure : 637
Pressure : 637
Pressure : 637
Pressure : 653
Pressure : 653
Pressure : 653
Pressure : 711
Pressure : 711
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 32767
Pressure : 32767
[/code[
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
Re: resistance threshold touch value of eve2-70A
Thank you you guided me very well. now when i run the calibrate. without manual touch following reading is coming. Please guide me. that why i cannot calibrate the screen.
touchvalue =128
touchvalue =1184
touchmatrix =-1
touchvalue =32767
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchvalue =128
touchvalue =1184
touchmatrix =-1
touchvalue =32767
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
touchmatrix =-1
touchvalue =32767
-
- Matrix Orbital
- Posts: 742
- Joined: Thu Dec 13, 2001 4:00 pm
- Location: Earth.... I think..
- Contact:
Re: resistance threshold touch value of eve2-70A
I can't easily tell what your code is doing or what the debug output means, best i can do is refer you to our manual calibration example code available here
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
Re: resistance threshold touch value of eve2-70A
hi Ray,
the value 32627 is from REG_TOUCH_RZ register
the value 32627 is from REG_TOUCH_RZ register
-
- LCD Geek
- Posts: 25
- Joined: Wed Apr 03, 2019 11:24 am
Re: resistance threshold touch value of eve2-70A
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);
}
{
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);
}