Giter VIP home page Giter VIP logo

ft6236's Introduction

FocalTech Touch IC library for Arduino IDE

Arduino IDE library for initially written purely for the the FocalTech FT6236 touch controller. But more IC's are supported. At the moment the following IC's are supported:

  • FT6236 (ChipID 0x36)
  • FT6206 (ChipID 0x06)
  • FT6236U (ChipID 0x64)

Usage

First, include the library in your sketch:

#include <FT6236.h>

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

FT6236 ts = FT6236();

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

The datasheet can be found all over the internet, but this is one with the register descriptions in it. Which comes in handy! http://dustinwatts.nl/docs/FT6236-FocalTechSystems.pdf

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 where I have a dedicated #freetouchdeck channel. https://discord.gg/RE3XevS

ft6236's People

Contributors

dustinwatts avatar witnessmenow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ft6236's Issues

Example Pin Assignments

Hi. Thanks for providing this library. In your example, you note the below. Can you clarify what the first # is for in the pin assignments below (40)? Is it the Touch Interrupt pin #?

//begin(40, SDA, SCL) for custom pins

LVGL Use TFT ILI9488 & FT6236 Invalid

LCD : 480 x 320 ILI9488 Touch: FT6236 does not work
only lvgl UI can be displayed, but there is no response when I click on the screen. I have modified the TFT touch function and used the FT6236 driver, I do not know the reason, could you help me?

thanks...

Touches regularly return an incorrect `0:0` x:y coordinate

While investigating regular odd/wrong touch behaviour I've found that the touch screen reports a 0:0 coordinate for a touch sometimes when it shouldn't.

This is a problem because it can sometimes result in a button tap not registering (or worse, auto-tapping a button that's sitting @ 0:0 on the screen)

I have narrowed the source of the problem to this line: https://github.com/DustinWatts/FT6236/blob/main/FT6236.cpp#L74
... but I don't know what the solution is yet.
That line does have valid coordinates in touchX and touchY (verified by adding a print line: Serial.printf("xxx: n / x:y --- %d / %d:%d", n, touchX[n], touchY[n]);) but it's returning 0:0 because it's told to.

I'm using this code below to verify things - if you just keep tapping the screen eventually it flashed red (keep an eye on the serial output to see it happen there too, with coordinate information)

#include <TFT_eSPI.h>

TFT_eSPI tft = TFT_eSPI();

#include <FT6236.h>
FT6236 ts = FT6236();

bool needsReset = false;

void reset() {
  needsReset = false;
  tft.fillScreen(TFT_BLACK);
  tft.setTextFont(2);
  tft.println(" Touch test - keep tapping. When an incorrect (0:0) coordinate is returned for a tap the screen will turn red...");
}

void setup(void) {
  Serial.begin(115200);

  if (!ts.begin(40)) {
    Serial.println("[WARNING]: Unable to start the capacitive touchscreen");
  }
  else {
    Serial.println("[INFO]: Capacitive touch started");
  }

  tft.begin();
  tft.setRotation(1);

  reset();
}

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

    //Flip things around so it matches our screen rotation
    //intentionally flipped for the FreeTouchDown display
    uint16_t t_x = p.y;
    uint16_t t_y = (uint16_t)map((long)p.x, (long)0, (long)tft.height(), (long)tft.height(), (long)0);

    // print out the originally detected coordinates, followed by the screen dimensions, followed by the converted
    // coordinates *for every touch*
    Serial.printf("touch x:y - %d:%d (%d/%d)    -> %d:%d\n", p.x, p.y, tft.width(), tft.height(), t_x, t_y);

    if (p.x == 0 && p.y == 0) {
      Serial.println("=============================================");
      Serial.printf("                    %d : %d\n", p.x, p.y); //How is this possible?
      Serial.println("=============================================");

      needsReset = true;
      tft.fillScreen(TFT_RED);
    } else if (needsReset) {
      reset();
    }
  }
}

Update and publish

Hello, first of all, thank you for this library. I forked it and found that it is also compatible with FT5436, so I just added chip IDs and made it compatible with both. I also added rotation functionality. It would be awesome if it will be in arduino library manager and PlatformIO libraries. If I open pull request, will you do it please? Else I can do it with my fork.

Thank you so much.

Wiring ESP32 with ILI9488 FT6236 and SHT35

Hi! Thanks a lot for this file driver!

Could you please help me with a question about two left wires?

I m using a ESP which is connected to a ILI9488(SPI) with a FT6236 and a SHT35(I2C).

On the display there are still two pins left not connected for the touch. The are labeled with CTP-INT and CTP-RST.

Do I need to connect them? I cant find anything about those to pins in your code.

Everything works great but I am concerned if everything is the way it should be or if there might be a problem because of those two missing wires and another device (SHT35) connected over I2C.

Would you mind helping me out with this?

Thanks a lot!

Origin of FT6236 vs ILI9488

Am I correct the the 0,0 origin used for FT6236 TS_Point is lower left while the origin of the display is upper left?

Multitouch or gestures?

I’ve got a display with the 6206 version of this chip but I can’t seem to extract more than a single touch.

The datasheet mentions multitouch capability and gesture detection. Do you have any experience getting multiple touches or gestures from your touch display with the FT6236 chip?

FT6236 versus Adafruit_FT6206 Library

I am working with the EastRising 3.5" TFT-LCD display which uses the FT6236 capacitive touch controller and ILI9488 display library.

I have been using the Adafruit_FT6206 Library which Adafruit says "Also supports FT6236 chips (and maybe other compatible chips!)". Generally this Adafruit FT6206 library is working okay with the EastRising display, although I am having one problem.

Have you used your FT6236 library with the East Rising 3.5" display? What, if any, differences are there between your FT6236 library and the Adafruit FT6206 library?

Thanks,
Don

Make touchID public

Thanks for the great library.

A small suggestion - the touch ID is really useful to have available from user code. The reasoning being is that when there are two touches, each may be put into the IC's 1st touch register or the 2nd touch register seemingly at random as the two fingers are moved around (the IC just does this, it is not a problem with your library). The touch ID is, however, consistent. Using the touch ID, it becomes easy to work out whether the data in the 1st touch register or the 2nd touch register really represents the first or second touch. It tells you which of the registers are reporting which finger.

The first finger to be touched will have a touch ID of zero, and it will stay as zero as long as the finger touches the screen. Similarly with the second finger to be touched, except it will have a touch ID of 1. Each point read from your library has a touch ID associated with it, this will tell you whether the XY position in the registers is associated with the first finger or the second.

Also, when there is a touch with one finger, then a second (so two touches) and then the first is released, the two touch IDs for the registers operate as follows:

0 15 (first finger down, 15 is no touch)
0 1 (second finger down, this could also flip back and forth to 1 0 at random, depending on which registers are reporting which finger)
1 15 (first finger lifted but the 1st touch register is now reporting the position of the second finger to touch the screen)

All that is needed to make the touch ID available from user code is to move the touchID[2] array to the public section of the class definition. Not worth creating a PR for!

Thanks again

Make an actual README.md

The README.md is very sparse atm. I'd like to include "How to use" and more importantly, what chips are supported.

P.S. I always make issues just to remind my self to do stuff, but feel free to pile on your ideas and/or comments 😉

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.