There does not seem to be a general solution to this problem. You did not mention how many reading you must average. A 'solution' which works well for two readings may fail for three or more. The article https://en.wikipedia.org/wiki/Mean_of_circular_quantities suggests an algorithm that seems to always do what we want. Too bad it is so complex.