This is all related to the PX4 stack (Pixhawk) installed on the STM32 flight controller on board.

Please be aware that the compass is not a compass but rather a Magnetometer. The difference is the way they measure and the output. A magnetometer outputs the direction of a detected magnetic field (earth's magnetic field in this case).The heading is derived from a filtered combination of the Accelerometer, Gyroscope and Magnetometer, yielding the attitude of the Quadcopter from which the heading can be extracted.