! 18-07-2016 ! test avec ARchos43IT sans GPS ! puis avec StaradictII et GPS ..OK ! Demonstrates the GPS commands debug.on s=0 GPS_Status=0 rmsg$="" a1$="" rr=0 dr=1 !NomFichier$="GPS_datas.txt" Progr$="Test-gps_160719.bas" print "PC Asus Win10 Basic_Launcher V0.7 SCi 3.4.3" print "Version basic : " Version$() Device DV$ print "Device Info : "; DV$ pause 3000 print "Application MikroC Coté PIC BT RN41:" print "Clicker2_18F87J50_RN41_BT_maitre_160719.c" pause 2000 BT.OPEN new_connection: xdomenu =0 BT.CONNECT ! Read status until ! a connection is made ln = 0 DO BT.STATUS s IF s = 1 ln = ln + 1 PRINT "En ecoute ", ln ELSEIF s =2 PRINT "Connection " ENDIF PAUSE 1000 UNTIL s = 3 ! When a connection is made ! get the name of the connected ! device BT.DEVICE.NAME device$ print "Connecté à : ";device$;chr$(13) print "Pret à recevoir une commande " print chr$(13) ! Gps.open {{},{},{}} ! The time interval expression sets the minimum ! time between location updates ! Time_Interval=3000 % 3 sec ! Minimum_Distance_Interval=2 % meters fot updating GPS.OPEN ! GPS_Status,Time_Interval,Minimum_Distance_Interval GR.OPEN 255,255,255 GR.ORIENTATION 0 GR.SCREEN w, h GR.TEXT.TYPEFACE 2 sp = h/9 pad = 0.25 * sp x = 20 idx=0 Boucle: BT.STATUS s IF s<> 3 PRINT "Connection BT perdue " GOTO Fin ENDIF GR.TEXT.SIZE sp - 2*pad GR.COLOR 255,0,0,0,1 Debug.print 1 y = 0*sp + sp - pad GR.TEXT.DRAW p, x,y, " Indice ="+ FORMAT$("####",idx) GPS.TIME time GR.TEXT.DRAW p, 400,y, "Time: " + USING$(, "%tT", int(time)) Debug.print 2 y = 1*sp + sp - pad GPS.ACCURACY accuracy GR.TEXT.DRAW p, x,y, "Accuracy: " + FORMAT$("####", accuracy) + " m" Debug.print 3 y = 2*sp + sp - pad GPS_Status=0 GPS.STATUS GPS_Status,inFix,inView GR.TEXT.DRAW p, x,y, "GPS Status= " + GPS_Status$ +" Satel. "+ FORMAT$("##%",inFix)+" dont "+ Format$("##%",inview)+ " detec." !GPS.SATELLITES sats !GR.TEXT.DRAW p, x,y, "Satellites: " + FORMAT$("##%", sats) + " in view "+ Format$("###",inview) Debug.print 4 y = 3*sp + sp - pad GPS.LATITUDE latitude GR.TEXT.DRAW p, x,y, "Latitude: " + FORMAT$("##%.#####", latitude) Debug.print 5 y = 4*sp + sp - pad GPS.LONGITUDE longitude GR.TEXT.DRAW p, x,y, "Longitude: " + FORMAT$("##%.#####", longitude) Debug.print 6 y = 5*sp + sp - pad GPS.ALTITUDE altitude GR.TEXT.DRAW p, x,y, "Altitude: " + FORMAT$("####%", altitude) + " m" Debug.print 7 !y = 6*sp + sp - pad !GPS.BEARING bearing !GR.TEXT.DRAW p, x,y, "Bearing: " + FORMAT$("##%.##", bearing) Debug.print 8 y = 6*sp + sp - pad GPS.SPEED speed GR.TEXT.DRAW p, x,y, "Speed: " + FORMAT$("##%.##", speed) + " m/s" Debug.print 9 y = 7*sp + sp - pad if (len(rmsg$)>1) GR.TEXT.DRAW p, x,y, "PIC ->RN41: " + left$(rmsg$,32) else GR.TEXT.DRAW p, x,y, " " endif y = 8*sp + sp - pad if (inFix>6) wmsg$="" wmsg$="LAT:"+FORMAT$("##%.#####", latitude)+" LON:" + FORMAT$("##%.#####", longitude)+ " ALT:" + FORMAT$("####%", altitude) GR.TEXT.DRAW p, x,y,wmsg$ GR.RENDER BT_Msg$= USING$(, "%tT", int(time))+" "+ wmsg$ + " Sat: "+ FORMAT$("##%",inFix) BT.WRITE BT_Msg$;chr$(13) else GR.TEXT.DRAW p,x,y,"Nb insuffisants de satelites : "+ FORMAT$("##%",inFix) BT.WRITE "Satelites en vue insuffisants: " + FORMAT$("##%",inFix);chr$(13) endif BT.WRITE BT_Msg$;chr$(13) GR.CLS PAUSE 1000 idx=idx+1 ! !if (idx=10) !Sms.send <33621334715,wmsg); % number_sexp>, !SMS.RCV.INIT !DO % Loop until SMS received !PAUSE 5000 % Sleep of 5 seconds !SMS.RCV.NEXT m$ % Try to get a new message !UNTIL m$ <> "@" % "@" indicates no new message !end if ! GOTO Boucle ONERROR: debug.print GETERROR$() Debug.print "sortie sur Erreur" fin: Console.save "Err_"+Prog$+".txt" pause 2000 end OnBtReadReady: ! Read messages until the message queue is empty rmsg$="" a1$="" DO BT.READ.READY rr IF rr dr=1 pause 100 bt.read.bytes A1$ rmsg$=rmsg$+a1$ end if until rr=0 if dr=1 then a1$="" dr=0 end if Pause 200 Bt.onReadReady.Resume END