Black Lives Matter - Action and Equality. ... Adafruit joins the Stop Hate for Profit campaign.

TFT register single touch.
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

TFT register single touch.

by VioletTempest on Tue Dec 10, 2019 3:11 pm

I'm creating a thermostat touchscreen application for the ILI9341 and ran into an issue. I have multiple screens that can be traversed by the user however after they touch the screen multiple ts.getPoint() calls are made. I'm using the <Touchscreen.h> library and have added a version of the isTouching() method to the Touchscreen.cpp file. (Posted below)
Code: Select all | TOGGLE FULL SIZE
bool TouchScreen::isTouching(void)
    uint16_t nTouchCount = 0, nTouch = 0;

    for (uint8_t nI = 0; nI < 4; nI++)
        //read current pressure level
        nTouch = pressure();

        // Minimum and maximum pressure that we consider true pressing
        if (nTouch > 100 && nTouch < 900)
    //Clean the touchScreen settings after function is used
    //Because LCD may use the same pins
    pinMode(_xm, OUTPUT);
    digitalWrite(_xm, LOW);
    pinMode(_yp, OUTPUT);
    digitalWrite(_yp, HIGH);
    pinMode(_ym, OUTPUT);
    digitalWrite(_ym, LOW);
    pinMode(_xp, OUTPUT);
    digitalWrite(_xp, HIGH);
    return nTouchCount > 3;

I find it interesting that one is not provided given it is declared in the header file.
I then use
Code: Select all | TOGGLE FULL SIZE
  p = ts.getPoint();

loop to continue to gather points until the user stops touching the screen. This doesn't seem to be working properly. I was wondering if adding a delay would help however after multiple variances with the delay I still run into the same problem.
Multiple touches are recorded and I cannot figure out a way to just keep one value.
Has anyone else encountered this issue and have a possible solution?
Thanks for the assistance!

Posts: 2
Joined: Tue Dec 03, 2019 12:34 pm

Re: TFT register single touch.

by asteroid on Sun Dec 15, 2019 10:21 am

A similar question was asked some time ago. The following discussion may or may not be helpful:

Posts: 298
Joined: Tue Oct 22, 2013 9:10 pm

Please be positive and constructive with your questions and comments.