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

Kingamadej 80 takeoff detection #81

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
17 changes: 17 additions & 0 deletions crates/cansat-stm32f4/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,27 @@ pub fn idle(mut ctx: app::idle::Context) -> ! {
.quote(b'\'')
.build();

let mut takeoff_detection_readings = 0;

loop {
let measurements = read_measurements(&mut ctx);
defmt::info!("{}", measurements);

if takeoff_detection_readings >= 0 {
if measurements.acceleration.unwrap().x > 0 {
takeoff_detection_readings += 1;
} else {
takeoff_detection_readings = 0;
}

if takeoff_detection_readings == 3 {
defmt::info!("Cansat has taken off.");
takeoff_detection_readings = -1;
} else {
defmt::info!("Cansat has not yet taken off.");
}
}

let csv_record = match serde_csv_core::to_vec(&mut writer, &measurements) {
Ok(r) => r,
Err(e) => {
Expand Down
Loading