Code Monkey home page Code Monkey logo

lis3mdl's People

Contributors

justacec avatar nnarain avatar ryanrightmer avatar taruti avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

lis3mdl's Issues

Takes full ownership of the I2C port not allowing for multiple devices on a single channel

I have a situation where I need to daisy chain three different sensors on the same I2C channel. With the pattern in this codebase, the driver takes ownership of the I2C device not allowing it to be shared with other device drivers.

I would recommend adding in some way that the driver accepts does not always own the I2C and can be managed by a higher level interface. An example would be to move the i2c device in the struct to be an Option<I2C> and then put in a take_i2c(&mut self) and a set_i2c(&mut self, i2c: I2C) style methods.

An alternative I have seen with other drivers, is to just pass the I2C device to each call. Sounds cumbersome, but might be proffered based on the time it takes to do the extra function calls and cross-checks postulated above.

Thoughts?

Please add support for `embedded-hal-async`

The I2c trait from embedded-hal-async would allow this crate's usage with embassy.

Unfortunately, I can only think of hacky solutions to support both blocking and async:

  • Make a second copy of all the functions, doing the rote fn -> async fn transformation and sprinkling in some .await calls
  • Macro magic to define two copies using the same source

and then another question is:

  • Keep the same type names and swap in async using a feature, or
  • Expose the methods on a different type or in a different module (still feature-gated).

I asked in rust-embedded/embedded-hal#356 if there's any best practice here. I think most of the other crates I've seen have gone for some form of duplicate code.

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.