Allan Li
/
Final_Demo
GPS and Compass update every1 sec
main.cpp@0:b28303f602dc, 2013-11-17 (annotated)
- Committer:
- airaylee
- Date:
- Sun Nov 17 22:17:18 2013 +0000
- Revision:
- 0:b28303f602dc
- Child:
- 1:ce62180e1576
For ECE4180 Final Project
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
airaylee | 0:b28303f602dc | 1 | #include "HMC6352.h" |
airaylee | 0:b28303f602dc | 2 | #include "mbed.h" |
airaylee | 0:b28303f602dc | 3 | #include "GPS.h" |
airaylee | 0:b28303f602dc | 4 | |
airaylee | 0:b28303f602dc | 5 | //HMC6352 use an I2C interface so we here have scl-p27 and sda-28 |
airaylee | 0:b28303f602dc | 6 | //BR-355 GPS use serial port p10-RX |
airaylee | 0:b28303f602dc | 7 | HMC6352 compass(p28, p27); |
airaylee | 0:b28303f602dc | 8 | Serial pc(USBTX, USBRX); |
airaylee | 0:b28303f602dc | 9 | GPS gps(p9, p10); |
airaylee | 0:b28303f602dc | 10 | |
airaylee | 0:b28303f602dc | 11 | int main() { |
airaylee | 0:b28303f602dc | 12 | pc.printf("Starting HMC6352 test...\n"); |
airaylee | 0:b28303f602dc | 13 | //Continuous mode, periodic set/reset, 20Hz measurement rate. |
airaylee | 0:b28303f602dc | 14 | compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); |
airaylee | 0:b28303f602dc | 15 | while (1) { |
airaylee | 0:b28303f602dc | 16 | wait(1); |
airaylee | 0:b28303f602dc | 17 | pc.printf("The compass Heading is: %f\n", compass.sample() / 10.0); |
airaylee | 0:b28303f602dc | 18 | if(gps.sample()){ |
airaylee | 0:b28303f602dc | 19 | pc.printf("I'm at %f, %f\n", gps.longitude, gps.latitude); |
airaylee | 0:b28303f602dc | 20 | } |
airaylee | 0:b28303f602dc | 21 | else{ |
airaylee | 0:b28303f602dc | 22 | pc.printf("Oh, no signal......"); |
airaylee | 0:b28303f602dc | 23 | } |
airaylee | 0:b28303f602dc | 24 | } |
airaylee | 0:b28303f602dc | 25 | } |
airaylee | 0:b28303f602dc | 26 |