Updated some of the error handling and data sources for GPS

This commit is contained in:
Luke Else 2023-07-21 14:29:57 +01:00
parent 620ff4b207
commit 5828d5ead6
2 changed files with 2 additions and 4 deletions

View File

@ -34,7 +34,7 @@ impl GpsData {
// Format the nmea buffer into a usable string // Format the nmea buffer into a usable string
let nmea_raw = String::from_utf8(buf.to_owned()) 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(); let nmea_vec: Vec<&str> = nmea_raw.split('$').collect();
// Loop through each sentence and use the information to update GPS data // Loop through each sentence and use the information to update GPS data
@ -57,8 +57,6 @@ impl GpsData {
// print decoded gps data to serial // print decoded gps data to serial
match nmea { match nmea {
nmea_parser::ParsedMessage::Gga(gga) => { nmea_parser::ParsedMessage::Gga(gga) => {
self.latitude = gga.latitude;
self.longitude = gga.longitude;
self.altitude = gga.altitude; self.altitude = gga.altitude;
} }
nmea_parser::ParsedMessage::Gll(gll) => { nmea_parser::ParsedMessage::Gll(gll) => {

View File

@ -68,7 +68,7 @@ fn main() -> Result<(), Error> {
let interface = I2CDisplayInterface::new(i2c); let interface = I2CDisplayInterface::new(i2c);
let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0) let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate0)
.into_buffered_graphics_mode(); .into_buffered_graphics_mode();
display.init().unwrap(); display.init().map_err(|err| Error::DisplayError(DisplayError::SetupError(err)))?;
let raw: ImageRaw<BinaryColor> = ImageRaw::new(include_bytes!("./rust.raw"), 64); let raw: ImageRaw<BinaryColor> = ImageRaw::new(include_bytes!("./rust.raw"), 64);
let im: Image<'_, _> = Image::new(&raw, Point::new(32, 0)); let im: Image<'_, _> = Image::new(&raw, Point::new(32, 0));