PaulStoffregen / XPT2046_Touchscreen

Touchscreen Arduino Library for XPT2046 Touch Controller Chip
240 stars 84 forks source link

attachInterrupt() in begin() method. #7

Closed prenticedavid closed 7 years ago

prenticedavid commented 7 years ago

If you specify an IRQ pin, on a Uno the ISR() only gets attached if you use digitalPinToInterrupt(tirqPin)

    attachInterrupt( digitalPinToInterrupt(tirqPin), isrPin, FALLING );  //.kbv

David.

SuitableOrNot commented 7 years ago

Same thing on a Mega2560, I modified this library to work with my LCD-Touch-Shield by modifying the "attachInterrupt"-Line within begin() in XPT2046_Touchscreen.cpp to:

bool XPT2046_Touchscreen::begin()
{
    SPI.begin();
    pinMode(csPin, OUTPUT);
    digitalWrite(csPin, HIGH);
    if (255 != tirqPin) {
        pinMode( tirqPin, INPUT );
        attachInterrupt( digitalPinToInterrupt(tirqPin), isrPin, FALLING );
        isrPinptr = this;
    }
    return true;
}

And now it works like a charm :) Thank you for this library 👍