Crates.io | ssd1327-i2c |
lib.rs | ssd1327-i2c |
version | 0.2.0 |
source | src |
created_at | 2023-11-24 18:31:02.034225 |
updated_at | 2023-11-24 18:31:02.034225 |
description | SSD1327 I2C Driver |
homepage | |
repository | https://github.com/Hugogo22/ssd1327-i2c |
max_upload_size | |
id | 1047285 |
size | 28,462 |
no_std
I2C Driver for SSD1327 Oled screens.
The graphics
feature implements the embedded-graphics DrawTarget
trait for the SSD1327 Oled screen.
Tested on an ESP32.
Following code shows how to flash a SSD1327 screen using the ESP HAL I2C Peripheral Driver.
// Create a new peripheral object with the described wiring
// and standard I2C clock speed
let i2c = I2C::new(
peripherals.I2C0,
sda,
scl,
100u32.kHz(),
&clocks,
);
// Create a new SSD1327I2C object with slave address 0x3C, width 127 and height 127
let mut driver = ssd1327_i2c::SSD1327I2C::new(i2c);
driver.init();
loop {
driver.send_cmd(ssd1327_i2c::Commands::DisplayModeAllON);
delay.delay_ms(1000u32);
driver.send_cmd(ssd1327_i2c::Commands::DisplayModeAllOFF);
delay.delay_ms(1000u32);
}
Following code shows how to write Hello rust!
to a SSD1327 screen using the ESP HAL I2C Peripheral Driver.
// Create a new peripheral object with the described wiring
// and standard I2C clock speed
let i2c = I2C::new(
peripherals.I2C0,
sda,
scl,
100u32.kHz(),
&clocks,
);
// Create a new SSD1327I2C object with slave address 0x3C, width 127 and height 127
let mut driver = ssd1327_i2c::SSD1327I2C::new(i2c);
driver.init();
// Create a new character style
let style = MonoTextStyle::new(&FONT_6X10, Gray4::WHITE);
// Create a text at position (10, 10) and draw it using the previously defined style
Text::new("Hello rust!", Point::new(10, 10), style).draw(&mut driver).unwrap();
loop {}