You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can anyone help please me understand why only one of the two Codes work with my 7" TFT RA8875 Capactive TFT touch Screen and already uncommented RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH. I am using Mega 2560 Arduino.
There are 2 points I seek understanding (Code1 = works) and (Code2 = doesn't work):
1- The following Code work downloaded from BuyDisplayOnline website;
/***************************************************
//Web: http://www.buydisplay.com
EastRising Technology Co.,LTD
Examples for ER-TFTM070-5 with Capacitive Touch Panel
Display is Hardward SPI 4-Wire SPI Interface and 5V Power Supply
Capacitive Touch Panel is I2C Interface
Tested and worked with:
Works with Arduino 1.6.0 IDE
****************************************************/
#include <stdint.h>
#include <SPI.h>
#include <Wire.h>
/*
Serial.begin(38400);
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 5000)) ;
*/
tft.begin(RA8875_800x480);
#if defined(USE_FT5206_TOUCH)
tft.useCapINT(RA8875_INT);//we use the capacitive chip Interrupt out!
//the following set the max touches (max 5)
//it can be placed inside loop but BEFORE touched()
//to limit dinamically the touches (for example to 1)
tft.setTouchLimit(MAXTOUCHLIMIT);
//tft.setRotation(0);//this works in any rotation mode!
tft.enableCapISR(true);//capacitive touch screen interrupt it's armed
#else
tft.print("you should open RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH!");
#endif
tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
}
void loop(){
#if defined(USE_FT5206_TOUCH)
if (tft.touched()){//if touched(true) detach isr
//at this point we need to fill the FT5206 registers...
tft.updateTS();//now we have the data inside library
tft.setCursor(CENTER,CENTER);
tft.print(" ");
tft.setCursor(CENTER,CENTER);
tft.print("touches:");
tft.print(tft.getTouches());
tft.print(" | gesture:");
tft.print(tft.getGesture(),HEX);
tft.print(" | state:");
tft.print(tft.getTouchState(),HEX);
//you need to get the coordinates? We need a bidimensional array
uint16_t coordinates[MAXTOUCHLIMIT][2];//to hold coordinates
tft.getTScoordinates(coordinates);//done
//now coordinates has the x,y of all touches
//now draw something....
uint16_t tempCol;
for (uint8_t i=1;i<=tft.getTouches();i++){
if (i == 1)tempCol = RA8875_RED;
if (i == 2)tempCol = RA8875_GREEN;
if (i == 3)tempCol = RA8875_MAGENTA;
if (i == 4)tempCol = RA8875_CYAN;
if (i == 5)tempCol = RA8875_YELLOW;
tft.fillCircle(coordinates[i-1][0],coordinates[i-1][1],10,tempCol);
}
tft.enableCapISR();//rearm ISR if needed (touched(true))
//otherwise it doesn't do nothing...
}
#endif
}
Hello i have a 9inch ra8875 display with capacitive touch 4 wire i tried everything but the touch has no reaction i would be grateful for any help thanks
The buydisplay RA8875 capacitive touchscreen models don't use the same touchscreen as most other RA8875 boards; they use GLS1680 displays. They're not easy to get working, so you may need to hunt around for the right library
Hi There,
Can anyone help please me understand why only one of the two Codes work with my 7" TFT RA8875 Capactive TFT touch Screen and already uncommented RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH. I am using Mega 2560 Arduino.
There are 2 points I seek understanding (Code1 = works) and (Code2 = doesn't work):
1- The following Code work downloaded from BuyDisplayOnline website;
/***************************************************
//Web: http://www.buydisplay.com
EastRising Technology Co.,LTD
Examples for ER-TFTM070-5 with Capacitive Touch Panel
Display is Hardward SPI 4-Wire SPI Interface and 5V Power Supply
Capacitive Touch Panel is I2C Interface
Tested and worked with:
Works with Arduino 1.6.0 IDE
****************************************************/
#include <stdint.h>
#include <SPI.h>
#include <Wire.h>
uint8_t addr = 0x38;
#include "Adafruit_GFX.h"
#include "Adafruit_RA8875.h"
//LCD:hardware SPI CTP:hardware IIC
//Arduino DUE,Arduino mega2560,Arduino UNO
#define RA8875_INT 4
#define RA8875_CS 10
#define RA8875_RESET 9
#define FT5206_WAKE 6
#define FT5206_INT 7
Adafruit_RA8875 tft = Adafruit_RA8875(RA8875_CS, RA8875_RESET);
uint16_t tx, ty;
enum {
eNORMAL = 0,
eTEST = 0x04,
eSYSTEM = 0x01
};
struct TouchLocation
{
uint16_t x;
uint16_t y;
};
TouchLocation touchLocations[5];
uint8_t readFT5206TouchRegister( uint8_t reg );
uint8_t readFT5206TouchLocation( TouchLocation * pLoc, uint8_t num );
uint8_t readFT5206TouchAddr( uint8_t regAddr, uint8_t * pBuf, uint8_t len );
uint32_t dist(const TouchLocation & loc);
uint32_t dist(const TouchLocation & loc1, const TouchLocation & loc2);
bool sameLoc( const TouchLocation & loc, const TouchLocation & loc2 );
uint8_t buf[30];
uint8_t readFT5206TouchRegister( uint8_t reg )
{
Wire.beginTransmission(addr);
Wire.write( reg ); // register 0
uint8_t retVal = Wire.endTransmission();
uint8_t returned = Wire.requestFrom(addr, uint8_t(1) ); // request 6 uint8_ts from slave device #2
if (Wire.available())
{
retVal = Wire.read();
}
return retVal;
}
uint8_t readFT5206TouchAddr( uint8_t regAddr, uint8_t * pBuf, uint8_t len )
{
Wire.beginTransmission(addr);
Wire.write( regAddr ); // register 0
uint8_t retVal = Wire.endTransmission();
uint8_t returned = Wire.requestFrom(addr, len); // request 1 bytes from slave device #2
uint8_t i;
for (i = 0; (i < len) && Wire.available(); i++)
{
pBuf[i] = Wire.read();
}
return i;
}
uint8_t readFT5206TouchLocation( TouchLocation * pLoc, uint8_t num )
{
uint8_t retVal = 0;
uint8_t i;
uint8_t k;
do
{
if (!pLoc) break; // must have a buffer
if (!num) break; // must be able to take at least one
} while (0);
return retVal;
}
void writeFT5206TouchRegister( uint8_t reg, uint8_t val)
{
Wire.beginTransmission(addr);
Wire.write( reg ); // register 0
Wire.write( val ); // value
uint8_t retVal = Wire.endTransmission();
}
void readOriginValues(void)
{
writeFT5206TouchRegister(0, eTEST);
delay(1);
//uint8_t originLength = readFT5206TouchAddr(0x08, buf, 8 );
uint8_t originXH = readFT5206TouchRegister(0x08);
uint8_t originXL = readFT5206TouchRegister(0x09);
uint8_t originYH = readFT5206TouchRegister(0x0a);
uint8_t originYL = readFT5206TouchRegister(0x0b);
uint8_t widthXH = readFT5206TouchRegister(0x0c);
uint8_t widthXL = readFT5206TouchRegister(0x0d);
uint8_t widthYH = readFT5206TouchRegister(0x0e);
uint8_t widthYL = readFT5206TouchRegister(0x0f);
//if (originLength)
{
Serial.print("Origin X,Y = ");
Serial.print( uint16_t((originXH<<8) | originXL) );
Serial.print(", ");
Serial.println( uint16_t((originYH<<8) | originYL) );
}
}
// 1234567890
void setup()
{
Serial.begin(9600);
Serial.println("RA8875 start");
Wire.begin(); // join i2c bus (address optional for master)
readOriginValues();
pinMode (FT5206_WAKE, INPUT);
digitalWrite(FT5206_WAKE, HIGH );
writeFT5206TouchRegister(0, eNORMAL); // device mode = Normal
uint8_t periodMonitor = readFT5206TouchRegister(0x89);
Serial.print("periodMonitor = ");
Serial.println( periodMonitor, HEX );
uint8_t lenLibVersion = readFT5206TouchAddr(0x0a1, buf, 2 );
if (lenLibVersion)
{
uint16_t libVersion = (buf[0] << 8) | buf[1];
}
else
{
Serial.println("lib version length is zero");
}
uint8_t firmwareId = readFT5206TouchRegister( 0xa6 );
Serial.print("firmware ID = ");
Serial.println( firmwareId);
//if (!tft.begin(RA8875_800x480))
//{
// Serial.println("RA8875 Not Found!");
// while (1);
//}
while (!tft.begin(RA8875_800x480))
{
Serial.println("RA8875 Not Found!");
delay(100);
}
Serial.println("Found RA8875");
tft.displayOn(true);
tft.GPIOX(true); // Enable TFT - display enable tied to GPIOX
tft.PWM1config(true, RA8875_PWM_CLK_DIV1024); // PWM output for backlight
tft.PWM1out(255);
// With hardware accelleration this is instant
tft.fillScreen(RA8875_WHITE);
// Play with PWM
for (uint8_t i=255; i!=0; i-=5 )
{
tft.PWM1out(i);
delay(10);
}
for (uint8_t i=0; i!=255; i+=5 )
{
tft.PWM1out(i);
delay(10);
}
tft.PWM1out(255);
tft.fillScreen(RA8875_RED);
delay(500);
tft.fillScreen(RA8875_YELLOW);
delay(500);
tft.fillScreen(RA8875_GREEN);
delay(500);
tft.fillScreen(RA8875_CYAN);
delay(500);
tft.fillScreen(RA8875_MAGENTA);
delay(500);
tft.fillScreen(RA8875_BLACK);
// Try some GFX acceleration!
tft.drawCircle(100, 100, 50, RA8875_BLACK);
tft.fillCircle(100, 100, 49, RA8875_GREEN);
tft.fillRect(11, 11, 700, 400, RA8875_BLUE);
tft.drawRect(10, 10, 400, 200, RA8875_GREEN);
tft.fillRoundRect(200, 10, 200, 100, 10, RA8875_RED);
tft.fillRoundRect(480, 100, 300, 200, 10, RA8875_RED);
tft.drawPixel(10,10,RA8875_BLACK);
tft.drawPixel(11,11,RA8875_BLACK);
//tft.drawLine(10, 10, 200, 100, RA8875_RED);
tft.drawTriangle(200, 15, 250, 100, 150, 125, RA8875_BLACK);
//tft.fillTriangle(200, 16, 249, 99, 151, 460, RA8875_YELLOW);
tft.drawEllipse(300, 100, 100, 40, RA8875_BLACK);
tft.fillEllipse(300, 100, 98, 38, RA8875_GREEN);
// Argument 5 (curvePart) is a 2-bit value to control each corner (select 0, 1, 2, or 3)
tft.drawCurve(50, 100, 80, 40, 2, RA8875_BLACK);
tft.fillCurve(50, 100, 78, 38, 2, RA8875_WHITE);
pinMode (FT5206_INT, INPUT);
//digitalWrite(FT5206_INT, HIGH );
tft.touchEnable(false);
Serial.print("Status: "); Serial.println(tft.readStatus(), HEX);
Serial.println("Waiting for touch events ...");
randomSeed(analogRead(0));
}
uint32_t dist(const TouchLocation & loc)
{
uint32_t retVal = 0;
uint32_t x = loc.x;
uint32_t y = loc.y;
retVal = xx + yy;
return retVal;
}
uint32_t dist(const TouchLocation & loc1, const TouchLocation & loc2)
{
uint32_t retVal = 0;
uint32_t x = loc1.x - loc2.x;
uint32_t y = loc1.y - loc2.y;
retVal = sqrt(xx + yy);
return retVal;
}
bool sameLoc( const TouchLocation & loc, const TouchLocation & loc2 )
{
return dist(loc,loc2) < 50;
}
void loop()
{
static uint16_t total = 256;
static uint16_t w = tft.width();
static uint16_t h = tft.height();
float xScale = 1024.0F/w;
float yScale = 1024.0F/h;
uint8_t attention = digitalRead(FT5206_INT);
static uint8_t oldAttention = 1;
uint32_t thisTouchTime = millis();
uint8_t i=0;
static
uint32_t lastTouchTime = thisTouchTime;
{
total--;
if ((total & 0x3ff) == 0)
{
//Serial.println(total);
}
// void fillRect(int16_t x, int16_t y, int16_t w, int16_t h, uint16_t color);
int16_t x = random(w);
int16_t y = random(h);
int16_t x1 = random(w);
int16_t y1 = random(h);
int16_t x2 = random(w);
int16_t y2 = random(h);
uint16_t c = (((random(64)<<6)|random(64))<<6)|random(31);
uint16_t bg = (((random(64)<<6)|random(64))<<6)|random(31);
int16_t th = random(h);
int16_t tw = random(w);
int16_t op = random(9);
int16_t en = random(8);
}
// for (; i < 5; i++)
// {
// tft.textMode();
// //tft.textSetCursor(touchLocations[i].x,touchLocations[i].y);
// tft.textSetCursor(380,380+16i);
// tft.textColor(RA8875_WHITE, RA8875_BLACK);
// tft.textEnlarge(0);
// snprintf((char)buf,sizeof(buf)," ");
// tft.textWrite((const char )buf,9);
// }
//lastCount = count;
// if (tft.touched()) // USB
// {
// Serial.print("Touch: ");
// tft.touchRead(&tx, &ty);
// Serial.print(tx); Serial.print(", "); Serial.println(ty);
// / Draw a circle */
// tft.fillCircle((uint16_t)(tx/xScale), (uint16_t)(ty/yScale), 4, RA8875_WHITE);
// }
}
}
****************************************************/
2- The following Code does NOT work. Downloaded from Github.
****************************************************/
/*
Serial.begin(38400);
long unsigned debug_start = millis ();
while (!Serial && ((millis () - debug_start) <= 5000)) ;
*/
tft.begin(RA8875_800x480);
#if defined(USE_FT5206_TOUCH)
tft.useCapINT(RA8875_INT);//we use the capacitive chip Interrupt out!
//the following set the max touches (max 5)
//it can be placed inside loop but BEFORE touched()
//to limit dinamically the touches (for example to 1)
tft.setTouchLimit(MAXTOUCHLIMIT);
//tft.setRotation(0);//this works in any rotation mode!
tft.enableCapISR(true);//capacitive touch screen interrupt it's armed
#else
tft.print("you should open RA8875UserSettings.h file and uncomment USE_FT5206_TOUCH!");
#endif
tft.setTextColor(RA8875_WHITE,RA8875_BLACK);
}
void loop(){
#if defined(USE_FT5206_TOUCH)
if (tft.touched()){//if touched(true) detach isr
//at this point we need to fill the FT5206 registers...
tft.updateTS();//now we have the data inside library
tft.setCursor(CENTER,CENTER);
tft.print(" ");
tft.setCursor(CENTER,CENTER);
tft.print("touches:");
tft.print(tft.getTouches());
tft.print(" | gesture:");
tft.print(tft.getGesture(),HEX);
tft.print(" | state:");
tft.print(tft.getTouchState(),HEX);
//you need to get the coordinates? We need a bidimensional array
uint16_t coordinates[MAXTOUCHLIMIT][2];//to hold coordinates
tft.getTScoordinates(coordinates);//done
//now coordinates has the x,y of all touches
//now draw something....
uint16_t tempCol;
for (uint8_t i=1;i<=tft.getTouches();i++){
if (i == 1)tempCol = RA8875_RED;
if (i == 2)tempCol = RA8875_GREEN;
if (i == 3)tempCol = RA8875_MAGENTA;
if (i == 4)tempCol = RA8875_CYAN;
if (i == 5)tempCol = RA8875_YELLOW;
tft.fillCircle(coordinates[i-1][0],coordinates[i-1][1],10,tempCol);
}
tft.enableCapISR();//rearm ISR if needed (touched(true))
//otherwise it doesn't do nothing...
}
#endif
}
****************************************************/
Appreciate your time and help.
AMOMAH
The text was updated successfully, but these errors were encountered: