1.28" touch screen, but can't get the touch to work

I have a 1.28inch Touch LCD (link) which works pretty good connected to an ESP32-WRover with a total of 12 wires, 8 are used to power and use the TFT display, and 4 more are for the touch.

I'm using the TFT_eSPI library to display and animate the gauge I created.

I tried loading the sample code from the link above, but I'm getting an error with a missing library following this line of code:
#include "LCD_Driver.h"

Few questions:

  1. Can I use TFT_eSPI library for the touch features as well? if yes, how?
  2. Where can I find this missing library? and am I missing anything else to work with it?
  3. Is there a better/easier way to activate the touch on these displays?

Thx.

You will find it in the zip file on the page you linked.

with a 2.8 inch ILI9341 TFT LCD Touchscreen Display I used XPT2046_Touchscreen library by Paul Stoffregen as described in esp32-tft-touchscreen-display-2-8-ili9341-arduino

@xfpd Thanks, the file is included in the ZIP as you said, but now I'm running into a pie of errors when trying to compile.
First, it says it can't find <avr/pgmspace.h>
Then, after I change these lines from
#include <avr/pgmspace.h>
to
#include <pgmspace.h>
I'm getting a lot of new errors, such as : Compilation error: expected initializer before 'PROGMEM'
that refers to font20.cpp
const uint8_t Font20_Table[] PROGMEM =

Feels like a rabbit hole.

Looking for more suggestions.

@horace I tried your link and tested one of the examples that come with that library, the code compiles but won't upload to the ESP32, because of "The serial TX path seems to be down"
Also, it looks for weird pin names like T_IRQ which I don't have on my screen, and it has 5 wires connected to the touch where in my display there are only 4.

I'm trying to get @bodmer 's TFT_eSPI to work with the touch features, but even though I spent hours reading posts and the documentation on Bodmer's Git, I still can't get it to work.

I'm sharing a few more details but would really appreciate any good guidance.

That's how the back side with all the connectors looks like:

Currently the wiring I used are as follows:
// Display connection
// ------------------
// BLK --> left unconnected
// CS (display_1) --> 15
// CS (display_2) --> 5
// DC --> 2
// RES --> 4
// SDA --> 23
// SCL --> 18
// VIN --> 3.3V
// GND --> GND

//Touch connections
//
// TP_SCL --> 22 (I2C-SCL)
// TP_SDA --> 21 (I2C_SDA)
// TP_RST --> 4
// TP_INT --> RX (GPIO 03)

The TFT part of the display works well, both displays are working while connected to the same ESP32 unit, where I can control each separately.

I've made my own User_Setup file:

#define USER_SETUP_ID 46

#define GC9A01_DRIVER

#define TFT_MISO 19
#define TFT_MOSI 23
#define TFT_SCLK 18
//#define TFT_CS    15  // Chip select control pin
#define TFT_DC    2  // Data Command control pin
#define TFT_RST   4  // Reset pin (could connect to RST pin)
//#define TFT_RST  -1  // Set TFT_RST to -1 if display RESET is connected to ESP32 board RST

#define LOAD_GLCD   // Font 1. Original Adafruit 8 pixel font needs ~1820 bytes in FLASH
#define LOAD_FONT2  // Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
#define LOAD_FONT4  // Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
#define LOAD_FONT6  // Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
#define LOAD_FONT7  // Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:.
#define LOAD_FONT8  // Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
#define LOAD_GFXFF  // FreeFonts. Include access to the 48 Adafruit_GFX free fonts FF1 to FF48 and custom fonts
#define SMOOTH_FONT

#define SPI_FREQUENCY  40000000

#define SPI_READ_FREQUENCY  20000000

#define SPI_TOUCH_FREQUENCY  2500000

// #define SUPPORT_TRANSACTIONS

Thank you to anyone who can shade some light on this with easy to understand instructions.

The subdirectory is where the IDE installation places the required files. Verify (or re-do) your IDE installation.

