got embassy compass outputting a heading number.

This commit is contained in:
Gabe Venberg 2025-07-08 17:22:26 +02:00
parent 6f6660fd6a
commit 45578958a6
8 changed files with 103 additions and 76 deletions

View file

@ -0,0 +1,2 @@
[build]
target = "x86_64-unknown-linux-gnu"

View file

@ -6,4 +6,5 @@ edition = "2024"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
defmt = "1.0.1"
libm = "0.2.1"

View file

@ -1,12 +1,13 @@
use defmt::Format;
use libm::{atan2f, atanf, cosf, sinf};
#[derive(Debug)]
#[derive(Debug, Format)]
pub struct Attitude {
pub pitch: f32,
pub roll: f32,
}
#[derive(Debug)]
#[derive(Debug, Format)]
pub struct NedMeasurement {
pub x: f32,
pub y: f32,
@ -14,6 +15,7 @@ pub struct NedMeasurement {
}
///theta=0 at north, pi/-pi at south, pi/2 at east, and -pi/2 at west
#[derive(Debug, Format)]
pub struct Heading(pub f32);
pub fn calc_attitude(measurement: &NedMeasurement) -> Attitude {