31 lines
781 B
Rust
31 lines
781 B
Rust
use embedded_graphics::{
|
|
mono_font::{ascii::FONT_6X10, MonoTextStyleBuilder},
|
|
pixelcolor::BinaryColor,
|
|
prelude::*,
|
|
text::{Baseline, Text},
|
|
};
|
|
use linux_embedded_hal::I2cdev;
|
|
use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306};
|
|
|
|
fn main() {
|
|
let i2c = I2cdev::new("/dev/i2c-1").unwrap();
|
|
let interface = I2CDisplayInterface::new(i2c);
|
|
let mut display = Ssd1306::new(
|
|
interface,
|
|
DisplaySize128x64,
|
|
DisplayRotation::Rotate0,
|
|
).into_buffered_graphics_mode();
|
|
display.init().unwrap();
|
|
|
|
let text_style = MonoTextStyleBuilder::new()
|
|
.font(&FONT_6X10)
|
|
.text_color(BinaryColor::On)
|
|
.build();
|
|
|
|
Text::with_baseline("Hello world!", Point::zero(), text_style, Baseline::Top)
|
|
.draw(&mut display)
|
|
.unwrap();
|
|
|
|
display.flush().unwrap();
|
|
}
|