![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Mini Project 10: Displaying stuff from day 7
Dependencies: DmTouch_UniGraphic UniGraphic mbed
acceler_sensor.cpp@0:1ebe73e062a7, 2017-01-17 (annotated)
- Committer:
- swescott17
- Date:
- Tue Jan 17 18:14:15 2017 +0000
- Revision:
- 0:1ebe73e062a7
- Child:
- 6:b196b0a8f337
Added files and libraries from other mini projects;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
swescott17 | 0:1ebe73e062a7 | 1 | #include "acceler_sensor.h" |
swescott17 | 0:1ebe73e062a7 | 2 | DigitalOut led3(LED3); |
swescott17 | 0:1ebe73e062a7 | 3 | |
swescott17 | 0:1ebe73e062a7 | 4 | void acceleration_n(void){ |
swescott17 | 0:1ebe73e062a7 | 5 | |
swescott17 | 0:1ebe73e062a7 | 6 | const int address = 0x53 << 1; // set 'address' to |
swescott17 | 0:1ebe73e062a7 | 7 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 8 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 9 | i2c_port.write(0x1D); //to set the Tap Threshold |
swescott17 | 0:1ebe73e062a7 | 10 | i2c_port.write(0x50 << 2); |
swescott17 | 0:1ebe73e062a7 | 11 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 12 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 13 | |
swescott17 | 0:1ebe73e062a7 | 14 | |
swescott17 | 0:1ebe73e062a7 | 15 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 16 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 17 | i2c_port.write(0x21);//set Tap Duration |
swescott17 | 0:1ebe73e062a7 | 18 | i2c_port.write(0x0A); |
swescott17 | 0:1ebe73e062a7 | 19 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 20 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 21 | |
swescott17 | 0:1ebe73e062a7 | 22 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 23 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 24 | int temp[2] = {0x22, 0x05}; |
swescott17 | 0:1ebe73e062a7 | 25 | i2c_port.write(temp[0]);//set Tap Gap |
swescott17 | 0:1ebe73e062a7 | 26 | i2c_port.write(temp[1]); |
swescott17 | 0:1ebe73e062a7 | 27 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 28 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 29 | |
swescott17 | 0:1ebe73e062a7 | 30 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 31 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 32 | i2c_port.write(0x23);//set Tap Window |
swescott17 | 0:1ebe73e062a7 | 33 | i2c_port.write(0xFF); |
swescott17 | 0:1ebe73e062a7 | 34 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 35 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 36 | |
swescott17 | 0:1ebe73e062a7 | 37 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 38 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 39 | i2c_port.write(0x2A);//set Tap Axis |
swescott17 | 0:1ebe73e062a7 | 40 | i2c_port.write(0x07); |
swescott17 | 0:1ebe73e062a7 | 41 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 42 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 43 | |
swescott17 | 0:1ebe73e062a7 | 44 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 45 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 46 | i2c_port.write(0x2E);//set interupt Enable |
swescott17 | 0:1ebe73e062a7 | 47 | i2c_port.write(0x20|0x40); |
swescott17 | 0:1ebe73e062a7 | 48 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 49 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 50 | |
swescott17 | 0:1ebe73e062a7 | 51 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 52 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 53 | i2c_port.write(0x2F);//set interupt map |
swescott17 | 0:1ebe73e062a7 | 54 | i2c_port.write(0x20|0x40); |
swescott17 | 0:1ebe73e062a7 | 55 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 56 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 57 | |
swescott17 | 0:1ebe73e062a7 | 58 | i2c_port.start(); |
swescott17 | 0:1ebe73e062a7 | 59 | i2c_port.write(address); |
swescott17 | 0:1ebe73e062a7 | 60 | i2c_port.write(0x2D);//power control register |
swescott17 | 0:1ebe73e062a7 | 61 | i2c_port.write(0x08);//measure mode |
swescott17 | 0:1ebe73e062a7 | 62 | i2c_port.stop(); |
swescott17 | 0:1ebe73e062a7 | 63 | wait(0.01); |
swescott17 | 0:1ebe73e062a7 | 64 | |
swescott17 | 0:1ebe73e062a7 | 65 | } |