spiritplumber
Member
sorry for the double post... I realized that if you trim the sertxd stuff this fits on a 08M, so I guess it's good for almost all the picaxes
again, just trim out the sertxd.
'
'
' Simplified version of gps navigation to just get to a waypoint and just do bearing->tracking.
' Can be used with a route by checking the proximity warning and nav ID.
' Requires navpoint names to be numbers in the format 000..255 (use leading zeros please).
'
' gps is hooked up to this pin.
symbol GPS_IN = 0
'navigation temporary memory map when grabbing string, let's try to fit everything in one place
symbol Bear1 = w0 ' 0 1
symbol Track1 = w1 ' 2 3
symbol Steer = b4 '2
symbol Prox = b5 '2
symbol Range1 = b6 '3
symbol Range2 = b7 '3
symbol OffTrk1= b8 '4
symbol OffTrk2= b10 '4
symbol NavName=b9 '5
symbol Track2 =b11 '5
symbol Unused = w6
symbol Unused1= b12
symbol Bear2 = b13
' calculated vars memory map for actual use
symbol Bear = w0
symbol Track = w1
' w2 is prox alert and steering, they stay the same
symbol Range = w3
symbol OffTrk = b8
' NavName gets preserved
' 10, 11, 12, 13 should be preserved
getgps:
gosub preservevars
serin GPS_IN, N4800, ("$GPRMC" ' lose UTC time coz we don't care
serin GPS_IN, N4800, (",A,",#Unused,#Unused,Unused1,#Unused,#Unused,Unused1,#Unused,#Unused,#Bear1,#Bear2
serin GPS_IN, N4800, ("RMB,A,",#OffTrk1,#OffTrk2,Steer
poke $C0, Bear2 ' bear2 is part of scratch, so let's deal with that
poke $C1, Unused ' do this 3 times at 4Mhz to insert correct delay
poke $C2, Bear2 ' do this 3 times at 4Mhz to insert correct delay
' LIMITATION: Navpoint names must be numbers right now. Fix it later!
serin GPS_IN, N4800, (",", #NavName, #Unused, #Unused, Unused1, #Unused, #Unused, Unused1, #Range1, #Range2, #Track1, #Track2, Unused1, Prox
peek $C0, Bear2 ' restore since we're done with scratch vars
calculate:
' calculations go here; use w2 as scratch var
poke $C4, Steer
poke $C5, Prox
w2 = Bear1
w2 = w2 * 10
w2 = w2 + Bear2
Bear = w2
w2 = Track1
w2 = w2 * 10
w2 = w2 + Track2
Track = w2
w2 = Range1
w2 = w2 * 10
w2 = w2 + Range2
Range = w2
w2 = OffTrk1
w2 = w2 * 10
w2 = w2 + OffTrk2
OffTrk = w2
peek $C4, Steer
peek $C5, Prox
gosub restorevars ' if we were using them for other stuff
' do whatever you need here, memory map should be:
'bearing
'bearing
'tracking
'tracking
'steer l/r
'prox alert
'range
'range
'offtrack
'navpoint #
'stuff from before getgps
'stuff from before getgps
'stuff from before getgps
'stuff from before getgps
' just printing the data -- note that everything must be divided by 10, i'm not doing it here to show the format
sertxd ("Destination ID: ",#NavName, " Offtrack: ",#OffTrk," - Steer "
gosub printdir
sertxd (13,10)
sertxd ("Distance: ",#Range," - Head/Track: ",#Bear,"/",#Track," Arrived: "
gosub printarr
sertxd (13,10)
goto getgps
end
' subroutines start here
printdir:
if Steer = "R" then printright
sertxd("Left "
return
printright:
sertxd("Right"
return
printarr:
if Prox = "A" then printyes
sertxd("No "
return
printyes:
sertxd("Yes"
return
preservevars:
poke $CA,b10
poke $CB,b11
poke $CC,b12
poke $CD,b13
return
restorevars:
peek $CA,b10
peek $CB,b11
peek $CC,b12
peek $CD,b13
return
again, just trim out the sertxd.
'
'
' Simplified version of gps navigation to just get to a waypoint and just do bearing->tracking.
' Can be used with a route by checking the proximity warning and nav ID.
' Requires navpoint names to be numbers in the format 000..255 (use leading zeros please).
'
' gps is hooked up to this pin.
symbol GPS_IN = 0
'navigation temporary memory map when grabbing string, let's try to fit everything in one place
symbol Bear1 = w0 ' 0 1
symbol Track1 = w1 ' 2 3
symbol Steer = b4 '2
symbol Prox = b5 '2
symbol Range1 = b6 '3
symbol Range2 = b7 '3
symbol OffTrk1= b8 '4
symbol OffTrk2= b10 '4
symbol NavName=b9 '5
symbol Track2 =b11 '5
symbol Unused = w6
symbol Unused1= b12
symbol Bear2 = b13
' calculated vars memory map for actual use
symbol Bear = w0
symbol Track = w1
' w2 is prox alert and steering, they stay the same
symbol Range = w3
symbol OffTrk = b8
' NavName gets preserved
' 10, 11, 12, 13 should be preserved
getgps:
gosub preservevars
serin GPS_IN, N4800, ("$GPRMC" ' lose UTC time coz we don't care
serin GPS_IN, N4800, (",A,",#Unused,#Unused,Unused1,#Unused,#Unused,Unused1,#Unused,#Unused,#Bear1,#Bear2
serin GPS_IN, N4800, ("RMB,A,",#OffTrk1,#OffTrk2,Steer
poke $C0, Bear2 ' bear2 is part of scratch, so let's deal with that
poke $C1, Unused ' do this 3 times at 4Mhz to insert correct delay
poke $C2, Bear2 ' do this 3 times at 4Mhz to insert correct delay
' LIMITATION: Navpoint names must be numbers right now. Fix it later!
serin GPS_IN, N4800, (",", #NavName, #Unused, #Unused, Unused1, #Unused, #Unused, Unused1, #Range1, #Range2, #Track1, #Track2, Unused1, Prox
peek $C0, Bear2 ' restore since we're done with scratch vars
calculate:
' calculations go here; use w2 as scratch var
poke $C4, Steer
poke $C5, Prox
w2 = Bear1
w2 = w2 * 10
w2 = w2 + Bear2
Bear = w2
w2 = Track1
w2 = w2 * 10
w2 = w2 + Track2
Track = w2
w2 = Range1
w2 = w2 * 10
w2 = w2 + Range2
Range = w2
w2 = OffTrk1
w2 = w2 * 10
w2 = w2 + OffTrk2
OffTrk = w2
peek $C4, Steer
peek $C5, Prox
gosub restorevars ' if we were using them for other stuff
' do whatever you need here, memory map should be:
'bearing
'bearing
'tracking
'tracking
'steer l/r
'prox alert
'range
'range
'offtrack
'navpoint #
'stuff from before getgps
'stuff from before getgps
'stuff from before getgps
'stuff from before getgps
' just printing the data -- note that everything must be divided by 10, i'm not doing it here to show the format
sertxd ("Destination ID: ",#NavName, " Offtrack: ",#OffTrk," - Steer "
gosub printdir
sertxd (13,10)
sertxd ("Distance: ",#Range," - Head/Track: ",#Bear,"/",#Track," Arrived: "
gosub printarr
sertxd (13,10)
goto getgps
end
' subroutines start here
printdir:
if Steer = "R" then printright
sertxd("Left "
return
printright:
sertxd("Right"
return
printarr:
if Prox = "A" then printyes
sertxd("No "
return
printyes:
sertxd("Yes"
return
preservevars:
poke $CA,b10
poke $CB,b11
poke $CC,b12
poke $CD,b13
return
restorevars:
peek $CA,b10
peek $CB,b11
peek $CC,b12
peek $CD,b13
return