Tony YI
/
ESDC2014
123123123123123123123123123
compass.h@1:cbec1283a16a, 2014-07-03 (annotated)
- Committer:
- terryLAI
- Date:
- Thu Jul 03 03:56:29 2014 +0000
- Revision:
- 1:cbec1283a16a
- Parent:
- 0:3417ca0a36c0
- Child:
- 2:442902ec3aa1
11111
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
terryLAI | 1:cbec1283a16a | 1 | #ifndef COMPASS_H |
terryLAI | 1:cbec1283a16a | 2 | #define COMPASS_H |
TonyYI | 0:3417ca0a36c0 | 3 | |
TonyYI | 0:3417ca0a36c0 | 4 | #include "mbed.h" |
terryLAI | 1:cbec1283a16a | 5 | #include "define.h" |
TonyYI | 0:3417ca0a36c0 | 6 | |
terryLAI | 1:cbec1283a16a | 7 | #define RUN_MSB 0xC7 |
terryLAI | 1:cbec1283a16a | 8 | #define RUN_LSB 0x10 |
terryLAI | 1:cbec1283a16a | 9 | |
terryLAI | 1:cbec1283a16a | 10 | #define STOP_MSB 0xC6 |
terryLAI | 1:cbec1283a16a | 11 | #define STOP_LSB 0x10 |
terryLAI | 1:cbec1283a16a | 12 | |
terryLAI | 1:cbec1283a16a | 13 | #define RESUME_MSB 0xD1 |
terryLAI | 1:cbec1283a16a | 14 | #define RESUME_LSB 0x10 |
TonyYI | 0:3417ca0a36c0 | 15 | |
terryLAI | 1:cbec1283a16a | 16 | #define RST_MSB 0xC2 |
terryLAI | 1:cbec1283a16a | 17 | #define RST_LSB 0x10 |
TonyYI | 0:3417ca0a36c0 | 18 | |
terryLAI | 1:cbec1283a16a | 19 | #define RESUME_MSB 0xD1 |
terryLAI | 1:cbec1283a16a | 20 | #define RESUME_LSB 0x10 |
terryLAI | 1:cbec1283a16a | 21 | |
terryLAI | 1:cbec1283a16a | 22 | #define COMPASS_TX p9 |
terryLAI | 1:cbec1283a16a | 23 | #define COMPASS_RX p10 |
terryLAI | 1:cbec1283a16a | 24 | |
terryLAI | 1:cbec1283a16a | 25 | |
TonyYI | 0:3417ca0a36c0 | 26 | |
TonyYI | 0:3417ca0a36c0 | 27 | #define DECLINATIONANGLE -0.0457 |
TonyYI | 0:3417ca0a36c0 | 28 | #define OFFSET 0 |
TonyYI | 0:3417ca0a36c0 | 29 | |
TonyYI | 0:3417ca0a36c0 | 30 | #include <math.h> |
TonyYI | 0:3417ca0a36c0 | 31 | |
terryLAI | 1:cbec1283a16a | 32 | class COMPASS |
TonyYI | 0:3417ca0a36c0 | 33 | { |
TonyYI | 0:3417ca0a36c0 | 34 | |
TonyYI | 0:3417ca0a36c0 | 35 | public: |
TonyYI | 0:3417ca0a36c0 | 36 | |
terryLAI | 1:cbec1283a16a | 37 | COMPASS(PinName TX, PinName RX); |
terryLAI | 1:cbec1283a16a | 38 | uint16_t Read(); |
terryLAI | 1:cbec1283a16a | 39 | |
TonyYI | 0:3417ca0a36c0 | 40 | |
terryLAI | 1:cbec1283a16a | 41 | private: |
terryLAI | 1:cbec1283a16a | 42 | |
terryLAI | 1:cbec1283a16a | 43 | MySerial *serial; |
terryLAI | 1:cbec1283a16a | 44 | char buffer[2]; |
terryLAI | 1:cbec1283a16a | 45 | uint16_t degree; |
TonyYI | 0:3417ca0a36c0 | 46 | |
terryLAI | 1:cbec1283a16a | 47 | void init(); |
terryLAI | 1:cbec1283a16a | 48 | void run(); |
terryLAI | 1:cbec1283a16a | 49 | void stop(); |
terryLAI | 1:cbec1283a16a | 50 | void resume(); |
terryLAI | 1:cbec1283a16a | 51 | void reset(); |
terryLAI | 1:cbec1283a16a | 52 | void write2Bytes(char msb, char lsb); |
terryLAI | 1:cbec1283a16a | 53 | |
TonyYI | 0:3417ca0a36c0 | 54 | float declinationAngle; |
TonyYI | 0:3417ca0a36c0 | 55 | int offset; |
TonyYI | 0:3417ca0a36c0 | 56 | }; |
TonyYI | 0:3417ca0a36c0 | 57 | |
terryLAI | 1:cbec1283a16a | 58 | #endif /* COMPASS_H */ |