2015/08/14

Dependencies:   VNH5019

Dependents:   Cansat_program4_1

Fork of cansat by Mami Yokokawa

Revision:
8:bc3365988ee1
Parent:
7:b24799407d03
Child:
9:ea6a71ec9f9d
--- a/cansat.cpp	Tue Aug 11 01:15:26 2015 +0000
+++ b/cansat.cpp	Wed Aug 12 12:10:26 2015 +0000
@@ -111,10 +111,18 @@
     CanSat::gyro_z = z;    
 }
 void CanSat::set_compass(int16_t x, int16_t y, int16_t z, double angle){
-    CanSat::compass_x = x;
-    CanSat::compass_y = y;
-    CanSat::compass_z = z;
-    CanSat::compass_angle = angle;
+   double setAngle;
+   CanSat::compass_x = x;
+   CanSat::compass_y = y;
+   CanSat::compass_z = z;
+   
+   setAngle = angle-90;
+   if(setAngle < 0){
+       setAngle = setAngle + 360;
+   }
+   setAngle = 360 - setAngle; 
+   
+   CanSat::compass_angle = setAngle;    
 }
 void CanSat::set_pressure(double p){
     CanSat::pressure = p;