Closed gmgunderground closed 2 years ago
Hello @gmgunderground .
Do you mean that you shift slightly toward the center of the screen from the touched position?
If so, the following code will allow some adjustment.
#include <M5Unified.h>
void setup(void)
{
M5.begin();
uint16_t data[8];
/// Calibrate by touching the four corners of the screen in sequence.
M5.Display.calibrateTouch(data, TFT_WHITE, TFT_BLACK, 32);
/// The data array contains the coordinate values of the four corners.
Serial.print("calibrate data:\n");
for (int i = 0 ; i < 8; ++i)
{
Serial.printf("[%d] = %d\n", i, data[i]);
}
/// Or, directly specify the coordinate values of the four corners without touching the screen.
/// If the value is set a little closer to the center, the touch coordinates will be a little outward.
/*
data[0] = 8; // left top X
data[1] = 8; // left top Y
data[2] = 8; // left bottom X
data[3] = 223; // left bottom Y
data[4] = 303; // right top X
data[5] = 8; // right top Y
data[6] = 303; // right bottom X
data[7] = 223; // right bottom Y
*/
/// set calibrate data:
M5.Display.setTouchCalibrate(data);
}
void loop(void)
{
m5gfx::touch_point_t tp[5];
auto tc = M5.Display.getTouch(tp, 5);
if (tc)
{
M5.Display.fillScreen(0);
for (int i = 0; i < tc; ++i)
{
M5.Display.drawCircle(tp[i].x, tp[i].y, 64, rand());
M5.Display.drawFastHLine(0, tp[i].y, M5.Display.width(), rand());
M5.Display.drawFastVLine(tp[i].x, 0, M5.Display.height(), rand());
}
}
}
@lovyan03 Thanks for the code, it actually helps a bit to improve the touch behavior, but it still remains quite inaccurate. Especially in the corners, the measured values of X and Y are quite wrong, significantly improving towards the center of the screen
@gmgunderground Have you tried adjusting data? If it always shifts toward the center, I think you can compensate by changing the calibration value closer to the center. For example, try the following .
uint16_t data[8];
data[0] = 32; // left top X
data[1] = 32; // left top Y
data[2] = 32; // left bottom X
data[3] = 207; // left bottom Y
data[4] = 287; // right top X
data[5] = 32; // right top Y
data[6] = 287; // right bottom X
data[7] = 207; // right bottom Y
M5.Display.setTouchCalibrate(data);
BTW, there is an update to the Core2 touch panel firmware. This reduces the problem of coordinates being shifted vertically at the top of the screen. ( It may have already been updated if your purchase was recent. )
Try to write Core2_Tools
once using M5Burner
.
If the touch panel firmware is out of date, Core2_Tools
will perform the update at startup.
Once the firmware update is performed, it will remain effective even if other programs are written thereafter.
@gmgunderground Have you tried adjusting data? If it always shifts toward the center, I think you can compensate by changing the calibration value closer to the center. For example, try the following .
uint16_t data[8]; data[0] = 32; // left top X data[1] = 32; // left top Y data[2] = 32; // left bottom X data[3] = 207; // left bottom Y data[4] = 287; // right top X data[5] = 32; // right top Y data[6] = 287; // right bottom X data[7] = 207; // right bottom Y M5.Display.setTouchCalibrate(data);
BTW, there is an update to the Core2 touch panel firmware. This reduces the problem of coordinates being shifted vertically at the top of the screen. ( It may have already been updated if your purchase was recent. )
Try to write
Core2_Tools
once usingM5Burner
. If the touch panel firmware is out of date,Core2_Tools
will perform the update at startup.Once the firmware update is performed, it will remain effective even if other programs are written thereafter.
I installed M5 Tools and it updated the display firmware at startup. Now the touch screen seems to be doing much better. Thank you
@gmgunderground Congratulations on the improvement of the touch panel performance issue !
Am I correct in assuming that this Issue has been resolved?
Now all it's ok
M5.Touch get wrong X and Y values more you go away from display center. The same problem there is with M5Core2. How to fix it? With this type of issue the display touch is compliteli useless. X and Y are not centered with the touch point.
https://user-images.githubusercontent.com/3244031/173841585-67615997-15f1-4aa2-a36c-80b45756c9c1.mp4