|
Hello,
This is my sample for HM55B compass, but I dont understand why "fatan2 tofloat x ofloat y, fangle" fangle = 0 when y = 0 I need workaround with "fatan2 tofloat x ofloat y + 0.1, fangle" to get correct compass bearing.
--------------------------------------------------------------------
pdata con p0 pclock con p1 penable con p2
reset con %0000 measure con %1000 report con %1100
status var nib ready con %1100
x var sword y var sword fangle var float angle var word
debut
high penable low penable
shiftout pdata, pclock, msbfirst, [reset4]
high penable low penable
shiftout pdata, pclock, msbfirst, [measure4]
status = 0 repeat high penable low penable shiftout pdata, pclock, msbfirst, [report4] shiftin pdata, pclock, msbpost, [status4] until status = ready
shiftin pdata, pclock, msbpost, [x11, y11]
high penable
if(x.bit10 = 1) then x = x - %11111111111 endif if(y.bit10 = 1) then y = y - %11111111111 endif
fatan2 tofloat x ofloat y + 0.1, fangle angle = toint((fangle / 3.1416) * 180.0) + 179
serout s_out, i38400, ["X = ", sdec x, " Y = ", sdec y, " Angle = ", dec angle, 13] pause 200
goto debut
--------------------------------------------------------------------
|