Expand description
§SSD1315
SSD1315 driver.
§Usage
Here is an example of 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(0, 0), 40)
.into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
.draw(&mut display)
.unwrap();
display.init(Default::default()).unwrap();
display.flush().unwrap();Congratulations! Now you can see a small circle displayed on your OLED screen!
If you want to apply your own configuration for the SSD1315 (for example, to change the contrast), follow this example:
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::Ssd1315Config::new();
config.contrast = 0xff;
let mut display = Ssd1315::new(interface);
Circle::new(Point::new(0, 0), 40)
.into_styled(PrimitiveStyle::with_fill(BinaryColor::On))
.draw(&mut display)
.unwrap();
display.init(config).unwrap();
display.flush().unwrap();Alternatively, you can use a preset configuration provided by ssd1315:
let config = config::Ssd1315Config::preset_config();Now you can see the change in contrast!
You might also want to draw some raw image(s) manually to fit your specific requirements. That’s no problem! You can draw it/them in an easy way:
let mut display = Ssd1315::new(interface);
let raw_image = [[0b1010_1010; 128]; 8];
*display.buffer_mut() = raw_image;
display.init(Default::default()).unwrap();
display.flush().unwrap();Modules§
Structs§
- Ssd1315
- A virtual SSD1315 device that holds interface data, a buffer that maps to the actual buffer in the SSD1315 and a configuration.