'Display latitude and longitude out of a GPS (NMEA output) on a 16*2 lines 'LCD display using the hitachi HD 44780 controller. Needs the stamp BS2 for '4800 bauds NMEA. The LCD is wired in 4 bits mode according to the 'application note #1 in the stamp 1 manual. The code for LCD is adapted to 'the BS2 from the same app note. The NMEA input is on PIN 7. lat var byte(8) 'latitude without last decimal long var byte(9) 'longitude without last decimal 'time var byte(6) 'time (not used for now) ns var byte 'North South character ew var byte 'East West character E con 5 'LCD Enable pin, 1 = enabled RS con 4 ' LCD Register select pin, 0 = instruction char var byte 'Character sent to LCD. c var byte 'not use anymore I think (?) ni var byte 'nibble sent to the LCD begin: outl = 0 'Clear the output lines dirl = %01111111 'One input, 7 outputs. pause 200 'Wait 200 ms for LCD to reset. ' Initialize the LCD in accordance with Hitachi's instructions for 4-bit interface. outl = %00000011 'Set to 8-bit operation. pulsout E,5 'Send data three times pause 10 'to initialize LCD. pulsout E,5 pause 10 pulsout E,5 pause 10 outl = %00000010 'Set to 4-bit operation. pulsout E,5 pulsout E,5 outl = %00001010 pulsout E,5 char = 14 'Set up LCD in accordance with gosub wr_LCD 'Hitachi instruction manual. char = 6 'Turn on cursor and enable gosub wr_LCD 'left-to-right printing. char = 1 'Clear the display. gosub wr_LCD high RS 'Prepare to send characters. start: ' get NMEA data from pin 7, wait for the sentence "$GPGGA" to appear then skip 8 characters then read a 8 char string in lat ..... serin 7,188+$4000,[wait("$GPGGA"),skip 8 ,str lat\8,skip 1,str ns\1,skip 1,str long\9,skip 1,str ew\1] 'display on the pc screen for debug purpose to test NMEA connection only 'debug str lat\7," ",ns," ",str long\8," ",ew,cr 'put LCD cursor at 1st position on 1st line low RS : char=%10000000 : gosub wr_LCD : high RS char="L" : gosub wr_LCD 'write "LAT N 74°56.45'" on LCD first line char="A" : gosub wr_LCD char="T" : gosub wr_LCD char=" " : gosub wr_LCD char=ns : gosub wr_LCD char=" " : gosub wr_LCD char=lat(0) : gosub wr_LCD char=lat(1) : gosub wr_LCD char=%11011111 : gosub wr_LCD 'hitachi's code for char "°" char=lat(2) : gosub wr_LCD char=lat(3) : gosub wr_LCD char=lat(4) : gosub wr_LCD char=lat(5) : gosub wr_LCD char=lat(6) : gosub wr_LCD char=lat(7) : gosub wr_LCD char=39 : gosub wr_LCD 'hitachi's code for char "'" 'move LCD cursor to 1st position on 2d line low RS : char=%11000000 : gosub wr_LCD : high RS char="L" : gosub wr_LCD 'write "LNG W 125°56.45'" on LCD second line char="N" : gosub wr_LCD char="G" : gosub wr_LCD char=" " : gosub wr_LCD char=ew : gosub wr_LCD char=long(0) : gosub wr_LCD char=long(1) : gosub wr_LCD char=long(2) : gosub wr_LCD char=%11011111 : gosub wr_LCD char=long(3) : gosub wr_LCD char=long(4) : gosub wr_LCD char=long(5) : gosub wr_LCD char=long(6) : gosub wr_LCD char=long(7) : gosub wr_LCD char=long(8) : gosub wr_LCD char=39 : gosub wr_LCD goto start end ' Write the ASCII character in char to LCD. 'rem: actually not all the codes are exact ASCII match. wr_LCD: outl = outl & %00010000 ni = char/16 'Put high nibble of b3 into b2. outl = outl | ni 'OR the contents of b2 into pins. pulsout E,10 'Blip enable pin. ni = char & %00001111 'Put low nibble of b3 into b2. outl = outl & %00010000 'Clear 4-bit data bus. outl = outl | ni 'OR the contents of b2 into pins. pulsout E,10 'Blip enable. return