RA8875 Up/Down/Left/Right touch gesture not working

KenHahn

Well-known member
I am working on a new product which includes an RA8875 7" LCD with capacitive touch from BuyDisplay (ER0TFTM070-5) on the front side and mounts a Teensy 4.1, adapter boards and various I/O on the back side.

I am using the RA8875 library that comes with Teensyduino. The LCD is on SPI1 and touch is on the default I2C (pins 18/19).

While testing the hardware, I found that the touchscreen works for single touches or multiple finger touches and also works with multiple finger gestures like using two fingers to zoom in/out. Single finger gestures like swipe up/down/left/right however just return 0.

Seems like a possible library issue? Wondering if anyone can confirm or deny? I tried going through the library, but it's above my software pay grade.

The simplist test case is to just run the RA8875/_CapacitiveTouchScreen/FT5206_gesture.ino example. In my case, I am running it on SPI1, so complete code below:
Code:
```cpp
/*
Demonstrate FT5206 gesture ID's
Works in all orientations

one finger swipe -> up, down ,left, right
two finger pinch -> zoom in, zoom out
three finger tap -> change screen rotation
*/

#include <SPI.h>
#include <RA8875.h>

/*
Teensy3.x and Arduino's
You are using 4 wire SPI here, so:
 MOSI:  11//Teensy3.x
 MISO:  12//Teensy3.x
 SCK:   13//Teensy3.x
 the rest of pin below:
*/

const int RA8875_MISO    =  39;     
const int RA8875_MOSI    =  26;     
const int RA8875_SCLK    =  27;     
const int RA8875_CS      =   5; 
const int RA8875_RESET   =   9;                
const int RA8875_INT     =   2;

#define MAXTOUCHLIMIT     3 //1...5

RA8875 tft = RA8875(RA8875_CS, RA8875_RESET, RA8875_MOSI, RA8875_SCLK, RA8875_MISO);


void setup(){
  //  begin display: Choose from: RA8875_480x272, RA8875_800x480, RA8875_800x480ALT, Adafruit_480x272, Adafruit_800x480
  tft.begin(RA8875_800x480);
  tft.setRotation(0);
  #if defined(USE_FT5206_TOUCH)
  tft.useCapINT(RA8875_INT);
  tft.setTouchLimit(MAXTOUCHLIMIT);
  tft.enableCapISR(true);
  tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
  printHeader();
  #else
  tft.print("you should open RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH!");
  #endif
}

void loop(){
  #if defined(USE_FT5206_TOUCH)
  static uint8_t rot = 0;
  static uint8_t prev_touches = 0;
  if (tft.touched()){
    tft.updateTS();
    if(tft.getTouches() == 3 && prev_touches < 3){
      if(++rot > 3) rot = 0;
      tft.setRotation(rot);
      printHeader();
    }else{
      uint8_t gesture = tft.getGesture();
      tft.setFontScale(1);
      switch (gesture) {
        case 0x10: //up
        tft.setCursor(CENTER,CENTER);
        tft.print("UP      ");
        break;
        case 0x14: //left
        tft.setCursor(CENTER,CENTER);
        tft.print("LEFT    ");
        break;
        case 0x18: //down
        tft.setCursor(CENTER,CENTER);
        tft.print("DOWN    ");
        break;
        case 0x1C: //right
        tft.setCursor(CENTER,CENTER);
        tft.print("RIGHT   ");
        break;
        case 0x48: //zoom in
        tft.setCursor(CENTER,CENTER);
        tft.print("ZOOM IN ");
        break;
        case 0x49: //zoom out
        tft.setCursor(CENTER,CENTER);
        tft.print("ZOOM OUT");
        break;
      }
    }
    prev_touches = tft.getTouches();
  }
  #endif
}
void printHeader(){
  tft.fillWindow(RA8875_BLACK);
  tft.setFontScale(0);
  tft.setCursor(0, 0);
  tft.print("Swipe or Pinch.");
  tft.setCursor(0, 25);
  tft.print("Tap 3 fingers to rotate.");
}

```
 
Back
Top