'GPS6.BAS ' decodage trame GPS LAIPAC 'revison 19/9/2003,22/9/2003 8/10/2003,28/10/2003,4/11/2003,5/11/2003,6/11/2003 '16/11/2003, 26/11/2003 , 28/11/2003, 29/11/2003, 1/12/2003, 6/12/2003, 9/12/2003 '14/12/2003 '28/1/2004 ajout altitude const pin_gps=13 ' pin recuperant sortie NMEAdu GPS const bouton_choix =14 '8 ' 14 ' bouton choix affichage const bouton_cible= 11 '9 '11 ' bouton entree coordonnee cible const dig_sui=9 ' bouton commande digit suivant const val_sui=8 ' bouton commande chiffre suivant const valid=10 'bouton validation entree const pin_eclair=15 ' port eclairage lcd const bouton_eclair=12 '8 '12 ' bouton commande eclairage 'affectation des bornes 'si on change il faut changer routine put_cmd ' I/O 0 LCD.11 | ' I/O 1 LCD.12 |-- data 4 bit ' I/O 2 LCD.13 | ' I/O 3 LCD.14 | ' I/O 4 LCD.4 RS du lcd ' 9 ' I/O 18 LCD.6 Enable du lcd ' 10 CONST RS=4 CONST E=18 '----------- LCD control characters ' CONST clrlcd=&h01 CONST CrsrLf= &h10 ' move cursor left const CrsrRt = &h14 ' move cursor right const DispLf = &h18 ' shift displayed chars left const DispRt = &h1C ' shift displayed chars right const DispLf = &h18 ' shift displayed chars left const DispRt = &h1C ' shift displayed chars right const UpLin = &h80 ' got upper line const LowLin = &hC0 ' goto lower line CONST home1 = &h02 ' move cursor to home position ligne1 CONST home2 = &hC0 'move cursor to home position ligne2 CONST home3 = 148 ' move cursor to home position line3 CONST home4 = 212 ' move cursor to home position line 4 const yes=0 ' si bouton active etat passe de 1 à 0 const no=1 dim j as byte ' variable à tout faire byte dim jj1 as integer ' variable integer à tout faire dim jj2 as integer ' variable integer à tout faire 'variables/constante pour entree donnee dim ligne_ecri as byte ,col_ecri as byte dim val as byte dim x1 as byte, x2 as byte 'entree 2 digit dim entree_valid as byte '----- variables necessaires-------------------------------- dim char as byte , char1 as byte dim val1 as byte ,pin as byte ' variable pour nibble_out facon alas dim lat_deg as byte dim lat_mn as byte dim lat_mn_deci as byte dim lon_deg as byte dim lon_mn as byte dim lon_mn_deci as byte dim lat_deg_c as byte dim lat_mn_c as byte dim lat_mn_deci_c as byte dim lon_deg_c as byte dim lon_mn_c as byte dim lon_mn_deci_c as byte dim cap as integer 'dim distance as integer ' differnece lat/long entre position et cible dim d_lat as integer dim d_lon as integer dim signe_dlat as byte dim signe_dlon as byte dim unit_lat as byte ' 1 : unite metre , 0 : unite km dim unit_lon as byte ' 1 : unite metre , 0 : unite km dim signe_lon as byte ' si longitude E signe_lon=1 autrement signe_lon=0 (NB compilateur ne connait pas nombre negatif dim signe_lon_c as byte ' idem pour longitude de la cible dim i(38) as byte ' buffer recevant les donnee chaine NMEA du module GPS dim k_bouton as byte '********************************************************************************* '[ ] 'set picbus high 'lcdinit gosub lit_cible '--------- Initialize the LCD (Hitatchi HD44780 controller) ' delay 1000 'laisse lcd temps de stabiliser byteout 0,&h00 out rs,0 out E,0 Init_LCD: out rs,0 : out E,0 : BYTEOUT 0,&h03 gosub pulse_en : gosub pulse_en : gosub pulse_en BYTEOUT 0,&h02 ' 4-bit mode gosub pulse_en 'ci dessous commade ex picpro char=&h28 :gosub put_cmd char=&h08 :gosub put_cmd char=&h01:gosub put_cmd char=&h06:gosub put_cmd char=&b00001111: gosub put_cmd ' display on ,cursor on blinking on ' char=&h0C:gosub put_cmd char=&h80:gosub put_cmd '--------------- fin initalisation lcd ------------------------------------- 'debug: char=home1:gosub put_cmd 'for x1=0 to 7 : char=table(x1,'G','P','S','-','A','L','A','S') : gosub wr_lcd : next x1 delay 5000 'goto debug out pin_eclair,0 ' n'eclaire pas au demarrage k_bouton=0 debut: 'serin pin_gps,207,0,2000,timeout,[WAIT("MC"),i(0)~30] 'if i(8)=86 then '86= V info non valide 'locate 0,0 'print "triangulation en cours" ' goto debut 'end if if keyin(bouton_choix,25)=0 then char=clrlcd:gosub put_cmd k_bouton=k_bouton+1 if k_bouton>4 then k_bouton=0 delay 100 end if if keyin(bouton_eclair,25)=0 then toggle pin_eclair if keyin(bouton_cible,25)=0 then gosub entre_cible if k_bouton=0 then gosub visu_lat_lon if k_bouton=1 then gosub cible_cap if k_bouton=2 then gosub affiche_cible if k_bouton=3 then gosub cap_alt if k_bouton=4 then gosub info_gps_heure goto debut: '----------------------------------------------------- '--------------------------------------------------------- info_gps_heure: 'cls :locate 0,0:print" info etat GPS" 'delay 200 'affiche sat en vue gosub traite_gpgga ' 'traite_gpgga: 'serin pin_gps,207,0,2000,timeout,[WAIT("GG"),i(0)~38] ' curieusement marche pas pour GPGGA si on attend GA 'serin pin_gps,207,0,2000,timeout,[i(0)~9] 'for x1=0 to 4:char=table(x1,'_','H','d','o','p'):gosub wr_lcd : next x1 'for x1=0 to 4 :char=i(x1):gosub wr_lcd : next x1 ' traite GPZDA pour recup heure serin pin_gps,207,0,2000,timeout,[WAIT("DA"),i(0)~38] 'cls:locate 0,0 'print "Heure =" 'for j=1 to 2 '7 :'print i(j) 'next j 'print "H " 'for j=3 to 4 '7 'print i(j) 'next j 'print "mn " 'for j=5 to 6 '7 'print i(j) 'next j 'print "sec" '--- 'char=clrlcd:gosub put_cmd char=home2:gosub put_cmd for x1=1 to 2 : char=i(x1) : gosub wr_lcd : next x1 char="H": gosub wr_lcd:char=32:gosub wr_lcd for x1=3 to 4 : char=i(x1) : gosub wr_lcd : next x1 char='m':gosub wr_lcd:char='n':gosub wr_lcd:char=32:gosub wr_lcd for x1=5 to 6 : char=i(x1) : gosub wr_lcd : next x1 char='s':gosub wr_lcd return '-------------------------------------------------- cap_alt: char=home1:gosub put_cmd gosub info_cap 'recupere cap et vitesse et ecrit le cap 'traite_gpgga: serin pin_gps,207,0,2000,timeout,[WAIT("GG"),i(0)~38] ' curieusement marche pas pour GPGGA si on attend GA serin pin_gps,207,0,2000,timeout,[i(0)~9] char=home2 :gosub put_cmd for x1=0 to 4:char=table(x1,'A','l','t','i',':'):gosub wr_lcd : next x1 for x1=6 to 9 :char=i(x1):gosub wr_lcd : next x1 char=32:gosub wr_lcd :char="m":gosub wr_lcd 'delay 2000 return '------------- info_cap: serin pin_gps,207,0,2000,timeout,[WAIT("TG"),i(0)~38] 'cls:locate 0,0 'print "cap =" 'for j=1 to 3 'print i(j) 'next j 'recupere cap en decimal pour affichage format NW.... jj1=(i(1)-48)*100 jj2=(i(2)-48)*10 jj1=jj1+jj2 jj1=jj1+(i(3)-48) 'print dec (jj1) 'if jj1>338 or jj1<22 then print "N" 'if jj1>21 and jj1<67 then print "NE" 'if jj1>66 and jj1<113 then print "E" 'if jj1>112 and jj1<157 then print "SE" 'if jj1>156 and jj1<203 then print "S" 'if jj1>202 and jj1<247 then print "SW" 'if jj1>246 and jj1<293 then print "W" 'if jj1>292 and jj1<338 then print "NW" 'locate 0,1 'print "vitesse " 'for j=20 to 24 'print i(j) 'next j 'char=clrlcd:gosub put_cmd for x1=0 to 3 : char=table(x1,'C','a','p',':') : gosub wr_lcd : next x1 for x1=1 to 3 :char=i(x1):gosub wr_lcd:next x1 char=32 :gosub wr_lcd if jj1>338 or jj1<22 then char= 'N':gosub wr_lcd :gosub clr_eol if jj1>21 and jj1<67 then char='N':gosub wr_lcd :char='E':gosub wr_lcd if jj1>66 and jj1<113 then char='E' :gosub wr_lcd :gosub clr_eol if jj1>112 and jj1<157 then char='S':gosub wr_lcd :char='E':gosub wr_lcd if jj1>156 and jj1<203 then char='S':gosub wr_lcd:gosub clr_eol if jj1>202 and jj1<247 then char='S':gosub wr_lcd :char='W':gosub wr_lcd if jj1>246 and jj1<293 then char='W':gosub wr_lcd:gosub clr_eol if jj1>292 and jj1<338 then char='N':gosub wr_lcd :char='W':gosub wr_lcd return '------------------------------------------- clr_eol: char=32:gosub wr_lcd:char=32:gosub wr_lcd return '----------------------------------------------- '--------------------------------------------- '---------------------------- affiche_cible: 'cls:locate 0,0:print " affiche cible" 'delay 200 gosub traite_gprmc gosub affiche_position_cible return '----------------------------------------------------- visu_lat_lon: 'cls:locate 0,0:print "visu lat/lon " 'delay 200 gosub traite_gprmc 'affiche position latitude puis longitude 'cls:locate 0,0 'for j=10 to 11 ' 20 'print i(j) 'next j 'print "'" 'for j=12 to 20 'print i(j) 'next j 'locate 0,1 'for j=22 to 24 '33 'print i(j) 'next j 'print "'" 'for j=25 to 33 'print i(j) 'next j ' char=home1:gosub put_cmd for x1=10 to 11 :char=i(x1):gosub wr_lcd : next x1 :char=''':gosub wr_lcd for x1=12 to 20:char=i(x1):gosub wr_lcd:next x1 char=home2:gosub put_cmd for x1=22 to 24 :char=i(x1):gosub wr_lcd:next x1:char=''':gosub wr_lcd for x1=25 to 33 :char=i(x1):gosub wr_lcd:next x1: delay 500 return '---------------------------------------------------- traite_gpgga: serin pin_gps,207,0,2000,timeout,[WAIT("GG"),i(0)~38] ' curieusement marche pas pour GPGGA si on attend GA 'cls 'locate 0,0 'print "nombre satel." 'for j=36 to 37 'print i(j) 'next j 'cas pour afficher parallele char=home1 :gosub put_cmd for x1=0 to 3:char=table(x1,'S','a','t',':'):gosub wr_lcd : next x1 for x1=36 to 37 :char=i(x1):gosub wr_lcd:next x1 'delay 500 return '---------------------------------------------------------- traite_gprmc: '************** traite la chaine NMEA $GPRMC ****************************** ' recupere long et latitude courante 'calcul distance par rapport à la cible à atteindre serin pin_gps,207,0,2000,timeout,[WAIT("MC"),i(0)~38] ' sort info 'locate 0,0 'cls 'sort la ligne recue sur 1 ligne 'for j=0 to 39 'print i(j) 'next j if i(8)=86 then '86= V info non valide 'locate 0,0 'print "triang. en cours" char=clrlcd:gosub put_cmd char=home1 :gosub put_cmd for x1=0 to 7:char=table(x1,'N','o','_','s','a','t','e','l'):gosub wr_lcd : next x1 delay 500 'goto debut ' a remettre quand tout sera operationnel end if 'extrait info lat 'locate 0,1: 'for j=10 to 11 'print i(j) 'next j 'print" Deg" lat_deg=(i(10)-48)*10 lat_deg=lat_deg+ (i(11)-48) 'print dec( lat_deg,2)," deg" ' affiche position en deg 'for j=12 to 13 'print i(j) 'next j 'print" mn " lat_mn=(i(12)-48)*10 lat_mn=lat_mn+ (i(13)-48) 'print dec( lat_mn,2) ' affiche position en minute 'print " ." 'for j=15 to 16 'print i(j) 'next j 'print" mn_dec " lat_mn_deci=(i(15)-48)*10 lat_mn_deci=lat_mn_deci+ (i(16)-48) 'print dec( lat_mn_deci,2) 'affiche position en minute decimale 'print " " 'print "LON " 'extrait info longitude 'for j=22 to 24 'print i(j) 'next j 'goto debut 'print" LON" '*********ATTENTION ne marche qua pour longitude execdant pas 255 deg pas genant on reste en europe ' sinon il faudrait prendre variable integer pour degree lon_deg=(i(22)-48)*100 j=i(23)-48 ' pour rendre moins complexe pour compilateur lon_deg=lon_deg+j*10 lon_deg=lon_deg+ (i(24)-48) 'print dec( lon_deg,2)," deg" ' affiche position en degre 'for j=25 to 26 'print i(j) 'next j 'print" mn " lon_mn=(i(25)-48)*10 lon_mn=lon_mn+ (i(26)-48) 'print dec( lon_mn,2) ' affiche position en minute 'print " ." 'goto debut 'for j=28 to 29 'print i(j) 'next j 'print" mn_dec " 'goto debut lon_mn_deci=(i(28)-48)*10 lon_mn_deci=lon_mn_deci+ (i(29)-48) 'print dec( lon_mn_deci,2) 'affiche position en minute decimale 'print " " 'recupere longitude east ou west 'print"sign" 'print i(33) ' vaut E or W if i(33)=87 then signe_lon=0 else signe_lon=1 end if ' print dec (signe_lon) ' recupere info CAP 'print "cap=" 'for j=35 to 37 'print i(j) 'next j cap=100*(i(35)-48) cap=cap+ 10*(i(36)-48) cap=cap+ (i(37)-48) 'print dec(cap) 'goto debut test_calcul: '*********************calcule distance entre cible et position actuelle******************************** ' NB calcul approche compte tenu du compilateur : distance=latitude + longitude ' on reste dans hemisphere nord (lat >0) ' protocole complique car compilateur connait pas nombre negatif si on veut conserver 0-65536 pour integer 'base 1 deg latitude= 111 km , 1 min= 1.85 km ' base 1 mn longitude=1850+lat *(520/45) avec lat en degre , resultat en metre pour lat env 45° ' I mn de longitude=1330 metre , 1 deg = 79.8 km ' -------------calcul difference en latitude par rapport à cible ---------- 'calcul lat en minute 'lat_deg=45 'lat_mn=45 'lat_mn_deci=25 'ci dessous pour debuggage 'lat_deg_c=46 'lat_mn_c=13 'lat_mn_deci_c=58 jj1=lat_deg*60 + lat_mn jj2=lat_deg_c*60 +lat_mn_c if jj1> jj2 then d_lat=jj1-jj2 signe_dlat=0 else d_lat=jj2-jj1 signe_dlat=1 end if d_lat=d_lat*18/10 ' d_lat en km unit_lat=0 'unite 1000 m soit 1 km if d_lat<15 and lat_deg_c=lat_deg then ' cas ou on est moins de 15 km de la cible ' on calcule en 1/100 mn soit resolution de 18 m ' a condition que coordonnees en degre soit different pour eviter syndrome du 45°59 vs 46°01 jj1= lat_mn*100+ lat_mn_deci jj2=lat_mn_c*100 +lat_mn_deci_c if jj1> jj2 then d_lat=jj1-jj2 signe_dlat=0 else d_lat=jj2-jj1 signe_dlat=1 end if d_lat=d_lat*18 ' 1/100mn= 18 metre unit_lat=1 'unite dist latitude = 1 metre end if ' affichage position cible centralise en dessous avec dlon 'print "dlat=",dec (d_lat) 'if unit_lat=1 then print " m " 'if unit_lat=0 then print " km " '---------- calcul ecart en longitude attention au meridien de greenwich tres present en france 'ci dessous pour debuggage 'lon_deg_c=0 'lon_mn_c=8 'lon_mn_deci_c=45 'signe_lon_c=0 'si 1 longitude EST , 0 si longitude W jj1=lon_deg*60 + lon_mn jj2=lon_deg_c*60 +lon_mn_c gosub calc_dlon_signe d_lon=d_lon*133/100 ' d_lat en km unit_lon=0 'unite 1 km if d_lon<15 and lon_deg_c=lon_deg then ' cas ou on est moins de 15 km de la cible ' on calcule en 1/100 mn soit resolution de 13 m base 45 deg latitude ' a condition que coordonnees en degre soit memes pour eviter syndrome du 0°59 vs 1°01 jj1= lon_mn*100+ lon_mn_deci jj2=lon_mn_c*100 +lon_mn_deci_c gosub calc_dlon_signe d_lon=d_lon*13 ' 1/100mn= 13 metre unit_lon=1 'unite dist latitude = 1 metre end if 'print "dlon=",dec (d_lon) 'if unit_lon=1 then print " m" 'if unit_lon=0 then print " km" return ' ' calcul de d_lon et signe de dlon suivant differents cas E ou W ou a cheval calc_dlon_signe: if signe_lon=signe_lon_c then if jj1> jj2 then d_lon=jj1-jj2 if signe_lon=0 then ' les 2 sont en long West signe_dlon=1 else ' les 2 sont en longitude East signe_dlon=0 end if else d_lon=jj2-jj1 if signe_lon=0 then ' les 2 sont en long West signe_dlon=0 else ' les 2 sont en long East signe_dlon=1 end if end if else ' cas à cheval if jj1> jj2 then d_lon=jj1+jj2 signe_dlon=0 else d_lon=jj2+jj1 signe_dlon= 1 end if end if return '------------------------------------------------ affiche_position_cible: '---affichage complet position cible version lccd serie----- 'cls 'locate 0,0 'print "Cible", dec (d_lat) 'if unit_lat=1 then print " m " 'if unit_lat=0 then print " km" 'if signe_dlat=1 then print "/N" 'if signe_dlat=0 then print "/S" 'locate 0,1 'print dec (d_lon) 'if unit_lon=1 then print " m " 'if unit_lon=0 then print " km" 'if signe_dlon=1 then print"/E" 'if signe_dlon=0 then print "/W" ' '------------------------------------------------------- 'idem pour lcd parallele char=home1:gosub put_cmd for x1=0 to 4 : char=table(x1,'D','e','s','t','i') : gosub wr_lcd : next x1 char=32:gosub wr_lcd jj1=d_lat:gosub sort_nombre if unit_lat=1 then char=32:gosub wr_lcd:char='m':gosub wr_lcd:char=32:gosub wr_lcd if unit_lat=0 then char=32:gosub wr_lcd:char='k':gosub wr_lcd:char='m':gosub wr_lcd ':char=32:gosub wr_lcd if signe_dlat=1 then char='/':gosub wr_lcd:char='N':gosub wr_lcd if signe_dlat=0 then char='/':gosub wr_lcd:char='S':gosub wr_lcd char=home2 :gosub put_cmd jj1=d_lon:gosub sort_nombre if unit_lon=1 then char=32:gosub wr_lcd:char='m':gosub wr_lcd:char=32:gosub wr_lcd if unit_lon=0 then char=32:gosub wr_lcd:char='k':gosub wr_lcd:char='m':gosub wr_lcd:char=32:gosub wr_lcd if signe_dlon=1 then char='/':gosub wr_lcd:char='E':gosub wr_lcd if signe_dlon=0 then char='/':gosub wr_lcd:char='W':gosub wr_lcd gosub clr_eol return '***************************************************** cible_cap: 'on doit auparavant appeler traite_gprmc:pour avoir d_lat,d_lon.... gosub traite_gprmc char=home1:gosub put_cmd for x1=0 to 1 : char=table(x1,'C',':') : gosub wr_lcd : next x1 char=32:gosub wr_lcd ' converti tout en hectometre if unit_lat=1 then d_lat=d_lat/100 else d_lat=d_lat*10 end if if unit_lon=1 then d_lon=d_lon/100 else d_lon=d_lon*10 end if jj1=d_lat+d_lon ' 'print "cible",dec (jj1)," " gosub sort_nombre ' sort jj1 déja calculé char=32:gosub wr_lcd:char='h':gosub wr_lcd :char='m':gosub wr_lcd:char='/':gosub wr_lcd jj1=4*d_lon/10 :jj2=24*d_lon/10 if d_lat> jj1 and d_lat=jj2 then if signe_dlat=1 then char='N':gosub wr_lcd:char=32:gosub wr_lcd if signe_dlat=0 then char='S':gosub wr_lcd:char=32:gosub wr_lcd end if '----- if d_lat<=jj1 then if signe_dlon=1 then char='E':gosub wr_lcd:char=32:gosub wr_lcd if signe_dlon=0 then char='W':gosub wr_lcd:char=32:gosub wr_lcd end if gosub clr_eol '----- char=home2:gosub put_cmd gosub info_cap return '************************************************* timeout: 'cls 'locate 0,0 'print " rien recu" 'delay 500 char=home1:gosub put_cmd for x1=0 to 5 : char=table(x1,'N','o','_','G','P','S') : gosub wr_lcd : next x1 gosub clr_eol delay 500 goto debut '************************************************ '------------------------------------------------------------ ' ci dessous routine entree coordonnees de la cible '----------------------------------------------------------- '--- entree coordonnees de la cible sur 1 et 2 ieme ligne : ' d'abord latitude puis longitude format DD°MM.mm 'degre , minute.minute decimale entre_cible: char=clrlcd:gosub put_cmd debut1: char=clrlcd:gosub put_cmd 'char='L':gosub wr_lcd:char='A':gosub wr_lcd:char='T':gosub wr_lcd 'char='_':gosub wr_lcd:char='c':gosub wr_lcd:char='i':gosub wr_lcd for x1=0 to 5 :char=table(x1,'L','a','t','_','c','i'):gosub wr_lcd : next x1 ligne_ecri=1 :col_ecri=8 gosub posi_cursor ' positionne curseur à ligne_ecri col_ecrit entree_valid=0 gosub entre_lat if entree_valid=0 then goto debut1 '---entree info longitude d'abord + si East - si West debut2: char=home2 :gosub put_cmd 'for x1=0 to 15:char=32:gosub wr_lcd:next x1 ' nettoie la ligne entree_valid=0 char=home2 :gosub put_cmd for x1=0 to 5 :char=table(x1,'L','o','n','_','c','i'):gosub wr_lcd : next x1 char=43:gosub wr_lcd ' ecrit + debut3: ligne_ecri=2 :col_ecri=7 gosub posi_cursor ' positionne curseur à ligne_ecri col_ecrit debut3_1: if keyin(dig_sui,25)=yes then signe_lon_c=1 : goto debut4 if keyin(val_sui,25)=no then goto debut3_1 delay 200 char=45:gosub wr_lcd :char=CrsrLf:gosub put_cmd 'positionne curseur sur "-" debut3_2: if keyin(dig_sui,25)=yes then signe_lon_c=0 : goto debut4 if keyin(val_sui,25)=yes then goto debut2 goto debut3_2 debut4: char=CrsrRt:gosub put_cmd ' met curseur 1 cran a droite gosub entre_lon if entree_valid=0 then goto debut2 'debut5: 'goto debut5 char=clrlcd:gosub put_cmd gosub sauve_cible return '------------------------------------------------------------------- '*********** ROUTINES GENERALES *************************** '------sub posi_cursor----------------------- posi_cursor: if ligne_ecri=1 then char=home1 else char=home2 gosub put_cmd col_ecri=col_ecri-1 for x1=1 to col_ecri char= CrsrRt :gosub put_cmd next x1 return '----- sub entree digit --------------------- entre_digit: val=5 ' valeur par defaut au depart entre 0 et 9 debut_entre: char=48+val:gosub wr_lcd char=CrsrLf:gosub put_cmd 'positionne curseur sur dernier caractere ecrit debut_entre1: if keyin(valid,25)=yes then entree_valid=1 :return if keyin(dig_sui,25)=yes then delay 200 :return if keyin(val_sui,25)=no then goto debut_entre1 val=val+1 delay 400 if val>9 then val=0 goto debut_entre '---------------------------------------------------------------- '--- sub entre_2_digit entre_2_digit: gosub entre_digit:x1=val col_ecri=col_ecri+1:char=CrsrRt:gosub put_cmd gosub entre_digit :x2=val col_ecri=col_ecri+1:char=CrsrRt:gosub put_cmd return '--- entree latitude --------------- entre_lat: col_ecri=5 gosub entre_2_digit lat_deg_c=10*x1+x2 char=39:gosub wr_lcd:col_ecri=col_ecri+1 ' ecrit ' pour degre gosub entre_2_digit lat_mn_c=10*x1+x2 char=46 :gosub wr_lcd:col_ecri=col_ecri+1 ' ecrit . pour point decimal gosub entre_2_digit lat_mn_deci_c=10*x1+x2 return '----------------------------------------------------------- '---- sub entre_longitude -------------- entre_lon: col_ecri=5 gosub entre_2_digit lon_deg_c=10*x1+x2 char=39:gosub wr_lcd:col_ecri=col_ecri+1 ' ecrit ' pour degre gosub entre_2_digit lon_mn_c=10*x1+x2 char=46 :gosub wr_lcd:col_ecri=col_ecri+1 ' ecrit . pour point decimal gosub entre_2_digit lon_mn_deci_c=10*x1+x2 return ' -----[ Subroutines affichage lcd parralel]----------------------------------------------------- '----------------------- Wr_LCD: ' Write ASCII char to LCD out RS,1 gosub put_cmd out rs,0 RETURN '---------------------------- put_cmd: ' char2=char ' char1=char>>4 ' char1=char1 and &h0f ' &h0F =00001111 pour ne sortir que 4 bit ' mais on met à zero les autres ' BYTEOUT 0,char1 ' output high nibble ' gosub pulse_en ' strobe the Enable line ' char2=char and &h0f ' BYTEOUT 0,char2 ' output low nibble ' gosub pulse_en ' alternative plus sure qui ne touche pas aux bit de poids fort ' presuppose lcd branche sur P0/P1/P2/P3 en mode 4 bit char1=char>>4 j=1 ' output high nibble for pin=0 to 3 val1= char1 and j out pin,val1 j=2*j next pin gosub pulse_en j=1 ' output low nibble for pin=0 to 3 val1= char and j out pin,val1 j=2*j next pin gosub pulse_en return '------------------------------------------------- pulse_en: delay 1 : out E,1 : delay 11 : out E,0 : delay 1 'avant 10 au lieu de 1 return '-------------------------------------------------------------- sort_nombre: 'routine sortie nmbre 16 bit contenu dans jj1 'utilise aussi jj2 jj2=jj1/10000 char=jj2+48:gosub wr_lcd jj1=jj1-jj2*10000 jj2=jj1/1000 char=jj2+48:gosub wr_lcd jj1=jj1-jj2*1000 jj2=jj1/100 char=jj2+48:gosub wr_lcd jj1=jj1-jj2*100 jj2=jj1/10 char=jj2+48:gosub wr_lcd jj1=jj1-jj2*10 jj2=jj1/1 char=jj1+48:gosub wr_lcd return '---------------------------------------------------- sauve_cible: eewrite &hFFF,lat_deg_c eewrite &hFFE,lat_mn_c eewrite &hFFD,lat_mn_deci_c eewrite &hffc,lon_deg_c eewrite &hffb,lon_mn_c eewrite &hffa,lon_mn_deci_c eewrite &hff9,signe_lon_c return '--------------------------------------- lit_cible: lat_deg_c=eeread (&hFFF) lat_mn_c=eeread (&hFFE) lat_mn_deci_c=eeread (&hFFD) lon_deg_c=eeread (&hffc) lon_mn_c=eeread (&hffb) lon_mn_deci_c=eeread (&hffa) signe_lon_c=eeread (&hff9) return