Improved eCompass with support for different sensor options and a new C++ wrapper
Dependents: KL46_eCompass KL46_eCompass_TiltCompensed_Acel-Mag Ragnarok_2ejes compass_acc ... more
Fork of Wi-Go_eCompass_Lib_V3 by
eCompass_Lib.cpp
- Committer:
- JimCarver
- Date:
- 2014-05-16
- Revision:
- 5:1b8ec4e7687b
- Parent:
- 3:98d426530167
- Child:
- 6:a161cb3bd061
File content as of revision 5:1b8ec4e7687b:
#include "eCompass_Lib.h" extern void run_eCompass(void); extern void init_eCompass(void); extern void calibrate_eCompass(void); extern void hal_map(MotionSensorDataCounts * acc_raw, MotionSensorDataCounts * mag_raw); axis6_t axis6; uint32_t seconds; uint32_t compass_type; int32_t tcount; uint8_t cdebug; eCompass::eCompass() { init_eCompass(); cdebug = 0; } //eCompass::~eCompass() { } void eCompass::run(MotionSensorDataCounts &acc_raw, MotionSensorDataCounts &mag_raw) { axis6.timestamp = tcount; hal_map( &acc_raw, &mag_raw); // // raw data axis6.acc_x = acc_raw.x; axis6.acc_y = acc_raw.y; axis6.acc_z = acc_raw.z; axis6.mag_x = mag_raw.x; axis6.mag_y = mag_raw.y; axis6.mag_z = mag_raw.z; // // raw data converted to floating ouing axis6.fax = (float) acc_raw.x; axis6.fay = (float) acc_raw.y; axis6.faz = (float) acc_raw.z; axis6.fmx = (float) mag_raw.x; axis6.fmy = (float) mag_raw.y; axis6.fmz = (float) mag_raw.z; // // Accelerometer data converted to Gs axis6.fGax = ((float) acc_raw.x) / 4096.0f; axis6.fGay = ((float) acc_raw.y) / 4096.0f; axis6.fGaz = ((float) acc_raw.z) / 4096.0f; // // Magnetometer data converted to microteslas axis6.fUTmx = ((float) mag_raw.x) / 10.0f; axis6.fUTmy = ((float) mag_raw.y) / 10.0f; axis6.fUTmz = ((float) mag_raw.z) / 10.0f; //printf("r"); if(!cdebug) run_eCompass(); } void eCompass::calibrate(void) { calibrate_eCompass(); } void eCompass::init(void) { init_eCompass(); }