Adafruit FT6206 Arduino Library
Adafruit_FT6206.h
Go to the documentation of this file.
1 
5 #ifndef ADAFRUIT_FT6206_LIBRARY
6 #define ADAFRUIT_FT6206_LIBRARY
7 
8 #include <Adafruit_I2CDevice.h>
9 
10 #include "Arduino.h"
11 
12 #define FT62XX_DEFAULT_ADDR 0x38
13 #define FT62XX_G_FT5201ID 0xA8
14 #define FT62XX_REG_NUMTOUCHES 0x02
15 
16 #define FT62XX_NUM_X 0x33
17 #define FT62XX_NUM_Y 0x34
18 
19 #define FT62XX_REG_MODE 0x00
20 #define FT62XX_REG_CALIBRATE 0x02
21 #define FT62XX_REG_WORKMODE 0x00
22 #define FT62XX_REG_FACTORYMODE 0x40
23 #define FT62XX_REG_THRESHHOLD 0x80
24 #define FT62XX_REG_POINTRATE 0x88
25 #define FT62XX_REG_FIRMVERS 0xA6
26 #define FT62XX_REG_CHIPID 0xA3
27 #define FT62XX_REG_VENDID 0xA8
28 
29 #define FT62XX_VENDID 0x11
30 #define FT6206_CHIPID 0x06
31 #define FT6236_CHIPID 0x36
32 #define FT6236U_CHIPID 0x64
33 #define FT6336U_CHIPID 0x64
34 
35 // calibrated for Adafruit 2.8" ctp screen
36 #define FT62XX_DEFAULT_THRESHOLD 128
37 
38 /**************************************************************************/
43 /**************************************************************************/
44 class TS_Point {
45  public:
46  TS_Point(void);
47  TS_Point(int16_t x, int16_t y, int16_t z);
48 
49  bool operator==(TS_Point);
50  bool operator!=(TS_Point);
51 
52  int16_t x;
53  int16_t y;
54  int16_t z;
55 };
56 
57 /**************************************************************************/
62 /**************************************************************************/
64  public:
65  Adafruit_FT6206(void);
66  bool begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD,
67  TwoWire* theWire = &Wire, uint8_t i2c_addr = FT62XX_DEFAULT_ADDR);
68  uint8_t touched(void);
69  TS_Point getPoint(uint8_t n = 0);
70 
71  // void autoCalibrate(void);
72 
73  private:
74  Adafruit_I2CDevice* i2c_dev = NULL;
75  void writeRegister8(uint8_t reg, uint8_t val);
76  uint8_t readRegister8(uint8_t reg);
77 
78  void readData(void);
79  uint8_t touches;
80  uint16_t touchX[2], touchY[2], touchID[2];
81 };
82 
83 #endif // ADAFRUIT_FT6206_LIBRARY
#define FT62XX_DEFAULT_ADDR
I2C address.
Definition: Adafruit_FT6206.h:12
TS_Point(void)
Instantiates a new FT6206 class with x, y and z set to 0 by default.
Definition: Adafruit_FT6206.cpp:239
bool operator==(TS_Point)
Simple == comparator for two TS_Point objects.
Definition: Adafruit_FT6206.cpp:264
bool operator!=(TS_Point)
Simple != comparator for two TS_Point objects.
Definition: Adafruit_FT6206.cpp:274
int16_t z
Definition: Adafruit_FT6206.h:54
#define FT62XX_DEFAULT_THRESHOLD
Default threshold for touch detection.
Definition: Adafruit_FT6206.h:36
Class that stores state and functions for interacting with FT6206 capacitive touch chips...
Definition: Adafruit_FT6206.h:63
Helper class that stores a TouchScreen Point with x, y, and z coordinates, for easy math/comparison...
Definition: Adafruit_FT6206.h:44
int16_t y
Definition: Adafruit_FT6206.h:53
int16_t x
Definition: Adafruit_FT6206.h:52