The trait `display_interface::WriteOnlyDataCommand` is not implemented for `SPIInterface

Hello, I am trying to create an spi connection to an oled display on an esp32-s3. I keep stumbeling on a WriteOnlyDataCommand is not implemented for SPIInterface error. I have been trying to go through examples and the docs, but can't find any way to get past this hurdle. Help would be greatly appreciated.

#![no_std]
#![no_main]

use esp_backtrace as _;
use esp_hal::{
    clock::ClockControl, delay::Delay, gpio::Io, peripherals::Peripherals, prelude::*,
    spi::master::Spi, spi::SpiMode, system::SystemControl,
};

use display_interface_spi::SPIInterface;
use ssd1309::{mode::GraphicsMode, Builder};

#[entry]
fn main() -> ! {
    let peripherals = Peripherals::take();
    let system = SystemControl::new(peripherals.SYSTEM);

    let mut clocks = ClockControl::max(system.clock_control).freeze();
    let delay = Delay::new(&clocks);

    esp_println::logger::init_logger_from_env();

    // Setup the i2c connection
    let io = Io::new(peripherals.GPIO, peripherals.IO_MUX);
    // let sda = io.pins.gpio8;
    let sclk = io.pins.gpio12;
    let mosi = io.pins.gpio13;
    let miso = io.pins.gpio11;
    let cs = io.pins.gpio10;
    let dc = io.pins.gpio18;

    let mut spi = Spi::new(peripherals.SPI2, 100.kHz(), SpiMode::Mode0, &mut clocks).with_pins(
        Some(sclk),
        Some(mosi),
        Some(miso),
        Some(cs),
    );

    let spi_interface = SPIInterface::new(spi, dc);

    Builder::new().connect(spi_interface);

    loop {
        log::info!("Hello world!");
        delay.delay(500.millis());
    }
}

the error I am getting:

error[E0277]: the trait bound `SPIInterface<esp_hal::spi::master::Spi<'_, esp_hal::peripherals::SPI2, FullDuplexMode>, GpioPin<18>>: display_interface::WriteOnlyDataCommand` is not satisfied
   --> src/main.rs:41:28
    |
41  |     Builder::new().connect(spi_interface);
    |                    ------- ^^^^^^^^^^^^^ the trait `display_interface::WriteOnlyDataCommand` is not implemented for `SPIInterface<esp_hal::spi::master::Spi<'_, esp_hal::peripherals::SPI2, FullDuplexMode>, GpioPin<18>>`
    |                    |
    |                    required by a bound introduced by this call
    |
help: trait impl with same name found
   --> /home/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/display-interface-spi-0.5.0/src/lib.rs:129:1
    |
129 | / impl<SPI, DC> WriteOnlyDataCommand for SPIInterface<SPI, DC>
130 | | where
131 | |     SPI: SpiDevice,
132 | |     DC: OutputPin,
    | |__________________^
    = note: perhaps two different versions of crate `display_interface` are being used?
note: required by a bound in `Builder::connect`
   --> /home/alex/.cargo/registry/src/index.crates.io-6f17d22bba15001f/ssd1309-0.4.0/src/builder.rs:96:13
    |
94  |     pub fn connect<DI>(self, interface: DI) -> DisplayMode<RawMode<DI>>
    |            ------- required by a bound in this associated function
95  |     where
96  |         DI: display_interface::WriteOnlyDataCommand,
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Builder::connect`

I bet this is the case.

1 Like

@paramagnetic thanks for the pointer. I totally missed that :frowning: I kept following the other examples, but obviously they were based on older versions. Thank you! Now at least I have a new battle plan:).

Thanks!