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.
Dependencies: FXAS21002
Fork of Hexi_gyro_app by
main.cpp@0:b0767be19223, 2016-08-12 (annotated)
- Committer:
- maclobdell
- Date:
- Fri Aug 12 16:25:02 2016 +0000
- Revision:
- 0:b0767be19223
- Child:
- 1:d26e406e92f9
initial;
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| maclobdell | 0:b0767be19223 | 1 | #include "mbed.h" |
| maclobdell | 0:b0767be19223 | 2 | #include "FXAS21002.h" |
| maclobdell | 0:b0767be19223 | 3 | |
| maclobdell | 0:b0767be19223 | 4 | /* Check out the full featured example application for interfacing to the |
| maclobdell | 0:b0767be19223 | 5 | * Gyro device at the following URL |
| maclobdell | 0:b0767be19223 | 6 | * https://developer.mbed.org/teams/ATT-Hackathon/code/Accel_Mag_Gyro_SensorStream_K64F_AGM01_M/ |
| maclobdell | 0:b0767be19223 | 7 | */ |
| maclobdell | 0:b0767be19223 | 8 | |
| maclobdell | 0:b0767be19223 | 9 | DigitalOut led1(LED1); |
| maclobdell | 0:b0767be19223 | 10 | |
| maclobdell | 0:b0767be19223 | 11 | // Pin connections for Hexiwear |
| maclobdell | 0:b0767be19223 | 12 | FXAS21002 gyro(PTC11,PTC10); |
| maclobdell | 0:b0767be19223 | 13 | // Storage for the data from the sensor |
| maclobdell | 0:b0767be19223 | 14 | float gyro_data[3]; float gyro_rms=0.0; |
| maclobdell | 0:b0767be19223 | 15 | |
| maclobdell | 0:b0767be19223 | 16 | |
| maclobdell | 0:b0767be19223 | 17 | // main() runs in its own thread in the OS |
| maclobdell | 0:b0767be19223 | 18 | // (note the calls to Thread::wait below for delays) |
| maclobdell | 0:b0767be19223 | 19 | int main() { |
| maclobdell | 0:b0767be19223 | 20 | |
| maclobdell | 0:b0767be19223 | 21 | gyro.gyro_config(); |
| maclobdell | 0:b0767be19223 | 22 | while (true) { |
| maclobdell | 0:b0767be19223 | 23 | |
| maclobdell | 0:b0767be19223 | 24 | gyro.acquire_gyro_data_dps(gyro_data); |
| maclobdell | 0:b0767be19223 | 25 | printf("G %4.2f,\t%4.2f,\t%4.2f\r\n",gyro_data[0],gyro_data[1],gyro_data[2]); |
| maclobdell | 0:b0767be19223 | 26 | gyro_rms = sqrt(((gyro_data[0]*gyro_data[0])+(gyro_data[1]*gyro_data[1])+(gyro_data[2]*gyro_data[2]))/3); |
| maclobdell | 0:b0767be19223 | 27 | printf("G RMS %f \n",gyro_rms); |
| maclobdell | 0:b0767be19223 | 28 | |
| maclobdell | 0:b0767be19223 | 29 | led1 = !led1; |
| maclobdell | 0:b0767be19223 | 30 | Thread::wait(1000); |
| maclobdell | 0:b0767be19223 | 31 | } |
| maclobdell | 0:b0767be19223 | 32 | } |
| maclobdell | 0:b0767be19223 | 33 |
