ra8875/GSL1680 .teensy 4.0 ..touch panel functional but an issue

@Joey120373 Buy Display wrote their code in that funky way as it is used as a driver. I don't understand C-code very much, but that is my take on it.

The Skalwar code throws the errors because the delay is before the I2C endTransmission. I too found the Buy Display code for the Due functions just fine on a T3.2 & T3.5. Skalwar's code was written for a Linux device, but I don't understand why it is different, yet looks so familiar.

When I first purchased the 5-inch display, I noted the data sheet had some errors in pin outs. The connection diagram was correct while the data sheet had pins swapped. I believe Buy Display has fixed that issue.

My solution to all those lines of code was to make 2 programs out if it. One to load the GSL code into an I2C EEPROM and a second to read the EEPROM and send it to the touch controller. Maybe someday I'll figure out how to write it into an acceptable driver. If you look at that long table of numbers, the first byte is an GSL address and the next 4-bytes are the data to be loaded into the GSL. The data is sent to the GSL in an <address><data> format.

I like your shifting method for the Y value. I resorted to just subtracting 4100 in my code.
 
That’s an interesting way to do it, would love to hear more on how exactly that’s done.
I am kinda in the same boat, porting the BuyDisplay code over to a dedicated library is a bit over my head.

Hoping maybe someone with better coding skills might tackle it.

I did try to just throw all the BD touch screen stuff into a function loop at one point, that didn’t work but I didn’t have high hopes that it would.

May have already mentioned this, but what I ended up doing was to just open another tap, made 2 loops, a set up1() and main1() loop there,
That way I can just put my code there instead of scrolling down 4000 lines to get to where I can start writing code.
 
Wanted to share some work I did over the past day since working with this screen. I'm attaching an edited library based off of Skallwar's work, I don't have a git or anything I left the credits in the files and just added a tag for myself.
Fixes include:
updated Firmware for 1680_F as it is different than H / others.
fixed the damn clear_reg and reset (for those that don't know if you throw bytes at an I2C registry without ending the transmission it just moves on to the next byte / registry, so yeah that was kinda special. (in short the begin and end transmission needed to be in the for loop)
updated all parameters to handle the full 10 (why i don't know) touch points the chip can track.
hard set i2C speed to 400000
I am packing this all up as one including the Adafruit screen driver, just want to make it easy for the next guy/gal, you know!?
warning my GSL1680.cpp is set for Wire2 as that's what I need, change it using find / replace (Wire2 to Wire1 or Wire)
ohh and don't forget to turn off debug error and info, they are currently enabled in the .cpp file.
I have this working on Teensy 4.1.
Testing Script
Code:
#include <SPI.h>
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
#include "Wire.h"
#include "GSL1680.h" //Library edited for Wire2

//                Arduino pin
#define TFT_CS        10 
#define TFT_RESET     7    
#define CTP_WAKE      8
#define CTP_INT       9
#define LEDdelay 500

uint32_t Timer = 0;

Adafruit_RA8875 tft = Adafruit_RA8875(TFT_CS, TFT_RESET);
GSL1680 TS = GSL1680();  


void setup() 
{
  delay(100);
  Serial.begin(115200);
  
  Serial.println("Trying to initialize RA8875 though SPI");
  if (!tft.begin(RA8875_800x480)) {
    Serial.println("RA8875 Not Found!");
    setup();
  } else {
    Serial.println("Found RA8875");
    Timer = millis();
    tft.displayOn(true);
    tft.GPIOX(true);
    tft.PWM1config(true, RA8875_PWM_CLK_DIV1024);
    tft.PWM1out(128);  
    tft.fillScreen(RA8875_GREEN);
    
    tft.textMode();
    tft.textSetCursor(10, 10);
    tft.textTransparent(RA8875_WHITE);
    tft.textEnlarge(1);
    
    tft.textWrite("Capacitive touch sensor demo. Touch me !");
    delay(500);
    TS.begin(CTP_WAKE, CTP_INT); 
    
    Serial.println("Setup done.");
  }
}

void loop() 
{
  if(millis()>(Timer+LEDdelay)){
    Timer=millis()+LEDdelay;
    //Serial.println("LOOPING");
  }
  
  if(digitalRead(CTP_INT) == HIGH) {
    Serial.println("Touch");
    int NBFinger = TS.dataread();
    for(int i=1; i<=NBFinger; i++){
      Serial.print(TS.readFingerID(i)+1);
      Serial.print(" ");
      Serial.print(TS.readFingerX(i));
      Serial.print(" ");
      Serial.print(TS.readFingerY(i));
      Serial.println("");
    }
  Serial.println("---");
  }

}

Library = https://drive.google.com/file/d/1qT2-ULYPiZfljJDFYQ392fTGlI5tJ17i/view?usp=sharing
 
Last edited:
Back
Top