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