Code:
'****************************************************************
'* Name : NOKIA_DEMO.PBP *
'* Author : richard *
'* Notice : *
'* : *
'* Date : 16/5/2018 *
'* Version : mssp1 version with bigtxt *
'* Notes : *
'* :FOR pic 16F1847@32MHZ NOKIA *
'****************************************************************
#CONFIG ; 16FF1847.
__config _CONFIG1, _FOSC_INTOSC & _WDTE_ON & _PWRTE_ON & _MCLRE_ON & _CP_OFF & _BOREN_OFF
__config _CONFIG2, _PLLEN_OFF & _LVP_OFF
#ENDCONFIG
define OSC 32
; --- *** Oscillator *** ---------------------------------------------------
OSCCON = %11110000 ;32 MHz,
ANSELb = 0
ANSELA = 0
TRISA=%10010000
TRISB=%11101011
ch var byte
BUFF VAR BYTE [16]
;DEFINES FOR DISPLAY use font7x5_16.bas or font7x5_18.bas for pic18
#DEFINE PIC16 1
#define use_mssp 1
lcdheight con 5 ; 6 PAGES
lcdwidth con 83 ; 84 PIXELS WIDE
' LCD_CLK var LATB.4 ' SCK1 pin needs to be set as dig o/p
' LCD_DIN var LATB.2 ' SDO1 pin needs to be set as dig o/p
LCD_RST var LATA.4
LCD_DC var LATA.3
LCD_CE var LATA.6
LCD_LIGHT var LATA.0
nmea var byte[80]
h var byte
m var byte
s var byte
Include "nokia_ds.INC" ' bring it in
include "font7x5_16.bas"
@ #DEFINE TOKEN_DESTROY 1
include "strtok.pbpmod"
'========================== MAIN Routine ==============================
gosub lcd_init
LCDCLR
ARRAYWRITE BUFF,["READY",0]
LCDSTR 5,0,BUFF
PAUSE 1000
LCDCLR
looper:
'start=$ end=*
arraywrite nmea,["GNRMC,090045.000,A,3823.6645,N,02353.3600,E,0.02,195.80,170518,,,A",0]
strtok nmea,0,","
ARRAYREAD nmea, 5, GNGGA,[wait("GNRMC")]
GOSUB SH_MSG
GOSUB SH_TIME
strtok nmea ;fix
GOSUB SH_LON
GOSUB SH_LAT
arraywrite buff,["speed",0]
LCDSTR 0,3,BUFF
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 36,3,buff
strtok nmea
arraywrite buff,["hdg",0]
LCDSTR 0,4,BUFF
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 36,4,buff
strtok nmea
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),dec2 h,dec2 m,dec2 s]
arraywrite buff,[dec2 h,"/",dec2 m,"/",dec2 s,0]
LCDSTR 36,5,BUFF
PAUSE 1000
GNGGA:
arraywrite nmea,["GNGGA,140405.000,3823.6010,N,02353.3054,E,1,9,0.88,0.8,M,35.9,M,,",0]
strtok nmea,0,","
ARRAYREAD nmea, 5, XXX,[wait("GNGGA")]
GOSUB SH_MSG
GOSUB SH_TIME
GOSUB SH_LON
GOSUB SH_LAT
strtok nmea
strtok nmea
strtok nmea
strtok nmea
strtok nmea
arraywrite buff,["M",0]
LCDSTR 28,5,BUFF
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 0,5,buff
PAUSE 1000
GOTO LOOPER
XXX:
LCDCLR
arraywrite buff,["Oops",0]
LCDSTR 0,1,BUFF
end
SH_MSG:
LCDSTR 0,0,nmea ;sentence type
strtok nmea
RETURN
SH_TIME:
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),dec2 h,dec2 m,dec2 s]
arraywrite buff,[dec2 h,":",dec2 m,":",dec2 s,0]
LCDSTR 36,0,BUFF
strtok nmea
RETURN
SH_LON:
arraywrite buff,["lon",0]
LCDSTR 0,1,BUFF
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 20,1,buff
strtok nmea
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 77,1,buff
strtok nmea
RETURN
SH_LAT:
arraywrite buff,["lt",0]
LCDSTR 0,2,BUFF
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 13,2,buff
strtok nmea
ARRAYREAD nmea ,[SKIP (STRTOK_INX-STRTOK_LEN),str buff\16]
LCDSTR 77,2,buff
strtok nmea
RETURN
Bookmarks