From 5828d5ead696667d5a979f31f2314cae0a8e2103 Mon Sep 17 00:00:00 2001 From: Luke Else Date: Fri, 21 Jul 2023 14:29:57 +0100 Subject: [PATCH] Updated some of the error handling and data sources for GPS --- src/gps/gpsdata.rs | 4 +--- src/main.rs | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/gps/gpsdata.rs b/src/gps/gpsdata.rs index 4365491..515a726 100644 --- a/src/gps/gpsdata.rs +++ b/src/gps/gpsdata.rs @@ -34,7 +34,7 @@ impl GpsData { // Format the nmea buffer into a usable string let nmea_raw = String::from_utf8(buf.to_owned()) - .map_err(|_| GpsError::ReadError())?; + .map_err(|_| GpsError::ReadError()).unwrap_or_default(); let nmea_vec: Vec<&str> = nmea_raw.split('$').collect(); // Loop through each sentence and use the information to update GPS data @@ -57,8 +57,6 @@ impl GpsData { // print decoded gps data to serial match nmea { nmea_parser::ParsedMessage::Gga(gga) => { - self.latitude = gga.latitude; - self.longitude = gga.longitude; self.altitude = gga.altitude; } nmea_parser::ParsedMessage::Gll(gll) => { diff --git a/src/main.rs b/src/main.rs index 74871a8..42e67ff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -68,7 +68,7 @@ fn main() -> Result<(), Error> { let interface = I2CDisplayInterface::new(i2c); let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0) .into_buffered_graphics_mode(); - display.init().unwrap(); + display.init().map_err(|err| Error::DisplayError(DisplayError::SetupError(err)))?; let raw: ImageRaw = ImageRaw::new(include_bytes!("./rust.raw"), 64); let im: Image<'_, _> = Image::new(&raw, Point::new(32, 0));