touch screen handler for the microchip AR1020
Revision 6:a6971458d612, committed 2011-02-24
- Comitter:
- hlipka
- Date:
- Thu Feb 24 22:05:04 2011 +0000
- Parent:
- 5:a5eba88e8c3e
- Commit message:
- calibration works now
Changed in this revision
ar1020.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a5eba88e8c3e -r a6971458d612 ar1020.cpp --- a/ar1020.cpp Thu Feb 24 21:30:56 2011 +0000 +++ b/ar1020.cpp Thu Feb 24 22:05:04 2011 +0000 @@ -168,7 +168,7 @@ _enable->write(0); } - wait_us(10); + wait_us(100); writeByte(0x55); wait_us(100); @@ -279,30 +279,36 @@ _enable->write(0); wait_us(10); char cid3[1]={0x04}; - cmd(0x14,cid3,1,false); + r=cmd(0x14,cid3,1,false); + printf("start calibration=%i\n",r); + if (r<0) + return; - wait_ms(1); - + printf("start OK, press upper left\n"); + led1=1; int resp=readCalibResponse(); printf("status=%i\n",resp); - printf("start OK, press upper left"); - led1=1; - resp=readCalibResponse(); - printf("status=%i\n",resp); - printf("press upper right"); + printf("press upper right\n"); led2=1; resp=readCalibResponse(); printf("status=%i\n",resp); - printf("press lower right"); + printf("press lower right\n"); led3=1; resp=readCalibResponse(); printf("status=%i\n",resp); - printf("press lower left"); + printf("press lower left\n"); led4=1; resp=readCalibResponse(); printf("status=%i\n",resp); + printf("exit calibration mode\n"); + + led1=0; + led2=0; + led3=0; + led4=0; _enable->write(1); + wait_ms(1000); r=cmd(0x23,NULL,0); printf("save registers=%i\n",r); @@ -317,7 +323,7 @@ int AR1020::readCalibResponse() { while (true) { while (true) { - wait_us(100); + wait_us(10); if (1==_siq->read()) break; } @@ -329,21 +335,22 @@ continue; } + wait_us(100); r=readByte(); - wait_us(100); if (r!=0x02) { printf("2=0x%x\n",r); continue; } + wait_us(100); r=readByte(); - wait_us(100); if (r!=0x00) { printf("3=0x%x\n",r); continue; } + + wait_us(100); int rc=readByte(); - wait_us(100); if (rc!=0x14) { printf("4=0x%x\n",r); continue;