A few things I've managed to figure out over the last few days:

  1. pgmspace.h, is part of the AVR family board which includes UNO, NANO, MEGA etc.. this family of boards DOESN'T include the ESP32, and that is why I was getting this error. trying to compile this sketch after defining UNO as a board, works well.
  2. I couldn't find any way to activate the touch feature on this screen using an ESP32. Sure it is possible, but I just couldn't find any tutorial I could follow.
  3. I did manage to change an AVR type sketch to only operate the touch feature on this screen, this means that I can connect the display to an ESP32 (for the fast processing) and the touch to a Nano and then I need them two to communicate with each other - ugly solution, but better than nothing.
  4. Attached is the sketch I modified, it still has one annoying bug that I can't solve, which is that it usually takes two clicks in order to get the correct X,Y position.
  5. To connect the touch feature, you only need 6 wires:
    GND --> GND
    VIN --> 3.3V
    TP_RST_PIN --> 4
    TP_INT_PIN --> 3
    TP_SDA --> SDA
    TP_SCL --> SCL

Since I can't upload more than 5 files, the rest of the sketch is in the next post. all 6 files are required.
LCD_1inch28_Touch_t9.ino (3.9 KB)

And here are the rest of the files for the above sketch.
Debug.h (681 Bytes)
DEV_Config.cpp (2.5 KB)
DEV_Config.h (2.5 KB)
Touch_Driver.cpp (4.8 KB)
Touch_Driver.h (4.9 KB)

Nobody likes code links. Either paste the formatted code in a CODE block (using the <CODE> button in the message editor) or "select" the code and use a "details" tool from the "sprocket" in the message editor. The result will look like this...

click for magic
void setup() {
  Serial.begin(115200);
  Serial.print("Never gonna"); delay(500);
  Serial.print(" give "); delay(1000);
  Serial.print("- you -"); delay(1000);
  Serial.println(" up!");
}
void loop(){}

@xfpd , code is too long to paste.

If anyone in the future will ever look for a way to connect the touch screen on these cheap AliExpress' TFTs, I'm sure they'll download the code (I know I would)

Thanks everyone for trying to help.

Hahahhahhaaah.

@xfpd Especially For You

LCD_1inch28_Touch_t9.ino
//*******************************************************************************************
// Activate only the touch screen on a 1.28" TFT (the model without the integrated ESP32) 
// This file will only work with Arduino from the AVR family (UNO, Nano, Mega etc...)
// THIS WILL NOT WORK ON ESP32 !!!
// Only connect 6 wires to activate ONLY the touch sensor
// then follow instructions on serial monitor (baud = 115,200)
// GND --> GND
// VIN --> 3.3V
// TP_RST_PIN --> 4
// TP_INT_PIN --> 3
// TP_SDA --> SDA 
// TP_SCL --> SCL 
//*******************************************************************************************

#include "Touch_Driver.h"

UBYTE flag = 0,flgh = 0;

unsigned int timeToSwipe=100;
bool swipe=0;
bool touching=0;
bool up=0,down=0, left=0, right=0, longPress=0;
int16_t x=0,y=0;

// ******************************************************
//                 SETUP
// ******************************************************

void setup()
{  
    Config_Init();
    delay(1000);
    Touch_1IN28_XY XY;
    Serial.println("Setup started");
    XY.mode = 2;
    XY.x_point = 0;
    XY.y_point = 0;
    
    if(Touch_1IN28_init(XY.mode) == true)
        Serial.println("Touch_1IN28_init - OK!");
    else
        Serial.println("Touch_1IN28_init - NOT OK! (but it will still work)");

    attachInterrupt(1,Touch_INT_callback,LOW);
    pinMode(TP_INT_PIN, INPUT_PULLUP);
    DEV_Delay_ms(500);
    Serial.println("Setup ended");
    Serial.println();

    Serial.println("Try touching a point, swiping left, right, up or down and long pressing");
}


