SOLVED MPU9150,how to add (show) N,E,S,W on the compass in the MPU9150.CPP file

I have now test your code,and is working,your code is much easier.thank you :slight_smile:

OSD.setCursor(3,5);
OSD.print("HEADING:"); 
  OSD.print(vec[VEC3_Z] * RAD_TO_DEGREE + 180,1);
  OSD.setCursor(17,5);

int degrees = vec[VEC3_Z] * RAD_TO_DEGREE + 180 - 22.5;

if ((degrees  < 0) || (degrees > 315 )) OSD.print("NORD");
else if(degrees < 45 ) OSD.print("NORD-QST");
else if(degrees < 90) OSD.print("QST");
else if(degrees  < 135) OSD.print("SQR-QST");
else if (degrees < 180) OSD.print("SQR");
else if (degrees < 225) OSD.print("SQR-VEST");
else if (degrees < 270) OSD.print("VEST");
else OSD.print("NORD-VEST");
  while(PINA&2);