Resolved an imoortant bug by adding % 360 to bearing diffrence.
Now we can get the accel, deceleration detection cirrectly.