Skip to content

Commit

Permalink
Fix compilation of bme680 module
Browse files Browse the repository at this point in the history
  • Loading branch information
jgosmann committed Feb 12, 2023
1 parent f313152 commit c8cc41d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.4.1] - 2023-02-12

### Fixed

* Fix compilation of `bme680` module by adding `delay` arguments.


## [0.4.0] - 2023-02-12

### Changed
Expand Down Expand Up @@ -56,7 +63,8 @@ Try to get documentation to build on docs.rs.
Initial release.


[Unreleased]: https://github.com/jgosmann/bsec/compare/v0.4.0...HEAD
[Unreleased]: https://github.com/jgosmann/bsec/compare/v0.4.1...HEAD
[0.4.1]: https://github.com/jgosmann/bsec/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/jgosmann/bsec/compare/v0.3.1...v0.4.0
[0.3.1]: https://github.com/jgosmann/bsec/compare/v0.3.0...v0.3.1
[0.3.0]: https://github.com/jgosmann/bsec/compare/v0.2.0...v0.3.0
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ license = "MIT OR Apache-2.0"
name = "bsec"
readme = "README.md"
repository = "https://github.com/jgosmann/bsec"
version = "0.4.0"
version = "0.4.1"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

Expand Down
15 changes: 11 additions & 4 deletions src/bme/bme680.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ where
D: DelayMs<u8>,
{
bme680: Bme680<I2C, D>,
delay: D,
initial_ambient_temp_celsius: f32,
temp_offset_celsius: f32,
disable_baseline_tracker: Option<f32>,
Expand All @@ -52,9 +53,10 @@ where
/// * `initial_ambient_temp_celsius = 20.0`
/// * `temp_offset_celsius = 0.0`
/// * `disable_baseline_tracker = false`
pub fn new(bme680: Bme680<I2C, D>) -> Self {
pub fn new(bme680: Bme680<I2C, D>, delay: D) -> Self {
Self {
bme680,
delay,
initial_ambient_temp_celsius: 20.,
temp_offset_celsius: 0.,
disable_baseline_tracker: None,
Expand Down Expand Up @@ -83,6 +85,7 @@ where
pub fn build(self) -> Bme680Sensor<I2C, D> {
Bme680Sensor::new(
self.bme680,
self.delay,
self.initial_ambient_temp_celsius,
self.temp_offset_celsius,
self.disable_baseline_tracker,
Expand All @@ -102,6 +105,7 @@ where
D: DelayMs<u8>,
{
bme680: Bme680<I2C, D>,
delay: D,
measurement_available_after: Option<Instant>,
last_measured_temp_celsius: f32,
temp_offset_celsius: f32,
Expand All @@ -127,12 +131,14 @@ where
/// documentation for details.
fn new(
bme680: Bme680<I2C, D>,
delay: D,
initial_ambient_temp_celsius: f32,
temp_offset_celsius: f32,
disable_baseline_tracker: Option<f32>,
) -> Self {
Bme680Sensor {
bme680,
delay,
measurement_available_after: None,
last_measured_temp_celsius: initial_ambient_temp_celsius,
temp_offset_celsius,
Expand Down Expand Up @@ -169,9 +175,10 @@ where
)
.build();

self.bme680.set_sensor_settings(settings)?;
self.bme680.set_sensor_settings(&mut self.delay, settings)?;
let profile_duration = self.bme680.get_profile_dur(&settings.0)?;
self.bme680.set_sensor_mode(PowerMode::ForcedMode)?;
self.bme680
.set_sensor_mode(&mut self.delay, PowerMode::ForcedMode)?;
self.measurement_available_after = Some(Instant::now() + profile_duration);
Ok(profile_duration)
}
Expand All @@ -181,7 +188,7 @@ where
None => panic!("must call start_measurement before get_measurement"),
Some(instant) if instant > Instant::now() => Err(nb::Error::WouldBlock),
_ => {
let (data, _state) = self.bme680.get_sensor_data()?;
let (data, _state) = self.bme680.get_sensor_data(&mut self.delay)?;
self.last_measured_temp_celsius = data.temperature_celsius();
let mut bsec_inputs = Vec::with_capacity(6);
bsec_inputs.extend(&[
Expand Down

0 comments on commit c8cc41d

Please sign in to comment.