Adafruit_TouchScreen icon indicating copy to clipboard operation
Adafruit_TouchScreen copied to clipboard

isTouching method in TouchScreen.h not implemented in .cpp file

Open coursera10062014 opened this issue 11 years ago • 9 comments

There's a bool isTouching() method declared on TouchScreen, but it is not implemented.

Attempts to use it reuslt in:

undefined reference to "TouchScreen::isTouching()"

It looks like the unused pressureThreshhold member variable was intended as a cutoff for the implementation of isTouching().

coursera10062014 avatar Oct 28 '14 00:10 coursera10062014

I made but the problem is LCD sharing touchscreen pins. It makes LCD go crazy. But I will take a look more to it and if I find a solution will post it later.

Jeroi avatar Mar 24 '15 15:03 Jeroi

Ok here is function which you need to add to your TouchScreen.cpp:

bool TouchScreen::isTouching(void) { //read current pressure level uint16_t touch = pressure();

//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); 

    // Minimum and maximum pressure that we consider true pressing
if (touch > 100 && touch < 900) {
    return true;
}
else return false;

}

Jeroi avatar Mar 24 '15 15:03 Jeroi

Have to say also that the pressure() function is not working at current state. It leaves output pins as input and makes LCD go crazy. It needs some serius repairs or movement to private function all to gether.

Edit: Adding that clean up code to the pressure function fixes quite much. Actually you need to only add that pin cleanup code to the pressure function and leave isTouching function without any pin settings.

I recon this will fix issues of TouchScreen leaving bad settings after done pressure function. I will create fork later and add all my fixes to it and make pull request.

Jeroi avatar Mar 24 '15 16:03 Jeroi

First thank you for fixing the isTouching method! :)

"I recon this will fix issues of TouchScreen leaving bad settings after done pressure function. I will create fork later and add all my fixes to it and make pull request."

Hello, did you already fix it?

PatrickGlatt avatar Nov 14 '16 21:11 PatrickGlatt

hey there I am using 4 wire touch controller made by Nkk switch serial # FTCU04B making project ball and plate balance with PID control we can't interface this controller with mega 2560 please let me know asap we have 2 weeks left thank you

het25 avatar Nov 18 '16 22:11 het25

I'm using platformio to manage my dependencies, can we get an implementation released officially?

Thank you.

/cc @ladyada

d42ohpaz avatar Feb 04 '21 12:02 d42ohpaz

@9ae8sdf76 submit a PR and we'll take a look

ladyada avatar Feb 04 '21 19:02 ladyada

@ladyada As much as I want to, I can't even get my screen calibrated - I can't be expected to write code for the library. :) To put it another way: it would take your team 5-10 minutes, while it might take me a day or two (with no guarantee of quality).

d42ohpaz avatar Feb 05 '21 04:02 d42ohpaz

@9ae8sdf76 please try! that way you'll get the exact function you'd like implemented. we have no ETA to work on this library

ladyada avatar Feb 05 '21 05:02 ladyada