diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 6cb045e..c404d4a 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -37,6 +37,7 @@ jobs: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: + target: thumbv7em-none-eabi components: rustfmt, clippy, rust-src - run: cargo test @@ -45,6 +46,8 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable + with: + target: thumbv7em-none-eabi - run: cargo test --all-features build: @@ -58,21 +61,4 @@ jobs: cargo build --target thumbv7m-none-eabi --all-features - - release: - runs-on: ubuntu-latest - steps: - - name: version - run: echo "version=$(cargo pkgid | cut -d '#' -f2)" >> $GITHUB_OUTPUT - id: version - - name: Release - uses: actions/create-release@v1 - id: create_release - with: - draft: false - prerelease: false - release_name: ${{ steps.version.outputs.version }} - tag_name: ${{ github.ref }} - #body_path: CHANGELOG.md - env: - GITHUB_TOKEN: ${{ github.token }} \ No newline at end of file + \ No newline at end of file diff --git a/src/lib.rs b/src/lib.rs index 8e5f8b9..122f3b4 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -60,7 +60,7 @@ impl> PasCo2 { defmt::info!("Setting measurement mode: {:b}", mode); self.i2c - .write(ADDRESS, &[MeasurementMode::address(), mode.into()])?; + .write(ADDRESS, &[MeasurementMode::address(), mode])?; Ok(()) } @@ -110,7 +110,7 @@ impl> PasCo2 { /// Clear the int active bit and the alarm bit of the sensor's [MeasurementStatus] register pub fn clear_measurement_status(&mut self) -> Result<(), I2C::Error> { - let bitmask = &MeasurementStatus::clear_int_active() & MeasurementStatus::clear_alarm(); + let bitmask = MeasurementStatus::clear_int_active() & MeasurementStatus::clear_alarm(); self.i2c .write(ADDRESS, &[MeasurementStatus::address(), bitmask])?; Ok(()) @@ -124,7 +124,7 @@ impl> PasCo2 { defmt::info!("Setting interrupt config: {:b}", config); self.i2c - .write(ADDRESS, &[InterruptConfig::address(), config.into()])?; + .write(ADDRESS, &[InterruptConfig::address(), config])?; Ok(()) } diff --git a/src/regs/measurement_mode.rs b/src/regs/measurement_mode.rs index 64aa17e..fd1941a 100644 --- a/src/regs/measurement_mode.rs +++ b/src/regs/measurement_mode.rs @@ -43,12 +43,10 @@ impl Default for MeasurementMode { impl From for u8 { fn from(value: MeasurementMode) -> Self { - let bitmask = (value.pwm_out_enable as u8) << 5 + (value.pwm_out_enable as u8) << 5 | (value.pwm_mode as u8) << 4 | (value.baseline_offset_comp as u8) << 2 - | value.operating_mode as u8; - - bitmask + | value.operating_mode as u8 } } diff --git a/src/regs/measurement_status.rs b/src/regs/measurement_status.rs index 327009d..f0465d9 100644 --- a/src/regs/measurement_status.rs +++ b/src/regs/measurement_status.rs @@ -3,13 +3,12 @@ pub struct MeasurementStatus { /// New data available in CO2PPM Register pub data_ready: bool, - /// Pin INT has been latched to active state + /// Pin INT has been latched to active state pub int_active: bool, /// Alarm notification (threshold violation occured) - pub alarm: bool + pub alarm: bool, } - impl MeasurementStatus { /// Bitmask to clear the int pin active bit pub(crate) fn clear_int_active() -> u8 { diff --git a/src/regs/mod.rs b/src/regs/mod.rs index 1e404ad..d91d3e2 100644 --- a/src/regs/mod.rs +++ b/src/regs/mod.rs @@ -43,9 +43,11 @@ impl Reg for AlarmThreshold { 0x09 } } +// Explicitly state it here that the threshold is zero +#[allow(clippy::derivable_impls)] impl Default for AlarmThreshold { fn default() -> Self { - Self(0) + Self(0x0) } } diff --git a/src/regs/status.rs b/src/regs/status.rs index eec590f..525f859 100644 --- a/src/regs/status.rs +++ b/src/regs/status.rs @@ -35,7 +35,7 @@ impl From for Status { Self { ready: (value & 0b1000_0000) != 0, pwm_dis: (value & 0b0100_0000) != 0, - temperature_error:(value & 0b0010_0000) != 0, + temperature_error: (value & 0b0010_0000) != 0, voltage_error: (value & 0b0001_0000) != 0, communication_error: (value & 0b0000_1000) != 0, } @@ -48,7 +48,6 @@ impl super::Reg for Status { } } - #[cfg(test)] #[test] fn test_bitmask() {