Final version of project
Dependencies: FSR LSM9DS1_Library_cal USBMIDI mbed
Fork of LSM9DS1_Demo_wCal by
Diff: main.cpp
- Revision:
- 3:de36d456f684
- Parent:
- 2:82b2a1e84586
- Child:
- 4:f0cd8d252c08
diff -r 82b2a1e84586 -r de36d456f684 main.cpp --- a/main.cpp Fri Apr 29 13:21:09 2016 +0000 +++ b/main.cpp Fri Apr 29 13:23:44 2016 +0000 @@ -90,35 +90,6 @@ StateType state = FRONT; // Initial state is FRONT StateType2 state2 = FRONT2; -// Calculate pitch, roll, and heading. -// Pitch/roll calculations taken from this app note: -// http://cache.freescale.com/files/sensors/doc/app_note/AN3461.pdf?fpsp=1 -// Heading calculations taken from this app note: -// http://www51.honeywell.com/aero/common/documents/myaerospacecatalog-documents/Defense_Brochures-documents/Magnetic__Literature_Application_notes-documents/AN203_Compass_Heading_Using_Magnetometers.pdf - -void printAltitude(float ax, float ay, float az, float mx, float my, float mz) -{ - float roll = atan2(ay, az); - float pitch = atan2(-ax, sqrt(ay * ay + az * az)); -// touchy trig stuff to use arctan to get compass heading (scale is 0..360) - mx = -mx; - float heading; - if (my == 0.0) - heading = (mx < 0.0) ? 180.0 : 0.0; - else - heading = atan2(mx, my)*360.0/(2.0*PI); - pc.printf("heading atan=%f \n\r",heading); - heading -= DECLINATION; //correct for geo location - if(heading>180.0) heading = heading - 360.0; - else if(heading<-180.0) heading = 360.0 + heading; - else if(heading<0.0) heading = 360.0 + heading; - - - // Convert everything from radians to degrees: - //heading *= 180.0 / PI; - pitch *= 180.0 / PI; - roll *= 180.0 / PI; -} void show_message(MIDIMessage msg) { switch (msg.type()) {