The site:
formatting link
The latest asm:
formatting link
To improve accuracy of the compass I added auto scaling routines that makes sure the CORDIC atan function always sees the highest possible input vales. Those 16 bit integer CORDIC routines get very inaccurate it seems for small inputs, they work from 1-16383, and show a huge error for small values of x and y. Then I take the abs values, look if x or y is the biggest, divide 16383 / biggest abs, and multiply x and y by that to get large numbers for CORDIC. This is all integer math, that is why. An analog multiplier and AGC could do the same :-) But this took fewer parts. You can rewrite it in C with fleetwood point I guess, but then America is hard to miss, integer should do. Actually IIRC Columbus started navigating using the stars, as his compass pointed away from the stars, because he forgot his GPS, or had no money for one.