// ******************************************************
//                 LOOP
// ******************************************************
void loop()
{   
  
  XY = Touch_1IN28_Get_Point();
  if ((XY.x_point>0 && XY.x_point<250) && (XY.y_point>0 && XY.y_point<250)){
    x= XY.x_point;
    y= XY.y_point;
    }

  if (flag == 1){

    touching=1;
    
    for(int i=0;i<timeToSwipe;i++){
      delay(1);

      if (DEV_I2C_Read_Byte(address,0x01) == UP) {
        resetTouch();
        flag = 0;
        swipe=1;
        up=1;
        }
      
      if (DEV_I2C_Read_Byte(address,0x01) == Down) {
        resetTouch();
        flag = 0;
        swipe=1;
        down=1;
        }

      if (DEV_I2C_Read_Byte(address,0x01) == LEFT) {
        resetTouch();
        flag = 0;
        swipe=1;
        left=1;
        }
      
      if (DEV_I2C_Read_Byte(address,0x01) == RIGHT) {
        resetTouch();
        flag = 0;
        swipe=1;
        right=1;
        }
      
      if (DEV_I2C_Read_Byte(address,0x01) == LONG_PRESS) {
        resetTouch();
        flag = 0;
        swipe=1;
        longPress=1;
        }

      }
      flag = 0;
      
    }


  if (touching){
    touching=0;
    if (!swipe){
      //XY = Touch_1IN28_Get_Point();
      Serial.print("   x: ");
      Serial.print(x);
      Serial.print("  y: ");
      Serial.println(y);
      flag = 0;
      }
    
    else if(up){
      Serial.println("**  Swipe UP");
      up=0;
      swipe=0;
      }

    else if(down){
      Serial.println("** Swipe DOWN");
      down=0;
      swipe=0;
      }

    else if(left){
      Serial.println("** Swipe LEFT");
      left=0;
      swipe=0;
      }

    else if(right){
      Serial.println("** Swipe Right");
      right=0;
      swipe=0;
      }

    else if(longPress){
      Serial.println("** Long press");
      longPress=0;
      swipe=0;
      }
    }

}



// ******************************************************
//                 resetTouch
// ******************************************************
void resetTouch(){
  DEV_Digital_Write(TP_RST_PIN, 0);
  DEV_Delay_ms(10);
  DEV_Digital_Write(TP_RST_PIN, 1);
  DEV_Delay_ms(50);
}


// ******************************************************
//                 Touch_INT_callback
// ******************************************************
void Touch_INT_callback()
{
    flag = TOUCH_IRQ;
}
DEV_Config.cpp
/*****************************************************************************
* | File        :   DEV_Config.c
* | Author      :   Waveshare team
* | Function    :   Hardware underlying interface
* | Info        :
*                Used to shield the underlying layers of each master 
*                and enhance portability
*----------------
* | This version:   V1.0
* | Date        :   2018-11-22
* | Info        :

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to  whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#include "DEV_Config.h"

void GPIO_Init()
{

  pinMode(TP_RST_PIN, OUTPUT);

 }

 void Config_Init()
 {

  GPIO_Init();
  
  //Serial
  Serial.begin(115200);
  
  //spi
  SPI.setDataMode(SPI_MODE3);
  SPI.setBitOrder(MSBFIRST);
  SPI.setClockDivider(SPI_CLOCK_DIV2);
  SPI.begin();

  //i2c
  Wire.begin();

  }

UBYTE DEV_I2C_Read_Byte(UBYTE DevAddr, UBYTE RegAddr)
{
  UBYTE value;

  Wire.beginTransmission(DevAddr);
  Wire.write((byte)RegAddr);
  Wire.endTransmission();

  Wire.requestFrom(DevAddr, (byte)1);
  value = Wire.read();

  return value;
}

void DEV_I2C_Read_nByte(UBYTE DevAddr,UBYTE Cmd, UBYTE *data, UBYTE num)
{

	Wire.beginTransmission(DevAddr);
	Wire.write(Cmd);
	// Wire.endTransmission();
	Wire.requestFrom(DevAddr, num);

	UBYTE i = 0;
	for(i = 0; i < num; i++) {
		data[i] =  Wire.read();
	}
	Wire.endTransmission();

}

void DEV_I2C_Write_Byte(UBYTE DevAddr, UBYTE RegAddr, UBYTE value)
{
  Wire.beginTransmission(DevAddr);
  Wire.write(RegAddr);
  Wire.write(value);
  Wire.endTransmission();
}


DEV_Config.h
/*****************************************************************************
* | File        :   DEV_Config.c
* | Author      :   Waveshare team
* | Function    :   Hardware underlying interface
* | Info        :
*                Used to shield the underlying layers of each master 
*                and enhance portability
*----------------
* | This version:   V1.0
* | Date        :   2018-11-22
* | Info        :

# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documnetation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to  whom the Software is
# furished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS OR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
******************************************************************************/
#ifndef _DEV_CONFIG_H_
#define _DEV_CONFIG_H_

