Update gps2-rpi-pico.py

main
ahmadlogs 2021-07-30 17:28:37 +05:00 zatwierdzone przez GitHub
rodzic 8bad25a3aa
commit 2928ed45a4
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4AEE18F83AFDEB23
1 zmienionych plików z 51 dodań i 1 usunięć

Wyświetl plik

@ -34,4 +34,54 @@ def convert(parts):
data = parts[0]+(parts[1]/60.0)
# parts[2] contain 'E' or 'W' or 'N' or 'S'
if (parts[2] == 'S'):
if (parts[2] == 'S'):
data = -data
if (parts[2] == 'W'):
data = -data
data = '{0:.6f}'.format(data) # to 6 decimal places
return str(data)
##########################################################
##########################################################
while True:
#_________________________________________________
#print(i2c.scan())
length = gps_module.any()
if length>0:
b = gps_module.read(length)
for x in b:
msg = my_gps.update(chr(x))
#_________________________________________________
latitude = convert(my_gps.latitude)
longitude = convert(my_gps.longitude)
#_________________________________________________
if (latitude == None and latitude == None):
oled.fill(0)
oled.text("No Data", 0, 0)
oled.show()
continue
#_________________________________________________
t = my_gps.timestamp
#t[0] => hours : t[1] => minutes : t[2] => seconds
gpsTime = '{:02d}:{:02d}:{:02}'.format(t[0], t[1], t[2])
gpsdate = my_gps.date_string('long')
speed = my_gps.speed_string('kph') #'kph' or 'mph' or 'knot'
#_________________________________________________
print('Lat:', latitude)
print('Lng:', longitude)
#print('time:', gpsTime)
#print('Date:', gpsdate)
#print('speed:', speed)
#_________________________________________________
oled.fill(0)
oled.text('Lat:'+ latitude, 0, 0)
oled.text('Lng:'+ longitude, 0, 12)
oled.text('Speed:'+ speed, 0, 24)
oled.text('Time:'+ gpsTime, 0, 36)
oled.text(gpsdate, 0, 48)
oled.show()
#_________________________________________________
##########################################################