From d8ff2b777579f5c8d7e0ad26d0c4290c83f15d75 Mon Sep 17 00:00:00 2001 From: Frederik Menke Date: Sun, 21 Jul 2024 13:32:13 +0200 Subject: [PATCH] Prefix sensor module to make it more obv --- src/{co2_sensor.rs => co2.rs} | 0 src/main.rs | 16 +++++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) rename src/{co2_sensor.rs => co2.rs} (100%) diff --git a/src/co2_sensor.rs b/src/co2.rs similarity index 100% rename from src/co2_sensor.rs rename to src/co2.rs diff --git a/src/main.rs b/src/main.rs index 46d1ee2..99432c7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -6,7 +6,7 @@ #![no_std] #![no_main] -mod co2_sensor; +mod co2; use byteorder::ByteOrder; use defmt::*; @@ -25,8 +25,6 @@ use {defmt_rtt as _, panic_probe as _}; use embassy_rp::i2c::{self, Config}; use embassy_time::{Duration, Timer}; -use co2_sensor::{get_measurement, get_status, set_measurement_mode, start_app}; - bind_interrupts!(struct Irqs { I2C1_IRQ => i2c::InterruptHandler; }); @@ -67,7 +65,7 @@ async fn main(spawner: Spawner) { // Wait for sensor to boot Timer::after(Duration::from_secs(1)).await; - let status = get_status(&mut i2c).await.unwrap(); + let status = co2::get_status(&mut i2c).await.unwrap(); info!("CO2 sesor reported status on boot: {}", status); @@ -75,11 +73,11 @@ async fn main(spawner: Spawner) { if status & 128u8 == 0 { info!("App is not running yet. Booting sensor..."); // App is not running - start_app(&mut i2c).await.unwrap(); + co2::start_app(&mut i2c).await.unwrap(); // After APP_START, we have to wait at least 1 ms (according to datasheet) Timer::after(Duration::from_millis(2)).await; - if get_status(&mut i2c).await.unwrap() & 128u8 == 0 { + if co2::get_status(&mut i2c).await.unwrap() & 128u8 == 0 { error!("App still not running after boot! Terminating..."); return; } @@ -88,11 +86,11 @@ async fn main(spawner: Spawner) { } // 16 is measurement mode 1 => 1 measurement per second - set_measurement_mode(&mut i2c, 16).await.unwrap(); + co2::set_measurement_mode(&mut i2c, 16).await.unwrap(); loop { - let status = get_status(&mut i2c).await.unwrap(); - let measured_value = get_measurement(&mut i2c).await.unwrap(); + let status = co2::get_status(&mut i2c).await.unwrap(); + let measured_value = co2::get_measurement(&mut i2c).await.unwrap(); info!( "Reported status: {}\tMeasured value: {}", status, measured_value