Skip to content
Open
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
21 changes: 21 additions & 0 deletions crates/cansat-stm32f4/src/tasks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,31 @@ 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);

let Some(acc) = measurements.acceleration else {
panic!("No acceleration data");
};

if takeoff_detection_readings >= 0 {
if acc.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