#include <stdint.h>
#include <stdio.h>
#include <SPI.h>
#include <Wire.h>
#include "Debug.h"
#include <avr/pgmspace.h>



#define UBYTE   uint8_t
#define UWORD   uint16_t
#define UDOUBLE uint32_t

/**
 * GPIO config
**/

#define TP_RST_PIN 4
#define TP_INT_PIN 3


/**
 * GPIO read and write
**/
#define DEV_Digital_Write(_pin, _value) digitalWrite(_pin, _value == 0? LOW:HIGH)
#define DEV_Digital_Read(_pin) digitalRead(_pin)


/**
 * SPI
**/
#define DEV_SPI_WRITE(_dat)   SPI.transfer(_dat)

/**
 * delay x ms
**/
#define DEV_Delay_ms(__xms)    delay(__xms)

/**
 * PWM_BL
**/
 #define  DEV_Set_BL(_Pin, _Value)  analogWrite(_Pin, _Value)

/*-----------------------------------------------------------------------------*/
void Config_Init();
uint8_t DEV_I2C_Read_Byte(uint8_t DevAddr, uint8_t RegAddr);
void DEV_I2C_Write_Byte(uint8_t DevAddr, uint8_t RegAddr, uint8_t value);
void DEV_I2C_Read_nByte(UBYTE DevAddr,UBYTE Cmd, UBYTE *data, UBYTE num);

#endif
Debug.h
/*****************************************************************************
* | File        : Debug.h
* | Author      :   Waveshare team
* | Function    : debug with prntf
* | Info        :
*   Image scanning
*      Please use progressive scanning to generate images or fonts
*----------------
* | This version:   V1.0
* | Date        :   2018-01-11
* | Info        :   Basic version
*
******************************************************************************/
#ifndef __DEBUG_H
#define __DEBUG_H

#include "stdio.h"

#define DEV_DEBUG 1
#if DEV_DEBUG
  #define Debug(__info,...) printf("Debug : " __info,##__VA_ARGS__)
#else
  #define DEBUG(__info,...)  
#endif

#endif

Touch_Driver.cpp
/*****************************************************************************
* | File      	:   Touch_1IN28.c
* | Author      :   Waveshare team
* | Function    :   Hardware underlying interface
* | Info        :
*                Used to shield the underlying layers of each master
*                and enhance portability
*----------------
* |	This version:   V1.0
* | Date        :   2022-12-02
* | Info        :   Basic version
*
******************************************************************************/
#include "Touch_Driver.h"

Touch_1IN28_XY XY;
/******************************************************************************
function :	read ID 读取ID
parameter:  CST816T : 0xB5
******************************************************************************/
UBYTE Touch_1IN28_WhoAmI()
{
    Serial.print("Who am I: ");
    Serial.println(DEV_I2C_Read_Byte(address,0xA7));
    if (DEV_I2C_Read_Byte(address,0xA7) == 0xB5)   
        return true;
    else
        return false;
}

/******************************************************************************
function :	reset touch 复位触摸
parameter: 
******************************************************************************/
void Touch_1IN28_Reset()
{
    DEV_Digital_Write(TP_RST_PIN, 0);
    DEV_Delay_ms(100);
    DEV_Digital_Write(TP_RST_PIN, 1);
    DEV_Delay_ms(100);
}

/******************************************************************************
function :	Read software version number 读取软件版本号
parameter:  
******************************************************************************/
UBYTE Touch_1IN28_Read_Revision()
{
    return DEV_I2C_Read_Byte(address,0xA9);
}

/******************************************************************************
function :	exit sleep mode 退出休眠模式
parameter:  
******************************************************************************/
void Touch_1IN28_Stop_Sleep()
{
    DEV_I2C_Write_Byte(address,DisAutoSleep,0x01);
}

