This is my compass calibration branch. It detects offsets and sets scale factors by rotating each mag axis through the same magnetic field. The local Earth magnetic field is the calibration standard.
Calibration movement is prompted by the red and blue leds. The user needs to know approximate north and inclination, but its not necessary. Red means you are increasing to the peak and blue means you past the peak. When you cant find any red you are done with that axis limit. You need to do this twice each axs to get the mins and the maxes.
It is controlled by stick input. Left stick down and left and right stick up and right starts the calibration. Right stick down and left saves the settings and goes to normal read mode.