//! Draw the Rust logo centered on a 90 degree rotated 128x64px display //! //! Image was created with ImageMagick: //! //! ```bash //! convert rust.png -depth 1 gray:rust.raw //! ``` //! //! This example is for the STM32F103 "Blue Pill" board using I2C1. //! //! Wiring connections are as follows for a CRIUS-branded display: //! //! ``` //! Display -> Blue Pill //! (black) GND -> GND //! (red) +5V -> VCC //! (yellow) SDA -> PB7 //! (green) SCL -> PB6 //! ``` //! //! Run on a Blue Pill with `cargo run --example rotation_i2c`. #![no_std] #![no_main] use cortex_m::asm::nop; use cortex_m_rt::entry; use defmt_rtt as _; use embassy_stm32::time::Hertz; use embedded_graphics::{ image::{Image, ImageRaw}, pixelcolor::BinaryColor, prelude::*, }; use panic_probe as _; use ssd1306::{prelude::*, I2CDisplayInterface, Ssd1306}; #[entry] fn main() -> ! { let p = embassy_stm32::init(Default::default()); let i2c = embassy_stm32::i2c::I2c::new_blocking( p.I2C1, p.PB6, p.PB7, Hertz::khz(400), Default::default(), ); let interface = I2CDisplayInterface::new(i2c); let mut display = Ssd1306::new(interface, DisplaySize128x64, DisplayRotation::Rotate90) .into_buffered_graphics_mode(); display.init().unwrap(); // Contrived example to test builder and instance methods. Sets rotation to 270 degress // or 90 degress counterclockwise display.set_rotation(DisplayRotation::Rotate270).unwrap(); let (w, h) = display.dimensions(); let raw: ImageRaw = ImageRaw::new(include_bytes!("./rust.raw"), 64); let im = Image::new( &raw, Point::new(w as i32 / 2 - 64 / 2, h as i32 / 2 - 64 / 2), ); im.draw(&mut display).unwrap(); display.flush().unwrap(); loop { nop() } }