/******************************************************************************
function :	Set touch mode 设置触摸模式
parameter:  
        mode = 0 gestures mode 
        mode = 1 point mode
        mode = 2 mixed mode
******************************************************************************/
void Touch_1IN28_Set_Mode(UBYTE mode)
{
    if (mode == 1)
    {
        DEV_I2C_Write_Byte(address,IrqCtl,0X41);
        DEV_I2C_Write_Byte(address,NorScanPer,0X01);//Normal fast detection cycle unit 10ms
        DEV_I2C_Write_Byte(address,IrqPluseWidth,0x0f); //Interrupt low pulse output width 1.5MS
    }       
    else if(mode == 2)
        DEV_I2C_Write_Byte(address,IrqCtl,0X71);
    else
        {
            DEV_I2C_Write_Byte(address,IrqCtl,0X11);
            DEV_I2C_Write_Byte(address,NorScanPer,0X01);
            DEV_I2C_Write_Byte(address,IrqPluseWidth,0x01);//Interrupt low pulse output width 1.5MS
            DEV_I2C_Write_Byte(address,MotionMask,EnDClick);//Enable double-tap mode
        }

}

/******************************************************************************
function :	wake up touchscreen 唤醒触摸屏
parameter:  
******************************************************************************/
void Touch_1IN28_Wake_up()
{
    DEV_Digital_Write(TP_RST_PIN, 0);
    DEV_Delay_ms(10);
    DEV_Digital_Write(TP_RST_PIN, 1);
    DEV_Delay_ms(50);
    DEV_I2C_Write_Byte(address,0xFE,0x01);
}


/******************************************************************************
function :	screen initialization 屏幕初始化
parameter:  
******************************************************************************/
UBYTE Touch_1IN28_init(UBYTE mode)
{
    UBYTE bRet,Rev;
    Touch_1IN28_Reset();
    
    bRet = Touch_1IN28_WhoAmI();
    if (bRet)
    {
        // Serial.println("Success:Detected CST816T.");
        Rev = Touch_1IN28_Read_Revision();
        // Serial.print("CST816T Revision = ");
        // Serial.println(Rev);
        Touch_1IN28_Stop_Sleep();
    }
    else
    {
        Serial.println("Error: Not Detected CST816T.");
        return false;
    }
    XY.mode = mode;
    Touch_1IN28_Set_Mode(mode);

    XY.x_point = 0;
    XY.y_point = 0;
    return true;
}

/******************************************************************************
function :	Get the corresponding point coordinates 获取对应的点坐标
parameter:  
******************************************************************************/
Touch_1IN28_XY Touch_1IN28_Get_Point()
{
    UBYTE data[4];
    DEV_I2C_Read_nByte(address, 0x03, data, 4);
    
    XY.x_point = ((data[0] & 0x0f)<<8) + data[1];
    XY.y_point = ((data[2] & 0x0f)<<8) + data[3];
    
    return XY;
}
Touch_Driver.h
/*****************************************************************************
* | File      	:   Touch_Driver.h
* | Author      :   Waveshare team
* | Function    :   Hardware underlying interface
* | Info        :
*                Used to shield the underlying layers of each master 
*                and enhance portability
*----------------
* |	This version:   V1.0
* | Date        :   2022-12-02
* | Info        :   Basic version
*
******************************************************************************/
#ifndef __Touch_DRIVER_H
#define __Touch_DRIVER_H	
#include "DEV_Config.h"
#include <stdlib.h>		//itoa()
#include <stdio.h>

#define address   0x15  //slave address

#define GESTUREID 0x01 //gesture code
#define None 0x00 		//no gesture
#define UP 0x02 		//slide up
#define Down 0x01 		//slide down
#define LEFT 0x03		//Swipe left
#define RIGHT 0x04		//Swipe right
#define CLICK 0x05		//click
#define DOUBLE_CLICK 0x0B//double click
#define LONG_PRESS 0x0C	//Press

#define FingerNum 0X02
#define XposH 0x03 //X coordinate high 4 digits
#define XposL 0x04 //The lower 8 bits of the X coordinate
#define YposH 0x05 //High 4 digits of Y coordinate
#define YposL 0x06 //The lower 8 bits of the Y coordinate

