-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
change beep frequency when GPS fix is obtained (#73)
* feat(cansat-stm32f4): add buzzer support #59 * style: make cargo-fmt happy * feat(cansat-stm32f4): beep every three seconds * feat!(cansat-core): add nmea parser * feat(cansat-stm32f4): when fix is obtained, change beep frequency * refactor!: use fork of nmea with implemented serialize trait * fix: use nmea fork from git repo * refactor: use refactored NmeaGga in read_measurement task * refactor: make clippy happy * feat: respect defmt optionality, impl Debug for nmea Error * style: delete commented code * chore: use original nmea repository * chore: enable GGA statement * style: make clippy happy
- Loading branch information
Showing
8 changed files
with
209 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
#![no_std] | ||
|
||
pub mod measurements; | ||
pub mod nmea; | ||
pub mod quantity; | ||
|
||
pub use measurements::Measurements; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
use nmea::sentences::{FixType, GgaData}; | ||
use nmea::ParseResult; | ||
use serde::Serialize; | ||
|
||
#[cfg(feature = "defmt")] | ||
use defmt::Format; | ||
|
||
#[cfg_attr(feature = "defmt", derive(Format))] | ||
#[derive(Debug)] | ||
pub enum Error<'a> { | ||
ParsingFailed(#[cfg_attr(feature = "defmt", defmt(Debug2Format))] nmea::Error<'a>), | ||
InvalidCommand, | ||
} | ||
|
||
#[derive(Serialize, Debug)] | ||
pub struct NmeaGga(GgaData); | ||
|
||
impl NmeaGga { | ||
pub fn try_new(bytes: &[u8]) -> Result<NmeaGga, Error> { | ||
let ParseResult::GGA(gga) = nmea::parse_bytes(bytes).map_err(Error::ParsingFailed)? else { | ||
return Err(Error::InvalidCommand) | ||
}; | ||
|
||
Ok(Self(gga)) | ||
} | ||
|
||
pub fn get_fix(&self) -> bool { | ||
self.0 | ||
.fix_type | ||
.map(|ft| FixType::Invalid != ft) | ||
.unwrap_or(false) | ||
} | ||
} | ||
|
||
#[cfg(feature = "defmt")] | ||
impl Format for NmeaGga { | ||
fn format(&self, fmt: defmt::Formatter) { | ||
defmt::write!( | ||
fmt, | ||
"fix_time: {:?}, fix_type: {:?}, latitude: {:?}, | ||
fix_satelites: {:?}, hdop: {:?}, altitude: {:?}, | ||
geoid_separation: {:?}", | ||
self.0.fix_time.as_ref().map(defmt::Debug2Format), | ||
self.0.fix_type.as_ref().map(defmt::Debug2Format), | ||
self.0.latitude, | ||
self.0.fix_satellites, | ||
self.0.hdop, | ||
self.0.altitude, | ||
self.0.geoid_separation | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters