Code Monkey home page Code Monkey logo

bmp280's Introduction

Nothing yet

bmp280's People

Contributors

gambrose avatar qiuchengxuan avatar

Watchers

 avatar

Forkers

gambrose

bmp280's Issues

Invalid parsing of raw measurements

In your test you have RawPressure::from_bytes(&hex!("4E 54 80")) I make that this should have a value of 320840 but it actually gives 320960.
repo:

#[test]
fn parse_raw_pressure() {
    use super::RawPressure;
    let raw_pressure = RawPressure::from_bytes(&hex!("4E 54 80"));
    assert_eq!(320840, raw_pressure.0);
}

I think this is because we are not taking the top nibble from the xlsb register.

I think that this:

pub fn from_bytes(bytes: &[u8]) -> Self {
      Self((bytes[0] as i32) << 12 | (bytes[1] as i32) << 4 | (bytes[2] as i32))
  }

should be changed to something like this:

 pub fn from_bytes(bytes: &[u8]) -> Self {
      let msb = (bytes[0] as i32) << 12;
      let lsb = (bytes[1] as i32) << 4;
      let xlsb = (bytes[2] as i32) >> 4;

      Self(msb | lsb | xlsb)
  }

i2c bus

Am I right in thinking that as it stands it is not possible to use this lib with a BMP280 connected to an i2c bus?

I am fairly new to rust but from looking over the code I think I would need to implement an I2cBus that implemented the Bus trait.

I am happy to try and put together a PR but wanted to reach out first as I might need some help, guidance as this is my first embedded rust project.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.