-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Use embedded_hal::blocking::delay::DelayMs instead of std::thread::sleep * Make thiserror dependency an optional feature Co-authored-by: Timo <[email protected]>
- Loading branch information
Showing
5 changed files
with
42 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
use thiserror::Error; | ||
pub type Result<T> = core::result::Result<T, SHTError>; | ||
|
||
pub type Result<T> = std::result::Result<T, SHTError>; | ||
|
||
#[derive(Error, Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] | ||
#[cfg_attr(feature = "thiserror", derive(thiserror::Error))] | ||
#[derive(Copy, Clone, Debug, Ord, PartialOrd, Eq, PartialEq)] | ||
pub enum SHTError { | ||
#[error("Write Read I2C Error")] | ||
#[cfg_attr(feature = "thiserror", error("Write Read I2C Error"))] | ||
WriteReadI2CError, | ||
#[error("Write I2C Error")] | ||
#[cfg_attr(feature = "thiserror", error("Write I2C Error")) ] | ||
WriteI2CError, | ||
#[error("Humidity bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}")] | ||
#[cfg_attr(feature = "thiserror", error("Humidity bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}"))] | ||
InvalidHumidityChecksumError { | ||
bytes_start: u8, | ||
bytes_end: u8, | ||
expected_checksum: u8, | ||
calculated_checksum: u8, | ||
}, | ||
#[error("Temperature bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}")] | ||
#[cfg_attr(feature = "thiserror", error("Temperature bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}"))] | ||
InvalidTemperatureChecksumError { | ||
bytes_start: u8, | ||
bytes_end: u8, | ||
expected_checksum: u8, | ||
calculated_checksum: u8, | ||
}, | ||
#[error("Status bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}")] | ||
#[cfg_attr(feature = "thiserror", error("Status bytes [{bytes_start:#x}, {bytes_end:#x}] expected {expected_checksum:#x} but got the checksum {calculated_checksum:#x}"))] | ||
InvalidStatusChecksumError { | ||
bytes_start: u8, | ||
bytes_end: u8, | ||
expected_checksum: u8, | ||
calculated_checksum: u8, | ||
}, | ||
#[error("Single shot reading timeout")] | ||
#[cfg_attr(feature = "thiserror", error("Single shot reading timeout"))] | ||
ReadingTimeoutError, | ||
#[error("This error should not happen")] | ||
#[cfg_attr(feature = "thiserror", error("This error should not happen"))] | ||
PlaceholderError, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters