Qtouch AT42QT2160 driver library for mbed

Dependencies:   mbed

Committer:
ksnjth
Date:
Fri Feb 16 10:29:39 2018 +0000
Revision:
0:8961c5b1e7cb
Rev 0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ksnjth 0:8961c5b1e7cb 1 #include "mbed.h"
ksnjth 0:8961c5b1e7cb 2 #include "QT2160.h"
ksnjth 0:8961c5b1e7cb 3
ksnjth 0:8961c5b1e7cb 4 I2C i2c(p28, p27);
ksnjth 0:8961c5b1e7cb 5 DigitalOut myled1(LED1);
ksnjth 0:8961c5b1e7cb 6 InterruptIn change1(p14);
ksnjth 0:8961c5b1e7cb 7 Serial pc(USBTX, USBRX);
ksnjth 0:8961c5b1e7cb 8 int temp=1;
ksnjth 0:8961c5b1e7cb 9
ksnjth 0:8961c5b1e7cb 10 QT S1 = {
ksnjth 0:8961c5b1e7cb 11 i2c,
ksnjth 0:8961c5b1e7cb 12 (0x44 << 1),
ksnjth 0:8961c5b1e7cb 13 1,
ksnjth 0:8961c5b1e7cb 14 1,
ksnjth 0:8961c5b1e7cb 15 20,
ksnjth 0:8961c5b1e7cb 16 5,
ksnjth 0:8961c5b1e7cb 17 2,
ksnjth 0:8961c5b1e7cb 18 50,
ksnjth 0:8961c5b1e7cb 19 25,
ksnjth 0:8961c5b1e7cb 20 8,
ksnjth 0:8961c5b1e7cb 21 0,
ksnjth 0:8961c5b1e7cb 22 {1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0},
ksnjth 0:8961c5b1e7cb 23 {7, 7, 7, 7, 7, 7, 7, 7, 10, 10, 10, 10, 10, 10, 10, 10},
ksnjth 0:8961c5b1e7cb 24 {40, 40, 40, 40, 40, 40, 40, 40, 0, 0, 0, 0, 0, 0, 0, 0}
ksnjth 0:8961c5b1e7cb 25
ksnjth 0:8961c5b1e7cb 26 };
ksnjth 0:8961c5b1e7cb 27
ksnjth 0:8961c5b1e7cb 28 void readS1()
ksnjth 0:8961c5b1e7cb 29 {
ksnjth 0:8961c5b1e7cb 30 QTread(S1);
ksnjth 0:8961c5b1e7cb 31 printf("%d \n", S1.readData.Regs.sliderTouchPosition);
ksnjth 0:8961c5b1e7cb 32 }
ksnjth 0:8961c5b1e7cb 33
ksnjth 0:8961c5b1e7cb 34 int main()
ksnjth 0:8961c5b1e7cb 35 {
ksnjth 0:8961c5b1e7cb 36
ksnjth 0:8961c5b1e7cb 37 pc.baud(230400);
ksnjth 0:8961c5b1e7cb 38 i2c.frequency(100000); // I2C init
ksnjth 0:8961c5b1e7cb 39 printf("Initializing \n");
ksnjth 0:8961c5b1e7cb 40 QTSetup(S1);
ksnjth 0:8961c5b1e7cb 41 printf("QT1 configured \n");
ksnjth 0:8961c5b1e7cb 42 change1.fall(&readS1);
ksnjth 0:8961c5b1e7cb 43 change1.mode(PullUp);
ksnjth 0:8961c5b1e7cb 44 readS1();
ksnjth 0:8961c5b1e7cb 45 while (1)
ksnjth 0:8961c5b1e7cb 46 {
ksnjth 0:8961c5b1e7cb 47
ksnjth 0:8961c5b1e7cb 48 wait_ms(1);
ksnjth 0:8961c5b1e7cb 49 }
ksnjth 0:8961c5b1e7cb 50 }