Use a touchscreen display to select which sensor measurement to display

Dependencies:   mbed DisplayModule24_demo_day10

Committer:
ldelaney17
Date:
Tue Jan 17 19:23:00 2017 +0000
Revision:
5:8a2afc6fdeb0
Child:
7:b275c76de4ba
add compass.h and compass.cpp

Who changed what in which revision?

UserRevisionLine numberNew 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 5:8a2afc6fdeb0 12 void compass_init(int num_avg = 1);
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