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.
Fork of dgps by
handle/handleCompass.h@44:2ae602b89961, 2014-04-23 (annotated)
- Committer:
- krobertson
- Date:
- Wed Apr 23 04:45:36 2014 +0000
- Revision:
- 44:2ae602b89961
- Parent:
- 10:c4745ddaaf6a
its alive! Compass integrated in.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| krobertson | 10:c4745ddaaf6a | 1 | #ifndef _HANDLECOMPASS_H_ |
| krobertson | 10:c4745ddaaf6a | 2 | #define _HANDLECOMPASS_H_ |
| krobertson | 10:c4745ddaaf6a | 3 | |
| krobertson | 10:c4745ddaaf6a | 4 | #include "adapt/compass.h" |
| krobertson | 44:2ae602b89961 | 5 | #include "adapt/usb.h" |
| krobertson | 10:c4745ddaaf6a | 6 | |
| krobertson | 10:c4745ddaaf6a | 7 | class compassHandle { |
| krobertson | 10:c4745ddaaf6a | 8 | public: |
| krobertson | 10:c4745ddaaf6a | 9 | /** |
| krobertson | 10:c4745ddaaf6a | 10 | * \brief the last read compass heading |
| krobertson | 10:c4745ddaaf6a | 11 | **/ |
| krobertson | 10:c4745ddaaf6a | 12 | float heading; |
| krobertson | 10:c4745ddaaf6a | 13 | |
| krobertson | 10:c4745ddaaf6a | 14 | /** |
| krobertson | 10:c4745ddaaf6a | 15 | * \brief constructor for the compass handle. Sets up the compass for reading. |
| krobertson | 10:c4745ddaaf6a | 16 | **/ |
| krobertson | 10:c4745ddaaf6a | 17 | compassHandle(); |
| krobertson | 10:c4745ddaaf6a | 18 | |
| krobertson | 10:c4745ddaaf6a | 19 | /** |
| krobertson | 10:c4745ddaaf6a | 20 | * \brief sets up the compass for reading headings |
| krobertson | 10:c4745ddaaf6a | 21 | **/ |
| krobertson | 10:c4745ddaaf6a | 22 | void setup(); |
| krobertson | 10:c4745ddaaf6a | 23 | |
| krobertson | 10:c4745ddaaf6a | 24 | /** |
| krobertson | 10:c4745ddaaf6a | 25 | * \brief gets an updated heading |
| krobertson | 10:c4745ddaaf6a | 26 | **/ |
| krobertson | 10:c4745ddaaf6a | 27 | void run(); |
| krobertson | 44:2ae602b89961 | 28 | |
| krobertson | 44:2ae602b89961 | 29 | static compassHandle* hand; |
| krobertson | 44:2ae602b89961 | 30 | static compassHandle& getCompassHand(){ |
| krobertson | 44:2ae602b89961 | 31 | if(hand == NULL){ |
| krobertson | 44:2ae602b89961 | 32 | hand = new compassHandle(); |
| krobertson | 44:2ae602b89961 | 33 | } |
| krobertson | 44:2ae602b89961 | 34 | return *hand; |
| krobertson | 44:2ae602b89961 | 35 | } |
| krobertson | 44:2ae602b89961 | 36 | |
| krobertson | 10:c4745ddaaf6a | 37 | private: |
| krobertson | 10:c4745ddaaf6a | 38 | /** |
| krobertson | 10:c4745ddaaf6a | 39 | * \brief reference to the compass adaptor |
| krobertson | 10:c4745ddaaf6a | 40 | **/ |
| krobertson | 10:c4745ddaaf6a | 41 | Compass compass; |
| krobertson | 44:2ae602b89961 | 42 | |
| krobertson | 44:2ae602b89961 | 43 | bool initialized; |
| krobertson | 10:c4745ddaaf6a | 44 | }; |
| krobertson | 10:c4745ddaaf6a | 45 | |
| krobertson | 10:c4745ddaaf6a | 46 | #endif |
