
fuji-compass
main.cpp@0:25754a2bb950, 2014-02-22 (annotated)
- Committer:
- com3
- Date:
- Sat Feb 22 08:48:03 2014 +0000
- Revision:
- 0:25754a2bb950
compass
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
com3 | 0:25754a2bb950 | 1 | #include "HMC6352.h" |
com3 | 0:25754a2bb950 | 2 | HMC6352 compass(p9, p10); |
com3 | 0:25754a2bb950 | 3 | |
com3 | 0:25754a2bb950 | 4 | uint8_t compassdef = 0; |
com3 | 0:25754a2bb950 | 5 | |
com3 | 0:25754a2bb950 | 6 | int main() { |
com3 | 0:25754a2bb950 | 7 | |
com3 | 0:25754a2bb950 | 8 | |
com3 | 0:25754a2bb950 | 9 | compass.setOpMode(HMC6352_CONTINUOUS, 1, 20); |
com3 | 0:25754a2bb950 | 10 | compassdef = (compass.sample() / 10); |
com3 | 0:25754a2bb950 | 11 | |
com3 | 0:25754a2bb950 | 12 | |
com3 | 0:25754a2bb950 | 13 | |
com3 | 0:25754a2bb950 | 14 | tx_data = ((compass.sample() / 10) + 540 - compassdef) % 360; |
com3 | 0:25754a2bb950 | 15 | |
com3 | 0:25754a2bb950 | 16 | } |
com3 | 0:25754a2bb950 | 17 |