Skip to content

DustinWatts/FocalTech_Touch

Repository files navigation

WIP

This library is a work in progress and some things might not work. If you find something, please open an issue. Thanks!

FocalTech Touch IC library

Compile Compile Latest commit

Library for the FocalTech touch controllers. At the moment the following IC's are supported:

  • FT6236 (ChipID 0x36)
  • FT6206 (ChipID 0x06)
  • FT6236U (ChipID 0x64)
  • FT5436 (ChipID 0x54)
  • FT6234 (ChipID 0x54)

And there are more to come!

Although this library supports the Arduino boards, the maximum VCC voltage and on the data pins is 3.3V. So if you plan to use this with an Arduino, be sure to not exceed 3.3V! (use an Arduino board that runs on 3.3V or levelshifters and a voltage regulator)

Usage

First, include the library in your sketch:

#include <FocalTech.h>

Next, create the object to be used (I use "ts" here, but you can use whatever you like):

FocalTech ts = FocalTech();

Next, in the setup() use begin to start the touch controller:

ts.begin(40)

40 sets the threshold for touch detection, aka how sensitive the touchscreen is. 40 seems to be a good number. This can be an integer from 0 to 255.

If your I2C pins are not the board's default pins or you are using custom pins for I2C you can also specify the I2C pins to be used. You start by supplying the threshold and then the I2C data pin followd by the I2C clock pin:

ts.begin(40, SDA_pin, SCL_pin)

Lastly, in the loop you can check for touches. If there is a touch detected, touched() will return true and you can go and get the X and Y coordinates using getPoint(). In the loop it will look something like this:

void loop(void)
{

    if (ts.touched())
    {
        // Retrieve a point
        TS_Point p = ts.getPoint();

        // Print coordinates to the serial output
        Serial.print("X Coordinate: ");
        Serial.println(p.x);
        Serial.print("Y Coordinate: ");
        Serial.println(p.y);
    }

    //Debouncing. To avoid returning the same touch multiple times you can play with this delay.
    delay(50);
}

At the and of a short loop a delay is needed to give the controller some time to clear it's registers and be ready for a next touch. If you have a short loop and don't add this delay, you run the risk of a touch being picked up multiple times where it was meant to be just a single touch.

Datasheet

Datasheets for some of the supported IC's can in de the Datasheets folder.

If you have a datasheet for an IC that is not in that folder, please create a pull request or open an issue, with the datasheet attached. Thanks in advance!

Support Me

If you like what I am doing, there are a number of ways you can support me.

Platform Link
Twtter You can follow me on Twitter: @dustinwattsnl
YouTube You can subscribe to my channel on Youtube: /dustinWatts
Patreon You can support me by becoming a patron on Patreon: https://www.patreon.com/dustinwatts
PayPal.me You can make a one time donation using PayPal.me: https://www.paypal.me/dustinwattsnl

Get help

For quick access to help you can join my Discord server. https://discord.gg/RE3XevS