from machine import Pin, I2C
import ssd1306
import micropyGPS
import time
# Create an I2C object for the SSD1306 display
i2c = I2C(scl=Pin(5), sda=Pin(4))
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
# Initialize the GPS parser
gps = micropyGPS.MicropyGPS(9, 'dd')
def display_text(text):
oled.fill(0)
oled.text(text, 0, 0)
oled.show()
def convert_coordinates_to_cartesian(latitude, longitude):
# Your conversion code here
pass
while True:
if uart.any():
sentence = uart.readline()
for char in sentence:
gps.update(chr(char))
if gps.valid:
if gps.fix_stat == 1: # GPS fix status 'A'
velocity = gps.speed[2] # Speed in km/h
latitude = gps.latitude[0] + gps.latitude[1] / 60.0
longitude = gps.longitude[0] + gps.longitude[1] / 60.0
# Display latitude, longitude, and speed on the OLED
display_text("Latitude: {:.8f}".format(latitude))
display_text("Longitude: {:.8f}".format(longitude))
display_text("Speed: {:.2f} Km/h".format(velocity))
# Convert coordinates to Cartesian
convert_coordinates_to_cartesian(latitude, longitude)
time.sleep(1)