Revised Figure11.txt 100 : 110 REMark Set ShowTrack% to 0 for orbits, 1 for track 120 ShowTrack%= 0 130 REMark For orbits: set Blobs% to 1 for blobs, 0 for lines 140 Blobs%= 1 150 : 160 CLOSE 170 REMark Serial Port: 6 for PC, 1 for Laptop 180 SerPort%= 6 190 maxid= 30: REMark highest permitted satellite id no. 200 : 210 IF ShowTrack% >0 THEN 220 Minlon=0: Minlat=0: Maxlon=0: Maxlat=0 230 REMark PRINT Minlon,Minlat,Maxlon,Maxlon 240 REMark For displaying track must set min and max 250 REMark lat and lon or call a procedure to do so ... 260 ChiCityMap 270 REMark PfdMap 280 : 290 REMark See Jan Jones page 39, 40 300 IF (1+ Minlon+ Minlat+ Maxlon+ Maxlat)= 1 THEN 310 CLS 320 PRINT \\\" *** Map limits not set ***": STOP 330 END IF 340 END IF 350 : 360 COLOUR_PAL 370 REMark For orbit display: 380 REMark Colours used for spot showing first observed 390 REMark position and use of satellite 400 seentint%= 194: usdtint%= 96 410 : 420 REMark *********************************** 430 sim= 1: REMark Set to 0 for receiver input 440 REMark 1 for file input 450 REMark Set dtof to 1 to save raw data to win1_sats_data 460 dtof= 0 470 REMark No point in saving already saved data! 480 IF sim <> 0 THEN dtof = 0 490 REMark *********************************** 500 : 510 CLS#0: CLS 520 CSIZE 0,0 530 : 540 REMark Set up the Serial Port if needed 550 IF sim THEN 560 REMark Serial Port simulated by data file 570 cs%= FOP_IN("win1_gps_sats_dat") 580 : 590 ELSE 600 REMark For real time data from receiver 610 REMark SerPort% set to 6 or 1 at start of program 620 BAUD SerPort%,4800 630 SerPort$= SerPort% 640 cs%= FOPEN("srx"&SerPort$&"IA") 650 END IF 660 : 670 REMark Window to display raw data 680 dd%= FOPEN ("con") 690 WINDOW #dd%,550,75,0,525 700 BORDER #dd%,1,9,1 710 PAPER #dd%,36: INK #dd%,0: CLS #dd% 720 : 730 REMark Window to display error and other messages 740 REMark in particular, corrupted data 750 de%= FOPEN ("con") 760 WINDOW #de%,400,75,400,45 770 BORDER #de%,1,9,1 780 PAPER #de%,39: INK #de%,0: CLS #de%: REMark paper was 36 790 : 800 REMark Delay in seconds between readings 810 REMark to avoid enormous sats_data file 820 INPUT "Delay in seconds",delay 830 : 840 REMark Window for main display of orbits or track 850 asprat= .8: REMark aspect ratio: width/height 860 size = 3.5: REMark for early fiddling with windows 870 dc%= FOPEN ("con") 880 Mctr= COS(RAD((Minlat+Maxlat)/2)) 890 High= 100*size 900 Wide= 137*size*asprat 910 WINDOW #dc%,Wide,High,0,525-High 920 BORDER #dc%,1,9,1 930 INK #dc%,0 940 PAPER #dc%,37: CLS #dc% 950 : 960 REMark ==================================================== 970 REMark Set up for track display 980 IF ShowTrack% <>0 THEN 990 difflon= Maxlon- Minlon 1000 difflat= Maxlat- Minlat 1010 SCALE #dc%,difflat,Minlon*asprat*Mctr, Minlat 1020 : 1030 REMark Lat and Lon grid 1040 LatLonGrid 1050 : 1060 REMark window to show instantaneous track and speed 1070 dt%= FOPEN ("scr") 1080 Topdc%= 525-High+3 1090 WINDOW #dt%,137/4*size*asprat,100/4*size,285,Topdc%: 1100 BORDER #dt%,1,9,1 1110 SCALE #dt%,200,-100*asprat,-100 1120 PAPER #dt%,37: CLS #dt%: 1130 ELSE 1140 REMark For orbit display 1150 SCALE #dc%,2.2,-1.1*asprat,-1.1 1160 REMark Set up alternative for orbits 1170 SatSky 1180 END IF 1190 REMark ================================================= 1200 : 1210 REMark Open a file to collect the data for simulation 1220 IF dtof <> 0 THEN 1230 fc%= FOP_NEW(win1_sats_data) 1240 END IF 1250 : 1260 REMark :::::::::::::::::::::::::::::::::::::::::::::::::: 1270 REMark This was originally the only display, put DEF PROC 1280 REMark round it to allow alternative track display 1290 REMark Window #dc% already defined as same size for both 1300 DEFine PROCedure SatSky 1310 REMark Sky disk 1320 FILL#dc%,1 1330 INK#dc%,29 1340 ELLIPSE#dc%,0,0,1,1*asprat,0 1350 FILL#dc%,0 1360 : 1370 REMark Draw polar plot grid lines 1380 INK#dc%,12 1390 radials : REMark draw the bearings 1400 REMark now draw the elevations 1410 FOR i = 1 TO 3 1420 ELLIPSE#dc%,0,0,i/3,1*asprat,0 1430 END FOR 1440 LINE#dc%,-1.02*asprat,0 TO 1.02*asprat,0 1450 LINE#dc%,0,-1.02 TO 0,1.02 1460 : 1470 REMark Mark points of compass 1480 INK#dc%,9 1490 CURSOR#dc%,1.03*asprat,0,0,-4 1500 PRINT#dc%,"E" 1510 CURSOR#dc%,-1.03*asprat,0,-6,-4 1520 PRINT#dc%,"W" 1530 CURSOR#dc%,0,1.04,-3,-8 1540 PRINT#dc%,"N" 1550 CURSOR#dc%,0,-1.03,-3,2 1560 PRINT#dc%,"S" 1570 : 1580 REMark Mark azimuth scale 1590 FOR i= 30 TO 330 STEP 30 1600 IF (i MOD 90) = 0 THEN NEXT i 1610 j= i+90 1620 CURSOR#dc%,1.03*COS(j*PI/180)*asprat,1.03*SIN (j*PI/180),-6,-5 1630 PRINT#dc%,360-i 1640 END FOR i 1650 : 1660 REMark mark elevation scale 1670 FOR i= 0 TO 3 1680 CURSOR#dc%,0,i/3,-6,-5 1690 PRINT#dc%,90-30*i 1700 END FOR i 1710 END DEFine SatSky 1720 : 1730 REMark :::::::::::::::::::::::::::::::::::::::::::::::::::: 1740 : 1750 REMark Display set up, now get ready for GPS data 1760 : 1770 REMark Array to store raw data lines from receiver 1780 DIM rawdata$(5,128) 1790 REMark Array to store satellite data .. 1800 REMark with: IdNo, Bearing, Elevation, Usage 1810 REMark where: Usage is 0 for not used, 1 for used. 1820 DIM satsvis(11,3) : REMark Allow for 12 satellites in view 1830 : 1840 DIM satsusd(11) : REMark List of Ids of satellites used. 1850 : 1860 REMark I use copies of the raw data ... 1870 DIM satlist$(6,128):REMark Satellite data from $GPSGV input 1880 REMark Allow for 7 $GPSV lines (OTT -- never more than 2!) 1890 : 1900 DIM rmcdata$(128) : REMark Lat, Long, Time 1910 : 1920 REMark Posns for orbits plotted as lines 1930 REMark to draw a blob for first point, then a line 1940 REMark Store: Old x,y; New x,y: 5th item, 0= new orbit .. 1950 REMark .. so draw a blob, 1= orbit started so draw line 1960 DIM posns(maxid,5): REMark need enough for each satellite 1970 REMark set all to zero for a start 1980 FOR i%= 0 TO maxid-1 1990 FOR j%= 0 TO 4 2000 posns(i%,j%)= 0 2010 END FOR j% 2020 END FOR i% 2030 : 2040 CLS 2050 REMark For plotting track, need a POINT to start 2060 REMark then continue with lines. 2070 REMark Don't bother not defining this if orbits 2080 FirstPt%=0 2090 : 2100 lines=0: REMark A count of input lines 2110 GoodLines=0: REMark Another count of input lines 2120 CLS #dd%: REMark I needed this for raw data display 2130 : 2140 REMark ===================================================== 2150 REMark Setting up complete, now for ... 2160 REMark ... data reading and display 2170 : 2180 REMark Repeat loop for continous display 2190 REMark delay at end 2200 REMark Each run through loop deals with a single set 2210 REMark of data sentences, five in my case, starting 2220 REMark with a $GPGGA. Sent each second, but read 2230 REMark at a rate determined by missing some with the delay 2240 REMark Test for end in gpsdata$ function 2250 : 2260 REPeat orbits 2270 AT #dd%,0,0: AT 0,0: REMark To keep the display tidy 2280 REMark I read all the sentences at one go so that I 2290 REMark don't end up with some from a later second's lot. 2300 rawdata$(0)= gpsdata$("$GPGGA"): REMark Wait for a first 2310 rawdata$(1)= gpsdata$("$GPGSA"): REMark ... read the rest 2320 rawdata$(2)= gpsdata$("$GPGSV") 2330 rawdata$(3)= gpsdata$("$GPGSV") 2340 rawdata$(4)= gpsdata$("$GPRMC") 2350 lines= lines+5: REMark lines, GoodLines bit messy ... 2360 REMark ... intended it to help look at corrupted data 2370 REMark Check lines for not corrupted data 2380 FOR i= 0 TO 4 2390 REMark Go through data to look for corrupted lines. 2400 REMark This became a long winded process, so that is 2410 REMark why I read all the sentences in one go. 2420 REMark Ignoring all the set of data, if there is one 2430 REMark corrupted item ,is a bit OTT, but safe. 2440 : 2450 REMark Sometimes get lines much longer than spec. .. 2460 REMark .. 'Long' lines seem to be a normal line but .. 2470 REMark .. no and followed by more, .. 2480 REMark .. badly formed, data, so ignore them: 2490 ChkFld%= '*' INSTR rawdata$(i) 2500 IF LEN(rawdata$(i)) > ChkFld%+ 3 THEN NEXT orbits 2510 : 2520 IF dtof <> 0 THEN 2530 PRINT #fc%,rawdata$(i): REMark Save in file if needed 2540 END IF 2550 : 2560 REMark Ckeck 'Checksum' field 2570 Check%= CheckSum(rawdata$(i)) 2580 IF Check% <> 0 THEN 2590 NEXT orbits 2600 END IF 2610 GoodLines= GoodLines+1 2620 DisLine dd%,GoodLines&" "&rawdata$(i),0 2630 END FOR i 2640 : 2650 REMark Get ready forlist of satellites used 2660 REMark from $GPGSA data line 2670 gpsAdata$ = rawdata$(1): REMark cautiously use copies 2680 : 2690 REMark Get ready for list of satellite data 2700 REMark First $GPGSV line gives no of $GPSV lines 2710 satlist$(1) = rawdata$(2) 2720 REMark Extract number of $GPGSV lines 2730 novrecs% = satlist$(1,8) 2740 : 2750 REMark Get rest of $GPGSV lines 2760 REMark FOR j= 2 to novrecs% 2770 REMark satlist$(j)= gpsdata$("GPGSV") 2780 REMark END FOR 2790 REMark Had trouble with that so .. assumed always two ... 2800 satlist$(2)= rawdata$ (3) 2810 : 2820 REMark Get RMC data 2830 REMark Too late now, but should use a copy of raw data! 2840 gpsrmc$= gpsdata$ ( "$GPRMC") 2850 : 2860 REMark Start at first $GPGSV line 2870 t$= satlist$(1): REMark To leave full data for later 2880 f$= field$(chop$(t$,3)) 2890 REMark IF NumChk(f$)<>0 THEN NEXT orbits 2900 novsats%= f$ 2910 : 2920 REMark Now have all the data needed for display 2930 : 2940 REMark Extract satellites used into satsusd array 2950 REMark from $GPGGA line 2960 v$= chop$(gpsAdata$,2) 2970 i= 0: REMark Count for sused REPeat loop 2980 PRINT \" Sats used : "; 2990 : 3000 REMark Extract time and validity 3010 UTC$= GPSTime$(rawdata$(4)) 3020 Inv%= 0: REMark to record invalid time and data 3030 IF gpsrmc$(18)= "V": Inv%=1 3040 : 3050 REPeat sused 3060 v$= chop$(gpsAdata$,1) 3070 REMark Mark end of list with -1 3080 IF v$(1)="," THEN satsusd(i)= -1: EXIT sused 3090 f$= field$(v$) 3100 IF LEN(f$) =0 THEN NEXT orbits 3110 satsusd(i)=f$ 3120 IF satsusd(i)<10 THEN PRINT "0"; 3130 PRINT satsusd(i);" "; 3140 i= i+1 3150 END REPeat sused 3160 : 3170 REMark Spaces at end of 'used' line for shorter overwrite 3180 PRINT " " 3190 : 3200 PRINT " Sats in view: "; 3210 : 3220 REMark Extract data from $GPGSV lines 3230 v$= satlist$(1) 3240 v$= chop$(v$, 2) 3250 FOR i= 1 TO novsats% 3260 v$= chop$(v$, 2) 3270 id$= field$( v$ ): REMark Satellite Identifier 3280 IF LEN(id$) =0 THEN NEXT orbits 3290 id%= id$ 3300 IF id%<10 THEN PRINT "0"; 3310 PRINT id%!; 3320 v$= chop$ ( v$, 1 ): REMark Satellite elevation 3330 el$= field$( v$ ) 3340 IF LEN(el$) =0 THEN NEXT orbits 3350 el%= el$ 3360 v$= chop$ ( v$, 1 ): REMark Satellite azimuth 3370 az$= field$( v$ ) 3380 IF LEN(el$) =0 THEN NEXT orbits 3390 IF NumChk(az$)<>0 THEN NEXT orbits 3400 az%= az$ 3410 j= 0: tint%= seentint% 3420 REPeat chkid 3430 IF satsusd(j)= -1 THEN EXIT chkid 3440 IF satsusd(j)= id% THEN 3450 tint%= usdtint% 3460 END IF 3470 j= j+1 3480 END REPeat chkid 3490 : 3500 IF ShowTrack% =0 THEN 3510 REMark At last can plot satellite in position 3520 REMark Plot omly valid data 3530 IF Inv%=0 THEN : spot el%, az%, id%, tint% 3540 END IF 3550 REMark Change data line after 4 sats 3560 IF (i MOD 4)= 0 THEN v$= chop$(satlist$(2),2) 3570 END FOR i 3580 : 3590 REMark Spaces at end of 'ids' line for shorter overwrite 3600 PRINT " " 3610 : 3620 REMark Print validity 3630 PRINT \" "; 3640 IF Inv%=1: PRINT "Inv";: ELSE PRINT "V"; 3650 PRINT "alid Position " 3660 REMark Spaces to overwrite longer 'Invalid' message 3670 : 3680 REMark Extract Lat and Long 3690 REMark Chopped gpsrmc$ also used by Track code 3700 REMark so use a variable to synchronise 3710 rmchop%= 3 3720 gpsrmc$= chop$(gpsrmc$, rmchop%) 3730 CSIZE 3,1 3740 AT 3,0 3750 REMark Latitude 3760 PRINT " ";gpsrmc$( 1 TO 2); CHR$(186); 3770 PRINT " ";gpsrmc$(3 TO 10);"'"!gpsrmc$(12); 3780 LatDeg$= gpsrmc$( 1 TO 2) 3790 LatMin$= gpsrmc$(3 TO 10) 3800 Lat= DecDeg(LatDeg$,LatMin$) 3810 IF gpsrmc$(12) =="S" THEN Lat= -Lat 3820 REMark Validity 3830 PRINT " "; Validity$ 3840 REMark Longitude 3850 PRINT " ";gpsrmc$(14 TO 16); CHR$(186); 3860 PRINT " ";gpsrmc$(17 TO 24);"'"! gpsrmc$(26) 3870 LonDeg$= gpsrmc$(14 TO 16) 3880 LonMin$= gpsrmc$(17 TO 24) 3890 Lon= DecDeg(LonDeg$,LonMin$) 3900 IF gpsrmc$(26)== "W" THEN Lon= -Lon 3910 : 3920 REMark Display UTC, extracted way back 3930 AT 6,2 3940 PRINT UTC$; 3950 : 3960 REMark Extract Track data, 3970 REMark gprsmc$ already chopped for Lat, Long 3980 AT 8,2 3990 trak$= gpsrmc$: trak$= chop$(trak$, 7-rmchop%) 4000 speed$= trak$(1 TO 5) 4010 IF NumChk(speed$)<>0 THEN CSIZE 0,0: NEXT orbits 4020 Speed= speed$* 1.150779: REMark Convert Knots to m.p.h. 4030 PRINT "Track"!trak$(7 TO 11);CHR$(186): REMark Bearing 4040 PRINT_USING " at ##.# m.p.h", Speed 4050 Brg= trak$(7 TO 11) 4060 : 4070 CSIZE 0,0 4080 : 4090 IF ShowTrack% THEN 4100 REMark Show track as a line: colour shows speed 4110 INK #dc%,Spink%(Speed) 4120 IF FirstPt%==0 THEN 4130 POINT #dc%, Lon*asprat*Mctr, Lat 4140 FirstPt%= 1 4150 ELSE 4160 LINE #dc% TO Lon*asprat*Mctr, Lat 4170 END IF 4180 : 4190 REMark Show Speed and bearing as a line, .. 4200 REMark .. length and colour for speed, .. 4210 REMark .. bearing as direction of line. 4220 CLS #dt%: INK #dt%,Spink%(Speed) 4230 POINT #dt%,0,0 4240 PENDOWN #dt% 4250 TURNTO #dt%,90-Brg: MOVE #dt%,Speed 4260 PENUP #dt% 4270 END IF 4280 : 4290 REMark Pause to slow down rate of refreshment of display 4300 PAUSE 50*delay 4310 : 4320 REMark End of repeat loop for continous display 4330 END REPeat orbits 4340 CLOSE #cs%: IF dtof <>0 THEN CLOSE #dc% 4350 STOP 4360 : 4370 REMark End of Main Program ================================= 4380 : 4390 DEFine PROCedure radials 4400 REMark Draws the celestial meridians at 30 deg intervals 4410 REMark as a series of dots to avoid too dark a line 4420 LOCal i,j,interval 4430 interval = 2E-2 4440 FOR i = 0 TO 350 STEP 10 4450 FOR j= 2 TO 100 4460 REMark uses j*interval as a radial distance .. 4470 REMark .. which must be converted to x,y for plot 4480 IF j*interval > 1 THEN EXIT j 4490 POINT#dc%,j*interval*COS(i*PI/180) *asprat,j*interval*SIN(i*PI/180) 4500 END FOR j 4510 END FOR i 4520 END DEFine 4530 : 4540 DEFine PROCedure spot(elvn,azm,id,tint) 4550 REMark Draw a blob in tint at elvn,azm and show id 4560 REMark For a polar plot need to convert to x,y coords 4570 REMark Code for line plot added later 4580 LOCal x,y,srad 4590 REMark ignore data if id outside possible range .. 4600 REMark .. it has happened, usually during start up of RX 4610 IF id > maxid THEN RETurn 4620 srad= (90-elvn)/90: REMark zero to one on plot 4630 x= srad*SIN(azm*PI/180)*asprat 4640 y= srad*COS(azm*PI/180) 4650 REMark Copy previous posn as 'old' 4660 posns(id,0)= posns(id,2) 4670 posns(id,1)= posns(id,3) 4680 REMark Save new posn for 'old' next time 4690 posns(id,2)= x 4700 posns(id,3)= y 4710 INK #dc%,tint: STRIP #dc%,tint 4720 REMark Draw sat as blob if first time plotted ... 4730 IF posns(id,4)< 1 OR Blobs% =1 THEN 4740 posns(id,4)= 1: REMark Remember as blobbed 4750 REMark draw a blob 4760 FILL#dc%,1 4770 ELLIPSE#dc%,x,y,6E-2,asprat,0 4780 FILL#dc%,0 4790 REMark Show sat id in contrasing ink 4800 IF tint= seentint% THEN INK #dc%,0: ELSE INK #dc%,7 4810 CURSOR#dc%,x,y,-6,-5 4820 IF id<10 THEN PRINT#dc%,0;: REMark Add leading zero? 4830 PRINT#dc%,id: REMark At last, print sat id 4840 ELSE 4850 REMark ... otherwise draw a line 4860 INK #dc%,tint: LINE #dc%,posns(id,0),posns(id,1) TO posns(id,2),posns(id,3): INK #dc%,0 4870 END IF 4880 END DEFine 4890 : 4900 DEFine FuNction gpsdata$( id$ ) 4910 REMark Waits for and reads a sentence of data starting 4920 REMark with the string id$ (not sat id this time) 4930 REMark Give up if there's no data to serial port 4940 FOR i= 1 TO 50 4950 IF EOF(#cs%) THEN 4960 AT 20,3: PRINT "Lines: ";lines!; 4970 PRINT " Good lines: ";GoodLines 4980 INPUT " Press to finish: ";t$ 4990 CLS: CLS#0: CLS#2: CLOSE: STOP 5000 END IF 5010 INPUT #cs%,t$ 5020 REMark More checks for dodgy data 5030 IF LEN(t$) = 0 THEN NEXT i 5040 IF t$(1) <> "$" THEN NEXT i 5050 IF t$(1 TO 6) = id$ THEN RETurn t$: 5060 END FOR 5070 IF i > 10 THEN PRINT " No GPS data": STOP 5080 END DEFine 5090 : 5100 DEFine FuNction field$(str$) 5110 REMark Extracts the first field from the NMEA message data 5120 REMark after it has been chopped to the start of the 5130 REMark field, with comma separated fields, so making 5140 REMark no assumption about the field length. 5150 LOCal k% 5160 REMark last field terminated by * at start of checksum 5170 REMark so need to check for ',' -- if none then '*' 5180 k%= "," INSTR str$ 5190 IF k% =0 THEN k%= "*" INSTR str$ 5200 RETurn str$ ( TO (k%-1)) 5210 REMark NOTE errors such as empy string must be 5220 REMark dealt with on return from call 5230 END DEFine 5240 : 5250 DEFine FuNction NumChk(a$) 5260 REMark Check if a$ contains a decimal number, fixed point 5270 REMark Return: 0= ok; 1= empty; 2= >1 d.ps; 3= non- numeric 5280 LOCal i%,a%,NoDecPts%: NoDecPts%= 0 5290 REMark NoDecPts% holds the nunber of dec pts found 5300 IF LEN(a$) = 0 THEN RETurn 1 5310 FOR i% = 1 TO LEN(a$) 5320 a%= CODE (a$(i%)) 5330 REMark 48 and 57 are codes for '0' and '9' 5340 REMark .. I just like < more than <= 5350 IF a% > 47 AND a < 58 THEN 5360 NEXT i% 5370 ELSE 5380 REMark Check for dec pt 5390 IF a%=46 THEN 5400 NoDecPts%= NoDecPts%+1: REMark Allow one dec. pt. 5410 IF NoDecPts%> 1 THEN RETurn 2: ELSE NEXT i% 5420 END IF 5430 RETurn 3 5440 END IF 5450 END FOR i% 5460 RETurn 0 5470 END DEFine 5480 : 5490 DEFine FuNction chop$(str$, skip) 5500 REMark Chops off skip fields from the start of str$ 5510 REMark Haven't had to chop as far as the '*' yet 5520 LOCal i,j 5530 IF ( skip < 1 ) THEN RETurn str$ 5540 FOR i= 1 TO skip 5550 j= "," INSTR str$ 5560 str$ = str$ ( j+1 TO ) 5570 END FOR 5580 RETurn str$ 5590 END DEFine 5600 : 5610 DEFine PROCedure DisLine(c%,t$,l%) 5620 REMark Diplays line padded to l% chars with spaces .. 5630 REMark .. in channel #c%, the spaces are needed 5640 REMark when short lines follow long 5650 REMark Had no success with CLS so far 5660 PRINT #c%;t$; 5670 tl%= LEN(t$) 5680 IF tl%< l% THEN 5690 PRINT #c%;FILL$(" ",l%-tl%) 5700 ELSE PRINT #c% 5710 END IF 5720 END DEFine 5730 : 5740 DEFine FuNction GPSTime$(t$) 5750 REMark Extracts time from t$ -- copy of RMC input 5760 REMark Should have used chop$ etc, but by this time the 5770 REMark data format seemed stable enough and CBB took over. 5780 t$= chop$(t$,1): REMark Remove '$GPRMC' 5790 RETurn '@ '&t$(1 TO 2)&':'&t$(3 TO 4)&':'&t$(5 TO 6)&' UTC' 5800 END DEFine GPSTime$ 5810 : 5820 DEFine FuNction CheckSum(a$) 5830 LOCal i,aa$,ChkSum,ChkCode$ 5840 IF LEN(a$)=0 THEN RETurn -2 5850 FOR i= 1 TO 256: REMark Allow for sentence .. 5860 REMark .. not terminated properly, i.e. no '*' 5870 aa$= a$(i) 5880 SELect ON CODE(aa$) 5890 REMark set ChkSum to zeros at start of sentence 5900 = CODE('$'): ChkSum= 0 5910 = CODE('*'): 5920 ChkCode$= a$((i+1) TO (i+2)) 5930 EXIT i 5940 = REMAINDER : 5950 REMark ^^ is 'bit-wise exclusive OR' Jan Jones p 40 5960 ChkSum= CODE(aa$) ^^ ChkSum 5970 END SELect 5980 END FOR i 5990 REMark Checksum in data is two hex chars (8 bits) 6000 IF HEX$(ChkSum,8) = ChkCode$ THEN 6010 RETurn 0: REMark Good result 6020 ELSE 6030 REMark Bad result 6040 PRINT #de%,a$;" ChkSum: ";HEX$(ChkSum,8);" Check code: ";ChkCode$ 6050 RETurn -1 6060 END IF 6070 END DEFine 6080 : 6090 REMark Follow a series of definitons of charts for tracks 6100 REMark Maxlon necessary for lat, lon grid 6110 DEFine PROCedure ChiCityMap 6120 Minlat= 50+49/60 6130 Maxlat= 50+51/60 6140 Minlon= -47/60 6150 Maxlon= -43/60 6160 END DEFine 6170 : 6180 DEFine PROCedure PfdMap 6190 Minlat= 50.7667 6200 Maxlat= 51.05 6210 Minlon= -1-3/60 6220 Maxlon= -.6 6230 END DEFine 6240 : 6250 DEFine FuNction DecDeg(D$,M$) 6260 IF LEN(D$)==0 OR LEN(M$)==0 THEN RETurn 361 6270 IF ',' INSTR(D$&M$) THEN RETurn 362 6280 RETurn D$+(M$/60) 6290 END DEFine 6300 : 6310 DEFine FuNction Spink%(S) 6320 REMark Returns a colour according to the Speed S 6330 SELect ON S 6340 ON S=0 TO 9.999: RETurn 0 : REMark Black 6350 ON S=10 TO 19.999: RETurn 59 : REMark Brown 6360 ON S=20 TO 29.999: RETurn 2 : REMark Red 6370 ON S=30 TO 39.999: RETurn 236 : REMark Yellow 6380 ON S=40 TO 49.999: RETurn 22 : REMark Orange 6390 ON S=50 TO 59.999: RETurn 3 : REMark Green 6400 ON S=60 TO 69.999: RETurn 25 : REMark Blue 6410 ON S=70 TO 79.999: RETurn 26 : REMark Violet 6420 REMark Shocking pink for over 80m.p.h. 6430 ON S= REMAINDER : RETurn 112 6440 END SELect 6450 END DEFine 6460 : 6470 DEFine PROCedure LatLonGrid 6480 REMark For track, prints a grid of lats and longs .. 6490 REMark .. each at one minute of arc intervals 6500 REMark parameters set in main program 6510 REMark No need for precise match to window as SB 6520 REMark just doesn't draw outside it 6530 LOCal Glat, Glon, Gld, Glm 6540 INK #dc%,13: REMark nice pale grey 6550 : 6560 REMark Start with latitudes 6570 Gl= Minlat 6580 REMark Need to convert to decimal degrees 6590 Gl= INT(Gl)+(INT((Gl-INT(Gl))*60))/60 6600 Gminl= Minlon*asprat*Mctr: Gmaxl= Maxlon*asprat*Mctr 6610 REPeat LatLines 6620 IF Minlat<=Gl AND Maxlat > Gl THEN 6630 LINE #dc%, Gminl,Gl TO Gmaxl,Gl 6640 END IF 6650 Gl= Gl+1/60 6660 IF Gl> Maxlat THEN EXIT LatLines 6670 END REPeat 6680 : 6690 REMark next meridians 6700 Gl= Minlon 6710 Gl= INT(Gl)+(INT((Gl-INT(Gl))*60))/60 6720 Gminl= Minlon: Gmaxl= Maxlon 6730 REPeat LonLines 6740 IF Minlon <= Gl AND Maxlon > Gl THEN 6750 Gp= Gl*asprat*Mctr 6760 LINE #dc%, Gp,Minlat TO Gp,Maxlat 6770 END IF 6780 Gl= Gl+1/60 6790 IF Gl> Maxlon THEN EXIT LonLines 6800 END REPeat 6810 END DEFine 6820 : 6830 REMark My programs always have this procedure at the end 6840 DEFine PROCedure backup 6850 SAVE dos1_GPSTalk_QLMags_Figure11.txt 6860 END DEFine