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: mbed CROTUS_XBee mbed-rtos Crotus_Com
main.cpp@1:3591e7df4ff4, 2017-03-14 (annotated)
- Committer:
- libv2001
- Date:
- Tue Mar 14 12:32:59 2017 +0000
- Revision:
- 1:3591e7df4ff4
- Parent:
- 0:28d5622d1a3e
- Child:
- 3:39b24d902aa7
Modification en lien avec le Code Review de J?rome
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
libv2001 | 0:28d5622d1a3e | 1 | #include "mbed.h" |
libv2001 | 0:28d5622d1a3e | 2 | #include "Magneto.h" |
libv2001 | 0:28d5622d1a3e | 3 | #include "Acc.h" |
libv2001 | 0:28d5622d1a3e | 4 | |
libv2001 | 0:28d5622d1a3e | 5 | DigitalOut myled(LED1); |
libv2001 | 0:28d5622d1a3e | 6 | |
libv2001 | 0:28d5622d1a3e | 7 | I2C i2c(p28, p27); |
libv2001 | 0:28d5622d1a3e | 8 | |
libv2001 | 0:28d5622d1a3e | 9 | Magneto magneto(i2c); |
libv2001 | 0:28d5622d1a3e | 10 | Acc acc(i2c); |
libv2001 | 0:28d5622d1a3e | 11 | |
libv2001 | 0:28d5622d1a3e | 12 | Serial pc(USBTX, USBRX); |
libv2001 | 0:28d5622d1a3e | 13 | |
libv2001 | 0:28d5622d1a3e | 14 | int main() { |
libv2001 | 1:3591e7df4ff4 | 15 | if(!magneto.TestDeviceConnection() || !acc.TestDeviceConnection()){ |
libv2001 | 0:28d5622d1a3e | 16 | pc.printf("SCRUB!!\r\n"); |
libv2001 | 0:28d5622d1a3e | 17 | return -1; |
libv2001 | 0:28d5622d1a3e | 18 | } |
libv2001 | 0:28d5622d1a3e | 19 | |
libv2001 | 0:28d5622d1a3e | 20 | magneto.ActivateDevice(); |
libv2001 | 0:28d5622d1a3e | 21 | acc.ActivateDevice(); |
libv2001 | 0:28d5622d1a3e | 22 | |
libv2001 | 0:28d5622d1a3e | 23 | wait(0.2); |
libv2001 | 0:28d5622d1a3e | 24 | |
libv2001 | 0:28d5622d1a3e | 25 | while(true){ |
libv2001 | 0:28d5622d1a3e | 26 | int16_t heading = magneto.GetHeadingXY(); |
libv2001 | 0:28d5622d1a3e | 27 | int16_t inclination = acc.GetInclinationYZ(); |
libv2001 | 0:28d5622d1a3e | 28 | pc.printf("Heading : %d, Inclination : %d\r\n", heading, inclination); |
libv2001 | 0:28d5622d1a3e | 29 | wait(0.1); |
libv2001 | 0:28d5622d1a3e | 30 | } |
libv2001 | 0:28d5622d1a3e | 31 | } |