Adafruit FT6206 Arduino Library
Adafruit_FT6206.h
1 /***************************************************
2  This is a library for the Adafruit Capacitive Touch Screens
3 
4  ----> http://www.adafruit.com/products/1947
5 
6  Check out the links above for our tutorials and wiring diagrams
7  This chipset uses I2C to communicate
8 
9  Adafruit invests time and resources providing this open source code,
10  please support Adafruit and open-source hardware by purchasing
11  products from Adafruit!
12 
13  Written by Limor Fried/Ladyada for Adafruit Industries.
14  MIT license, all text above must be included in any redistribution
15  ****************************************************/
16 
17 #ifndef ADAFRUIT_FT6206_LIBRARY
18 #define ADAFRUIT_FT6206_LIBRARY
19 
20 #include "Arduino.h"
21 #include <Wire.h>
22 
23 #define FT62XX_ADDR 0x38
24 #define FT62XX_G_FT5201ID 0xA8
25 #define FT62XX_REG_NUMTOUCHES 0x02
26 
27 #define FT62XX_NUM_X 0x33
28 #define FT62XX_NUM_Y 0x34
29 
30 #define FT62XX_REG_MODE 0x00
31 #define FT62XX_REG_CALIBRATE 0x02
32 #define FT62XX_REG_WORKMODE 0x00
33 #define FT62XX_REG_FACTORYMODE 0x40
34 #define FT62XX_REG_THRESHHOLD 0x80
35 #define FT62XX_REG_POINTRATE 0x88
36 #define FT62XX_REG_FIRMVERS 0xA6
37 #define FT62XX_REG_CHIPID 0xA3
38 #define FT62XX_REG_VENDID 0xA8
39 
40 #define FT62XX_VENDID 0x11
41 #define FT6206_CHIPID 0x06
42 #define FT6236_CHIPID 0x36
43 #define FT6236U_CHIPID 0x64 // mystery!
44 
45 // calibrated for Adafruit 2.8" ctp screen
46 #define FT62XX_DEFAULT_THRESHOLD 128
47 
48 /**************************************************************************/
53 /**************************************************************************/
54 class TS_Point {
55 public:
56  TS_Point(void);
57  TS_Point(int16_t x, int16_t y, int16_t z);
58 
59  bool operator==(TS_Point);
60  bool operator!=(TS_Point);
61 
62  int16_t x;
63  int16_t y;
64  int16_t z;
65 };
66 
67 /**************************************************************************/
72 /**************************************************************************/
74 public:
75  Adafruit_FT6206(void);
76  boolean begin(uint8_t thresh = FT62XX_DEFAULT_THRESHOLD);
77  uint8_t touched(void);
78  TS_Point getPoint(uint8_t n = 0);
79 
80  // void autoCalibrate(void);
81 
82 private:
83  void writeRegister8(uint8_t reg, uint8_t val);
84  uint8_t readRegister8(uint8_t reg);
85 
86  void readData(void);
87  uint8_t touches;
88  uint16_t touchX[2], touchY[2], touchID[2];
89 };
90 
91 #endif // ADAFRUIT_FT6206_LIBRARY
TS_Point(void)
Instantiates a new FT6206 class with x, y and z set to 0 by default.
Definition: Adafruit_FT6206.cpp:256
bool operator==(TS_Point)
Simple == comparator for two TS_Point objects.
Definition: Adafruit_FT6206.cpp:279
bool operator!=(TS_Point)
Simple != comparator for two TS_Point objects.
Definition: Adafruit_FT6206.cpp:289
int16_t z
Definition: Adafruit_FT6206.h:64
Class that stores state and functions for interacting with FT6206 capacitive touch chips...
Definition: Adafruit_FT6206.h:73
Helper class that stores a TouchScreen Point with x, y, and z coordinates, for easy math/comparison...
Definition: Adafruit_FT6206.h:54
int16_t y
Definition: Adafruit_FT6206.h:63
int16_t x
Definition: Adafruit_FT6206.h:62