Use a touchscreen display to select which sensor measurement to display
Dependencies: mbed DisplayModule24_demo_day10
compass.h@7:b275c76de4ba, 2017-01-17 (annotated)
- Committer:
- ldelaney17
- Date:
- Tue Jan 17 21:08:45 2017 +0000
- Revision:
- 7:b275c76de4ba
- Parent:
- 5:8a2afc6fdeb0
- Child:
- 8:a7b7edb66de5
Final working version; still needs some more comments, but everything works
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ldelaney17 | 5:8a2afc6fdeb0 | 1 | /* |
ldelaney17 | 5:8a2afc6fdeb0 | 2 | * Compass I2C interface header file |
ldelaney17 | 5:8a2afc6fdeb0 | 3 | * Laura Delaney |
ldelaney17 | 5:8a2afc6fdeb0 | 4 | * 1/11/2017 |
ldelaney17 | 5:8a2afc6fdeb0 | 5 | */ |
ldelaney17 | 5:8a2afc6fdeb0 | 6 | |
ldelaney17 | 5:8a2afc6fdeb0 | 7 | #ifndef COMPASS_H_ |
ldelaney17 | 5:8a2afc6fdeb0 | 8 | #define COMPASS_H_ |
ldelaney17 | 5:8a2afc6fdeb0 | 9 | |
ldelaney17 | 5:8a2afc6fdeb0 | 10 | extern I2C connection; |
ldelaney17 | 5:8a2afc6fdeb0 | 11 | //initialize the sensor to single measure mode |
ldelaney17 | 7:b275c76de4ba | 12 | void compass_init(int num = 5); |
ldelaney17 | 5:8a2afc6fdeb0 | 13 | //calculates the heading from the data, prints the heading if DEBUG_MODE is defined |
ldelaney17 | 5:8a2afc6fdeb0 | 14 | float calc_heading(short mags[3], float declination); //x, z, y |
ldelaney17 | 5:8a2afc6fdeb0 | 15 | //gets the heading, adjusted for the given declination |
ldelaney17 | 5:8a2afc6fdeb0 | 16 | float get_heading(float declination); //spokane is +14.85 and getting smaller |
ldelaney17 | 5:8a2afc6fdeb0 | 17 | //gets the average of n readings. If n is not given, averages 5 readings |
ldelaney17 | 5:8a2afc6fdeb0 | 18 | float get_avg_heading(float declination, int n = 5); |
ldelaney17 | 5:8a2afc6fdeb0 | 19 | |
ldelaney17 | 5:8a2afc6fdeb0 | 20 | #endif |