Crate ssd1315

source ·
Expand description

§SSD1315

SSD1315 driver.

§Usage

Here is an example about how to use ssd1315:

use ssd1315::*;
use embedded_graphics::{
    pixelcolor::BinaryColor,
    prelude::*,
    primitives::{Circle, PrimitiveStyle},
};

let interface = interface::I2cDisplayInterface::new(i2c);
// let interface = interface::SpiDisplayInterface::new(spi, dc);

let mut display = Ssd1315::new(interface);

Circle::new(Point::new(1, 1), 40)
        .into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
        .draw(&mut display)
        .unwrap();

display.init_screen();
display.flush_screen();

Congratulations! Now you can see a little circle that is displaying on your OLED screen!

If you want to apply your own config for SSD1315 when it is initializing, follow this example (we assume that you want to change the contrast of the OLED screen):

use ssd1315::*;
use embedded_graphics::{
    pixelcolor::BinaryColor,
    prelude::*,
    primitives::{Circle, PrimitiveStyle},
};

let interface = interface::I2cDisplayInterface::new(i2c);
// let interface = interface::SpiDisplayInterface::new(spi, dc);

let mut config = config::Ssd1315DisplayConfig::new();
config.contrast = 0xff;

let mut display = Ssd1315::new(interface);
display.set_custom_config(config);

Circle::new(Point::new(1, 1), 40)
        .into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
        .draw(&mut display)
        .unwrap();

display.init_screen();
display.flush_screen();

Or use a pre-set config that was provided by ssd1315:

let config = config::Ssd1315DisplayConfig::preset_config();

Now you can see the change of contrast!

You might also want to draw some raw image(s) manually to fit your specific requirements. That’s no matter! You can draw it/them in an easy way:

let mut display = Ssd1315::new(interface);

let raw_image = [[0b1010_1010; 8]; 128];
raw_image.draw_from_raw(&mut display);

display.init_screen();
display.flush_screen();

Modules§

Structs§

  • A virtal SSD1315 device that holds an interface data and a buffer that maps to the actual buffer in the SSD1315.

Traits§