curAngle = current angle
oldAngle = old angle
dAngle = angle difference
dAngle = oldAngle-curAngle
Basically store the angle in oldAngle to use for next calculation. You can also checks every 100ms or so (not every frame), compare the angle 100ms ago and now, then you can find out where it is leaning from the difference. You can also apply different levels of tolerance; negligible angle difference shouldn't change the angle, value between 1 and 15 would result in slight leaning, value above 15 into more powerful leaning etc.