![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Compass Working
Revision 5:f6762034b4c0, committed 2016-01-19
- Comitter:
- pstephens18
- Date:
- Tue Jan 19 18:51:56 2016 +0000
- Parent:
- 4:92024cb66c9c
- Commit message:
- Second
;
Changed in this revision
Tap.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/Tap.cpp Tue Jan 19 18:43:06 2016 +0000 +++ b/Tap.cpp Tue Jan 19 18:51:56 2016 +0000 @@ -1,7 +1,7 @@ #include "Tap.h" I2C acc(p9,p10); DigitalIn int2(p20); -DigitalOut check(p12); +InterruptIn check(p12); BusOut led(LED1,LED2,LED3,LED4); char acc_config[2]; const int addr=(0x53<<1); @@ -49,30 +49,36 @@ } float Tap() { - while(1) - { - wait(0.01); - - if(int2.read()==1) // Check for interupt signal - { - - acc_config[0]=0x30; - acc.write(addr,acc_config,1); - acc.read(addr,data1,1); // Get interupt information + int2.rise(&Tap_return) + while(1) + { + wait(0.01); - if(data1[0] & 0x40) // Turn on one LED for one tap + if(int2.read()==1) // Check for interupt signal { - led =1; - } - if(data1[0] & 0x20) // Turn on two LEDs for two taps - { - led =2; - } - wait(1); - // Turn off LED - if(led==1){return 1;} - if(led ==2){return 2;} + + acc_config[0]=0x30; + acc.write(addr,acc_config,1); + acc.read(addr,data1,1); // Get interupt information + + if(data1[0] & 0x40) // Turn on one LED for one tap + { + led =1; + } + if(data1[0] & 0x20) // Turn on two LEDs for two taps + { + led =2; + } + wait(1); + // Turn off LED + if(led==1){return 1;} + if(led ==2){return 2;} + + } + } + } + + void Tap_return() + { - } - } -} \ No newline at end of file + } \ No newline at end of file