SSD1331 driver

Build Status

SSD1331 display showing Ferris

SPI (4 wire) driver for the SSD1331 OLED display.

The display is configured by this driver to use a 16 bit, R5 G6 B5 pixel definition. You can convert images into the correct RAW format with the following commands (assumes 8x8 PNG input):

```bash convert ferris.png -flip -type truecolor -define bmp:subtype=RGB565 -depth 16 -strip ferris.bmp

Where 128 is (width * height * 2)

tail -c 128 ferris.bmp > ferris.raw ```

Documentation

Examples

From examples/image.rs:

```rust

![no_std]

![no_main]

extern crate cortexm; extern crate cortexmrt as rt; extern crate panicsemihosting; extern crate stm32f1xx_hal as hal;

use cortexmrt::ExceptionFrame; use cortexmrt::{entry, exception}; use embeddedgraphics::image::Image1BPP; use embeddedgraphics::prelude::; use hal::i2c::{BlockingI2c, DutyCycle, Mode}; use hal::prelude::; use hal::stm32; use ssd1331::prelude::*; use ssd1331::Builder;

[entry]

fn main() -> ! { let cp = cortex_m::Peripherals::take().unwrap(); let dp = stm32::Peripherals::take().unwrap(); let mut flash = dp.FLASH.constrain(); let mut rcc = dp.RCC.constrain(); let clocks = rcc.cfgr.freeze(&mut flash.acr); let mut afio = dp.AFIO.constrain(&mut rcc.apb2); let mut gpioa = dp.GPIOA.split(&mut rcc.apb2); let mut gpiob = dp.GPIOB.split(&mut rcc.apb2);

// SPI1
let sck = gpioa.pa5.into_alternate_push_pull(&mut gpioa.crl);
let miso = gpioa.pa6;
let mosi = gpioa.pa7.into_alternate_push_pull(&mut gpioa.crl);
let dc = gpiob.pb1.into_push_pull_output(&mut gpiob.crl);

let spi = Spi::spi1(
    dp.SPI1,
    (sck, miso, mosi),
    &mut afio.mapr,
    Mode {
        polarity: Polarity::IdleLow,
        phase: Phase::CaptureOnFirstTransition,
    },
    8.mhz(),
    clocks,
    &mut rcc.apb2,
);

let mut disp: GraphicsMode<_> = Builder::new().connect_spi(spi, dc).into();

disp.init().unwrap();
disp.flush().unwrap();

let im = Image1BPP::new(include_bytes!("./ferris.raw"), 86, 64).translate(Coord::new(5, 0));

disp.draw(im.into_iter());
disp.flush().unwrap();

loop {}

}

[exception]

fn HardFault(ef: &ExceptionFrame) -> ! { panic!("{:#?}", ef); }

```

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.