Skip to content

Latest commit

 

History

History

adafruit_touchscreen_tsc2007

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

TSC2007 - Resistive Touch Screen Controller (Adafruit)

Summary

This breakout board features the TSC2007, which has an easy-to-use I2C interface available. There is also an interrupt pin that you can use to indicate when a touch has been detected to your microcontroller or microcomputer. We wrapped up the chip with a 3V voltage regulator and level shifting; therefore, it is safe to use the device with 3V or 5V logic. This touch screen controller board can be used for any four-wire resistive touchscreen. This project aims to implement a hardware driver for Adafruit TSC2007 Touch Screen Controller, which interacts with the resistive touch screen on ILI9341 TFT displays. It gets XY coordinates of the point that the user presses on the screen; the coordinates are matched with the screen resolution. It is useful for applications, which require a UI interface.

Required Hardware

Hardware Connection

To test this example, you should connect the Adafruit TSC2007 Touch Screen Controller to the Adafruit 2.4" TFT LCD (with Touchscreen) and the EFR32xG24 Explorer Kit as shown below.

hardware_connection

EFR32xG24 Explorer Kit Adafruit TSC2007 Adafruit ILI9341 Pin function
PC4 QWIIC SCL - I2C SCL
PC5 QWIIC SDA - I2C SDA
PB0 PENIRQ - GPIO IRQ
- X+ XP(X+) Analog
- Y+ YP(Y+) Analog
- Y- YM(Y-) Analog
- Y+ XM(Y+) Analog
PC8 - D/C GPIO
PC0 - CS SPI CS
PC1 - CLK SPI SCK
PC2 - MISO SPI MISO
PC3 - MOSI SPI MOSI

Setup

You can either create a project based on an example project or start with an empty example project.

Create a project based on an example project

  1. From the Launcher Home, add the BRD2703A to My Products, click on it, and click on the EXAMPLE PROJECTS & DEMOS tab. Find the example project with filter tsc2007.

  2. Click Create button on the Third Party Hardware Drivers - TSC2007 - Resistive Touch Screen Controller (Adafruit) example. Example project creation dialog pops up -> click Create and Finish and Project should be generated. create_example

  3. Build and flash this example to the board.

Start with an empty example project

  1. Create an "Empty C Project" for the "EFR32xG24 Explorer Kit Board" using Simplicity Studio v5. Use the default project settings.

  2. Copy the file app/example/adafruit_touchscreen_tsc2007/app.c into the project root folder (overwriting existing file).

  3. Install the software components:

    • Open the .slcp file in the project.

    • Select the SOFTWARE COMPONENTS tab.

    • Install the following components:

      • [Services] → [IO Stream] → [IO Stream: EUSART] → default instance name: vcom
      • [Application] → [Utility] → [Log]
      • [Application] → [Utility] → [Assert]
      • [Third Party Hardware Drivers] → [Display & LED] → [ILI9341 - TFT LCD Display (Adafruit) - SPI]
      • [Third Party Hardware Drivers] → [Services] → [GLIB - OLED Graphics Library]
      • [Third Party Hardware Drivers] → [Human Machine Interface] → [TSC2007 - Resistive Touch Screen Controller (Adafruit)] → use default configuration
  4. Build and flash the project to your device.

Note:

  • Make sure that the SDK extension is already installed. If not, please follow this documentation.

  • SDK Extension must be enabled for the project to install TSC2007 - Resistive Touch Screen Controller (Adafruit) component.

Touch screen calibration

Below is the calibration value for Adafruit ILI9341 - 2.4" TFT LCD, that we use in this example:

tsc2007_configuration

To calibrate other touch screen we need to follow these steps:

  1. First we need to set the screen resolution.

  2. We need to get 4 values: Xmin, Ymin, Xmax Ymax by measuring 3 point at 3 conners of the screen: Upper left (X1, Y1), Upper right(X2, Y2), ower right(X3, Y3)

    • Upper left of the screen (x = 0, y = 0):

      • Normaly the raw values are X1 = Xmin, Y1 = Ymin
      • If we get X1 = Xmax, Y1 = Ymin at this position, The "Invert X-axis" option need to be enabled
        • If we get X1 = Xmin, Y1 = Ymax at this position, The "Invert Y-axis" option need to be enabled
      • If we get X1 = Xmax + Y1 = Ymax at this position, Both of the "Invert X-axis" and "Invert Y-axis" option need to be enabled
    • Upper right of the screen (x = Width, y = 0):

      • Normaly the raw values are X1 = Xmax, Y1 = Ymin
      • If we get X2 = Ymax, Y2 = Xmin at this position, The "XY swap" option need to be enabled
    • Lower right of the screen (x = Width, y = Height). Use this result to verify the options are matched with what we've set:

      • Normaly the raw values are X3 = Xmax, Y3 = Ymax
      • If we get X3 = Xmin, Y3 = Ymax at this position, The "Invert X-axis" option need to be enabled
        • If we get X3 = Xmax, Y3 = Ymin at this position, The "Invert Y-axis" option need to be enabled
      • If we get X3 = Xmin + Y3 = Ymin at this position, Both of the "Invert X-axis" and "Invert Y-axis" option need to be enabled

    calib

Note:

  • X: Pixel value of X-axis
  • Y: Pixel value of Y-axis
  • X_RAW: Raw value of X-axis
  • Y_RAW: Raw value of Y-axis
  • Z1_RAW: Raw value of Z1 (cross-panel measurements)
  • Z2_RAW: Raw value of Z2 (cross-panel measurements)
  • RT: Touch resistance
  • Xmin: The minimum raw value of X-axis
  • Ymin: The minimum raw value of Y-axis
  • Xmax: The maximum raw value of X-axis
  • Ymax: Thee maximum raw value of Y-axis

How It Works

Testing

This example demonstrates how the TSC2007 driver works by displaying XY-coordinates if we press the touch screen. It also shows the raw values of the sensor data to support the screen calibration. You should expect a similar output to the one below.

output

Report Bugs & Get Support

To report bugs in the Application Examples projects, please create a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo. Please reference the board, project, and source files associated with the bug, and reference line numbers. If you are proposing a fix, also include information on the proposed fix. Since these examples are provided as-is, there is no guarantee that these examples will be updated to fix these issues.

Questions and comments related to these examples should be made by creating a new "Issue" in the "Issues" section of third_party_hw_drivers_extension repo.