#![no_std]
#![no_main]
use embedded_graphics::{
mono_font::{ ascii::FONT_6X10, MonoTextStyleBuilder },
pixelcolor::BinaryColor,
prelude::*,
text::{ Baseline, Text },
};
use hal::{ clock::ClockControl, peripherals, prelude::*, Delay, i2c::I2C, IO, spi::SpiMode };
use esp_backtrace as _;
use esp_println::println;
use ssd1306::{ prelude::*, I2CDisplayInterface, Ssd1306 };
#[entry]
fn main() -> ! {
let peripherals = peripherals::Peripherals::take();
let system = peripherals.SYSTEM.split();
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
let io = IO::new(peripherals.GPIO, peripherals.IO_MUX);
let mut delay = Delay::new(&clocks);
println!("Hello, console!");
let mut i2c = I2C::new(
peripherals.I2C0,
io.pins.gpio21,
io.pins.gpio22,
(400u32).kHz(),
&clocks
);
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();
Text::with_baseline("Hello Rust!", Point::new(0, 16), text_style, Baseline::Top)
.draw(&mut display)
.unwrap();
// Spam some characters to the display
for c in 97..123 {
let _ = display.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) });
}
for c in 65..91 {
let _ = display.write_str(unsafe { core::str::from_utf8_unchecked(&[c]) });
}
display.flush().unwrap();
loop {
}
}
Loading
esp32-c6-devkitc-1
esp32-c6-devkitc-1