Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce update when angle not changing and sleep esp modem #203

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions firmware/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ esp-wifi = { git = "https://github.com/esp-rs/esp-wifi.git", rev = "76ba312", fe
"embedded-svc",
"wifi",
"embassy-net",
"ps-min-modem",
], optional = true }
smoltcp = { version = "0.9", default-features = false, features = [
], optional = true }
Expand Down Expand Up @@ -213,6 +214,7 @@ nalgebra = { version = "0.31", default-features = false, features = [
"macros",
"libm",
] }
approx = "0.5.1"
fugit = "0.3"
firmware_protocol = { path = "../networking/firmware_protocol", features = [
"nalgebra031",
Expand Down
7 changes: 6 additions & 1 deletion firmware/src/imu/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
mod drivers;
mod fusion;

use approx::AbsDiffEq;
use defmt::{debug, info, trace, warn};
use embassy_executor::task;
use firmware_protocol::ImuType;
Expand Down Expand Up @@ -46,6 +47,7 @@ pub async fn imu_task(
info!("Initialized IMU!");

let mut i = 0;
let mut prev_q = Quat::identity();
loop {
let q = match imu.next_data().await {
Ok(q) => q.q,
Expand All @@ -64,7 +66,10 @@ pub async fn imu_task(
);
}
i += 1;
quat_signal.signal(q);
if !q.abs_diff_eq(&prev_q, 0.0001) {
prev_q = q;
quat_signal.signal(q);
}
}
}

Expand Down