33 lines
946 B
Rust
33 lines
946 B
Rust
use nmea0183::{ParseResult, Parser};
|
|
use stm32f1xx_hal::{
|
|
delay::Delay,
|
|
prelude::*,
|
|
serial::{Config, Serial},
|
|
stm32,
|
|
};
|
|
|
|
use crate::application::App;
|
|
use crate::time;
|
|
|
|
impl App {
|
|
pub fn poll_gps(&mut self) -> () {
|
|
match self.serial.read() {
|
|
Ok(byte) => {
|
|
self.board_led.toggle().unwrap();
|
|
if let Some(result) = self.gps_parser.parse_from_byte(byte) {
|
|
match result {
|
|
Ok(ParseResult::GGA(Some(gga))) => {
|
|
time::set(&gga.time);
|
|
defmt::info!("Got GGA")
|
|
} // Got GGA sentence
|
|
Ok(_) => {} // Some other sentences..
|
|
Err(_) => {} // Got parse error
|
|
}
|
|
}
|
|
}
|
|
Err(nb::Error::WouldBlock) => {}
|
|
Err(nb::Error::Other(_)) => {}
|
|
}
|
|
}
|
|
}
|