Skip to content

Commit

Permalink
Allow device I2C address in initialization configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
marti157 committed May 15, 2024
1 parent c0b5f33 commit 59efd16
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,18 @@ pub struct BMP<I2C, D> {
/// Driver configuration, used only during driver initialization.
pub struct Config {
pub oss: Oss,
/// Device I2C address, default is 0x77
pub address: u8,
}

impl Default for Config {
/// Default configuration for the BMP085/180 driver.
/// Oversampling setting defaults to [`LowPower`](Oss::LowPower)
fn default() -> Self {
Config { oss: Oss::LowPower }
Config {
oss: Oss::LowPower,
address: BMP_DEVICE_ADDR,
}
}
}

Expand Down Expand Up @@ -89,7 +94,7 @@ where
Self {
i2c,
delayer,
address: BMP_DEVICE_ADDR,
address: config.address,
calib_data: CalibrationData::default(),
oss: config.oss,
sea_level_pressure: 101_325,
Expand Down

0 comments on commit 59efd16

Please sign in to comment.