symbol ConfigDelay = w2 'Set Compass configure time
symbol configout = b.2 'Compass configure pulse output
ConfigDelay = 50000
high configout ' Set Pulse out to High
pause 6000
pulsout configOut,55000 '500ms pulse to start compass calibration
pause ConfigDelay
pulsout configOut,55000 '500ms pulse to end compass calibration
dspdir:
serout C.1, t9600,($31)
pause 10
serin C.1, t9600, b14, b15, b50, b51, b52, b53, b54, b55 'Read Compasa data from GY-26
serout C.0,n2400,(254,128)
serout C.0,n2400,(" Heading " )
serout C.0,n2400,(254,192)
if b50 = 30 then
serout C.0,n2400,(" ", b51, b52, b53, b54, 210," ")
Else
serout C.0,n2400,(" ",b50, b51, b52, b53, b54, 210," ")
endif
w10 = b50 - 48 * 10 + b51 - 48 * 10 + b52 - 48
select case W10
case 0 to 10
serout C.0,n2400,("N ")
case 11 to 32
serout C.0,n2400,("NNE ")
case 33 to 55
serout C.0,n2400,("NE ")
case 56 to 80
serout C.0,n2400,("ENE ")
case 81 to 101
serout C.0,n2400,("E ")
case 102 to 122
serout C.0,n2400,("ESE ")
case 123 to 149
serout C.0,n2400,("SE ")
case 150 to 170
serout C.0,n2400,("SSE ")
case 171 to 190
serout C.0,n2400,("S ")
case 191 to 212
serout C.0,n2400,("SSW ")
case 213 to 235
serout C.0,n2400,("SW ")
case 236 to 258
serout C.0,n2400,("WSW ")
case 259 to 280
serout C.0,n2400,("W ")
case 281 to 302
serout C.0,n2400,("WNW ")
case 303 to 325
serout C.0,n2400,("NW ")
case 336 to 347
serout C.0,n2400,("NNW ")
case 348 to 360
serout C.0,n2400,("N ")
END SELECT
goto dspdir