28 lines
865 B
Rust
28 lines
865 B
Rust
use nmea0183::ParseResult;
|
|
use stm32f1xx_hal::prelude::*;
|
|
|
|
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))) => {
|
|
defmt::info!("Got a GGA, setting time");
|
|
time::set(&gga.time);
|
|
}
|
|
Ok(_) => {} // Some other sentences..
|
|
Err(_) => {} // Got parse error
|
|
}
|
|
}
|
|
}
|
|
Err(nb::Error::WouldBlock) => {}
|
|
Err(nb::Error::Other(_)) => {}
|
|
}
|
|
}
|
|
}
|