Giter Club home page Giter Club logo

Comments (4)

bugadani avatar bugadani commented on July 30, 2024

Could you please try with embedded-hal-bus = "0.1.0" instead of trying to use the dependency from github?

from ssd1306.

pdgilbert avatar pdgilbert commented on July 30, 2024

Changing Cargo.toml so I have

embedded-hal-bus = "0.1.0"

and text_i2c.rs to what I think I should have:

...
use hal::{
    //i2c::I2c,
    prelude::*,
    pac::{Peripherals, I2C1},
    pac,
};

use embedded_hal_bus::i2c::I2c;
...

Then when I compile I get

...

 Downloaded embedded-hal-bus v0.1.0
  Downloaded 1 crate (11.9 KB) in 0.72s
   Compiling embedded-hal-bus v0.1.0
   Compiling ssd1306 v0.8.4 (/home/paul/githubClones/ssd1306)

error[E0432]: unresolved import `embedded_hal_bus::i2c::I2c`
  --> examples/text_i2c.rs:53:5
   |
53 | use embedded_hal_bus::i2c::I2c;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^ no `I2c` in `i2c`
   |
help: consider importing one of these items instead
   |
53 | use crate::hal::i2c::I2c;
   |     ~~~~~~~~~~~~~~~~~~~~
53 | use embedded_hal::i2c::I2c;
   |     ~~~~~~~~~~~~~~~~~~~~~~
53 | use embedded_hal_async::i2c::I2c;
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
53 | use stm32f1xx_hal::i2c::I2c;
   |     ~~~~~~~~~~~~~~~~~~~~~~~
     and 2 other candidates

For more information about this error, try `rustc --explain E0432`.
error: could not compile `ssd1306` (example "text_i2c") due to 1 previous error

I find it strange that there is "no I2c in i2c". It really looks to me like it should be there. I don't see typos or anything simple, but this does not seem right.

Also, when I look at cargo tree, it looks like display-interface-i2c depends on embedded-hal-async but not on embedded-hal-bus.

$ cargo tree
ssd1306 v0.8.4 (/home/paul/githubClones/ssd1306)
├── display-interface v0.5.0 (https://github.com/bugadani/display-interface.git?branch=eh1#e65eaf6d)
├── display-interface-i2c v0.5.0 (https://github.com/bugadani/display-interface.git?branch=eh1#e65eaf6d)
│ ├── display-interface v0.5.0 (https://github.com/bugadani/display-interface.git?branch=eh1#e65eaf6d)
│ ├── embedded-hal v1.0.0
│ └── embedded-hal-async v1.0.0
│ └── embedded-hal v1.0.0
├── display-interface-spi v0.5.0 (https://github.com/bugadani/display-interface.git?branch=eh1#e65eaf6d)
│ ├── byte-slice-cast v1.2.2
│ ├── display-interface v0.5.0 (https://github.com/bugadani/display-interface.git?branch=eh1#e65eaf6d)
│ ├── embedded-hal v1.0.0
│ └── embedded-hal-async v1.0.0 ()
├── embedded-graphics-core v0.4.0
│ ├── az v1.2.1
│ └── byteorder v1.5.0
├── embedded-hal v1.0.0
├── embedded-hal-async v1.0.0 (
)
└── embedded-hal-bus v0.1.0
├── critical-section v1.1.2
└── embedded-hal v1.0.0
[dev-dependencies]
...

from ssd1306.

bugadani avatar bugadani commented on July 30, 2024

embedded-hal-bus isn't a simple plug-and-play crate, you don't get an I2c struct that "just works". You need to decide on how you share your bus between your devices, and for that you have three options.

Why do you expect display-interface-i2c to depend on embedded-hal-bus? embedded-hal-bus doesn't define any new traits that would require any special handling in display-interface-i2c.

from ssd1306.

pdgilbert avatar pdgilbert commented on July 30, 2024

Thanks for the hint @bugadani . I guess it is more complicated than I thought. I'll eventually figure it out. Not exactly a simple replacement for shared_bus, but seems like more control over the mechanism.

My thinking on display-interface-i2c depending on embedded-hal-bus was because I mis-read the tree and thought it depended on embedded-hal-spi. I think the spi and i2c similarities are such that one dependency would suggest the other too..

from ssd1306.

Related Issues (20)

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.