Skip to content

Commit

Permalink
Derive standard traits for crate types
Browse files Browse the repository at this point in the history
  • Loading branch information
sirhcel committed Oct 12, 2024
1 parent 012c388 commit 2255861
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub(crate) enum Command {
MeasureHighPrecision,
MeasureMediumPrecision,
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sensirion_i2c::i2c;

/// Error conditions from accessing SHT4x sensors.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[non_exhaustive]
pub enum Error<E> {
/// Failed I2C communication.
Expand Down
2 changes: 1 addition & 1 deletion src/sht4x.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const RESPONSE_LEN: usize = 6;

/// Driver for STH4x sensors.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Debug)]
#[derive(Debug, Eq, PartialEq)]
pub struct Sht4x<I, D> {
i2c: I,
address: Address,
Expand Down
12 changes: 6 additions & 6 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use fixed::types::{I16F16, I18F14, U16F16};

/// I2C adresses used by STH4x sensors.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Address {
Address0x44,
Address0x45,
Expand All @@ -19,7 +19,7 @@ impl From<Address> for u8 {

/// Heating power to apply when activating the internal heater.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum HeatingPower {
/// Operate the heater at 200 mW.
Low,
Expand All @@ -31,7 +31,7 @@ pub enum HeatingPower {

/// Duration of heating when activating the internal heater.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum HeatingDuration {
/// Operate the heater for 100 ms.
Short,
Expand All @@ -40,7 +40,7 @@ pub enum HeatingDuration {
}

/// A measurement from the sensor in SI units.
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Measurement {
/// The measurred temperature in degree Celsius (°C).
temperature: I16F16,
Expand All @@ -52,7 +52,7 @@ pub struct Measurement {
///
/// Higher-precision measurements take longer.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum Precision {
Low,
Medium,
Expand All @@ -61,7 +61,7 @@ pub enum Precision {

/// A measurement from the sensor in raw sensor data.
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive(Clone, Copy, Debug)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct SensorData {
/// The measured temperature as raw sensor value.
pub temperature: u16,
Expand Down

0 comments on commit 2255861

Please sign in to comment.