Just a simple Python script to display the location data to the LCD (PiFace CAD):
*This is not by any means a clean program - I haven't removed unneeded imports and the display portion includes a counter I was intending to use but haven't implemented yet*
*This is just a simple demo to show it is working*
#!/usr/bin/env python3
"""
Grab data from GPS and spit it out to LCD
"""
import sys
PY3 = sys.version_info[0] >= 3
if not PY3:
print("Please use `python3`.")
sys.exit(1)
###import libraries and set up gps
import urllib.request
import xml.etree.ElementTree
from time import sleep
from threading import Barrier
import pifacecommon
import pifacecad
import sys,math,time,microstacknode.gps.l80gps
gps=microstacknode.gps.l80gps.L80GPS()
current_pos=False
while current_pos==False:
try: # try command used to prevent crash when no response from GPS
current_pos=gps.gpgll # gets current GPS position
except (microstacknode.gps.l80gps.DataInvalidError, microstacknode.gps.l80gps.NMEAPacketNotFoundError): # if no GPS response or if response is invalid
time.sleep(1) #pauses before retry to connect to GPS
#print(current_pos) # for debugging
cad=pifacecad.PiFaceCAD()
cad.lcd.backlight_on()
cad.lcd.cursor_off()
cad.lcd.blink_off()
cad.lcd
count=0
last_pos=0
while True:
try: # try command used to prevent crash when no response from GPS
current_pos=gps.gpgll # gets current GPS position
except (microstacknode.gps.l80gps.DataInvalidError, microstacknode.gps.l80gps.NMEAPacketNotFoundError): # if no GPS response or if response is invalid
time.sleep(1) #pauses before retry to connect to GPS
cad.lcd.home()
# cad.lcd.write(str(count))
if last_pos != current_pos:
last_pos = current_pos
# cad.lcd.write(str(count)+", "+str(current_pos["latitude"])+"\n"+str(current_pos["longitude"]))
cad.lcd.write(str(current_pos["latitude"])+"\n"+str(current_pos["longitude"]))
count += 1
else:
count = 1