Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
QT1070.h
00001 #ifndef QT1070_H 00002 #define QT1070_H 00003 00004 #include "mbed.h" 00005 00006 /** AT42QT1070 class 00007 * Seven-channel QTouch® Touch Sensor Driver 00008 * 00009 * Example: 00010 * @code 00011 * #include "mbed.h" 00012 * #include "QT1070.h" 00013 * 00014 * DigitalOut led(LED1); 00015 * I2C i2c(PB_7,PB_6); 00016 * QT1070 touch(&i2c, PA_11); 00017 * 00018 * int main() { 00019 * touch.guard(0); 00020 * touch.aksAve(5,0,0); // Disable key5 AVE=0 00021 * touch.aksAve(6,0,0); // Disable key6 AVE=0 00022 * 00023 * while(1) { 00024 * if(touch.change()){ 00025 * led=!led; 00026 * printf("Key %d!!!!\r\n", touch.key()); 00027 * } 00028 * } 00029 * } 00030 * @endcode 00031 */ 00032 00033 class QT1070{ 00034 public: 00035 enum state{ 00036 I2C_ADDR = 0x36, //I2C adress 00037 KEY_NUM = 0x07, //Number of channel 00038 AVEMAX = 31, //Averaging maximum 00039 AKSMAX = 3 //Group maximum 00040 }; 00041 00042 //Register map 00043 enum reg{ 00044 REG_CHIPID = 0, 00045 REG_FIRMW = 1, 00046 REG_STATUS = 2, 00047 REG_KEYSTAT = 3, 00048 REG_KEYSIG0 = 4, 00049 REG_REFDAT0 = 18, 00050 REG_NTHR0 = 32, 00051 REG_AVEAKS0 = 39, 00052 REG_DI0 = 46, 00053 REG_FOMOGRD = 53, 00054 REG_LOWPWR = 54, 00055 REG_MAXOND = 55, 00056 REG_CALIB = 56, 00057 REG_RESET = 57 00058 }; 00059 00060 /** Create PCA9633 instance + config method 00061 * @param *i2c initialized I2C bus to use 00062 * @param change PinName if connected 00063 */ 00064 QT1070(I2C *i2c, PinName change=NC); 00065 00066 /** Get key reg. 00067 * @rerun 0 if not, 2^key if hit 00068 */ 00069 char key(void); 00070 00071 /** Check a change in status 00072 * @return true in change occurs 00073 */ 00074 bool change(void); 00075 00076 /** Get signal. 00077 * @param key <0,6> key number 00078 */ 00079 unsigned short signal(char key); 00080 00081 /** Get reference. 00082 * @param key <0,6> key number 00083 */ 00084 unsigned short ref(char key); 00085 00086 /** Set/Get negative threshold. 00087 * @param key <0,6> key number 00088 * @param val <1,255> (Getter if 0) 00089 */ 00090 char nthresh(char key, char val=0); 00091 00092 /** Set/Get adjacent supresssor group and averaging. 00093 * @param key <0,6> key number 00094 * @param group <0,3> adjacent key suppressor group of the key 00095 * @param ave <1,31> averaged signal value 00096 */ 00097 char aksAve(char key, char group=1, char ave=8); 00098 00099 /** set DI. 00100 * @param key <0,6> key number 00101 * @param val <2,255> how measurement before confirm key hit 00102 */ 00103 void detectInt(char key, char val); 00104 00105 /** Set fastout and Maxcal. 00106 * @param fo set the digital integrator of 4 for all channel 00107 * @param maxcal if set only the key timeout was recalibrated 00108 */ 00109 void foMaxCal(bool fo, bool maxcal=false); 00110 00111 /** Set a key to be guard channel (priority filtering). 00112 * @param key <0,6> key number 00113 */ 00114 void guard(char key); 00115 00116 /** Set interval between key measurment to reduce pwr. 00117 * @param ms <8,2040>[ms] in step of 8ms 00118 */ 00119 void lowpwr(unsigned short ms); 00120 00121 /** Set how long any key can be touch before it recalibrates itself. 00122 * @param ms <0,40800>[ms] in step of 160ms 00123 */ 00124 void maxOnDuration(unsigned short ms); 00125 00126 /** Trig a calibration cycle 00127 */ 00128 void calibrate(void); 00129 00130 /** Trig a RESET 00131 */ 00132 void reset(void); 00133 00134 protected: 00135 void write(char reg, char data); 00136 void writeW(char reg, unsigned short data); 00137 char read(char reg); 00138 unsigned short readW(char reg); 00139 00140 private: 00141 I2C *_i2c; 00142 DigitalIn _change; 00143 }; 00144 00145 #endif
Generated on Mon Jul 25 2022 23:10:23 by
