stm32-rs / stm32f407g-disc

Rust BSP crate for the STM32F4DISCOVERY (STM32F407G-DISC) development board
BSD Zero Clause License
43 stars 14 forks source link

Fix example build errors #30

Closed charlesbmi closed 1 year ago

charlesbmi commented 1 year ago

I am trying to get set up using this BSP crate.

When I try a clean cargo build --examples, I got the following errors:

error[E0107]: struct takes 2 generic arguments but 1 generic argument was supplied
   --> examples/i2c_hal_ssd1306helloworld.rs:45:23
    |
45  |         let mut disp: TerminalMode<_> = Builder::new().with_i2c_addr(0x3c).connect_i2c(i2c).into();
    |                       ^^^^^^^^^^^^ - supplied 1 generic argument
    |                       |
    |                       expected 2 generic arguments

and

error[E0599]: no method named `with_i2c_addr` found for struct `Builder` in the current scope
  --> examples/i2c_hal_ssd1306alphabeter.rs:45:56
   |
45 |         let mut disp: TerminalMode<_> = Builder::new().with_i2c_addr(0x3c).connect_i2c(i2c).into();
   |                                                        ^^^^^^^^^^^^^ method not found in `Builder`

It seems that this was the old API for the ssd1306 crate: https://docs.rs/ssd1306/0.3.1/ssd1306/index.html

The Cargo.toml-specified ssd1306=0.5.2 versions uses a slightly different API: https://docs.rs/ssd1306/0.5.2/ssd1306/index.html. I have fixed this in this PR. I do not have a ssd1306 display to test this out, so this is just to fix the build errors.