#define BPC0H 0xB0 //High 8 bits of BPC0 value
#define BPC0L 0xB1 //The lower 8 bits of the BPC0 value
#define BPC1H 0xB2 //The upper 8 bits of the BPC1 value
#define BPC1L 0xB3 //The lower 8 bits of the BPC1 value
#define ChipID 0xA7 //Chip model
#define ProjID 0xA8 //Project Number

#define FwVersion 0xA9 //software version number

#define MotionMask 0xEC 
#define EnConLR  0x04 //Enable continuous left and right swipe actions
#define EnConUD  0x02 //Enable continuous up and down sliding action
#define EnDClick 0x01 //Enable double-click action

#define IrqPluseWidth 0xED //Interrupt low pulse output width unit 0.1ms, optional value: 1~200, default value is 10

#define NorScanPer 0xEE //Normal fast detection cycle unit 10ms, optional value: 1~30, default value is 1

#define MotionSlAngle 0xEF //Gesture detection sliding partition angle control Angle=tan(c)*10
							//c is the angle based on the positive direction of the x-axis
#define LpScanRaw1H 0xF0 //Low power consumption scans the upper 8 bits of the reference value of channel 1
#define LpScanRaw1L 0xF1 //Low power scan the lower 8 bits of the reference value of channel 1
#define LpScanRaw2H 0xF2 //Low power consumption scans the upper 8 bits of the reference value of channel 1
#define LpScanRaw2L 0xF3 //Low power scan the lower 8 bits of the reference value of channel 1

#define LpAutoWakeTime 0xF4 //Auto-recalibration cycle at low power consumption Unit: 1 minute, optional value: 1~5. The default value is 5
#define LpScanTH 0xF5 //Low power scan wake-up threshold. The smaller the value, the more sensitive it is. Available values: 1-255. The default value is 48
#define LpScanWin 0xF6 //Low power scan range. The larger the value, the more sensitive and the higher the power consumption. Available values: 0, 1, 2, 3. The default value is 3
#define LpScanFreq 0xF7 //Low power consumption scan frequency The smaller the more sensitive the optional value: 1~255. The default value is 7
#define LpScanIdac 0xF8 //Low power consumption scanning current The smaller the more sensitive Optional value: 1~255
#define AutoSleepTime 0xF9 //When there is no touch within x seconds, it will automatically enter the low power consumption mode. The unit is 1S, and the default value is 2S.

#define IrqCtl 0xFA 
#define EnTest 0x80 //Interrupt pin test, automatically sends out low pulses periodically after enabling
#define EnTouch 0x40 //When a touch is detected, periodically emit a low pulse
#define EnChange 0x20 //Sends a low pulse when a touch state change is detected
#define EnMotion 0x10 //When a gesture is detected, emit a low pulse
#define OnceWLP 0x00 //The long press gesture only sends out a low pulse signal

#define AutoReset 0xFB //When there is a touch but no valid gesture within x seconds, it will automatically reset. The unit 1S is not enabled when it is 0. The default is 5.
#define LongPressTime 0xFC //Press and hold for x seconds to reset automatically. Unit 1S is not enabled when it is 0. The default is 10.
#define IOCtl 0xFD //
#define SOFT_RST 0x04 //Enable soft reset
#define IIC_OD 0x02 //OD
#define En1v8  0x01 //1.8V

#define DisAutoSleep 0xFE //The default is 0, enabling automatic entry into low power consumption mode; non-zero value, prohibiting automatic entry into low power consumption mode 

 


typedef struct{
	UBYTE mode;
	UBYTE Gesture;
	UWORD color;
	UWORD x_point;
	UWORD y_point;

}Touch_1IN28_XY;

extern Touch_1IN28_XY XY;

typedef enum {
    TOUCH_INIT  = 0,
    TOUCH_IRQ,
    TOUCH_FUNCTION,
	TOUCH_DRAW,
	TOUCH_OUT_GESTURE,
	TOUCH_NO_DRAW,
} Touch_STATE;


UBYTE Touch_1IN28_init(UBYTE mode);
Touch_1IN28_XY Touch_1IN28_Get_Point();

#endif
1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.