mini_oled/screen/
mod.rs

1//! # Screen
2//!
3//! This module contains the screen-related definitions, including the `Canvas` for drawing,
4//! `DisplayProperties` for configuration, and the `Sh1106` driver implementation.
5//!
6//! ## Example
7//!
8//! Initialize the display and access the canvas.
9//!
10//! ```rust,ignore
11//! use mini_oled::{
12//!     interface::i2c::I2cInterface,
13//!     screen::{properties::DisplayRotation, sh1106::Sh1106},
14//! };
15//!
16//! // let i2c = ...; // Your I2C driver
17//! let i2c_interface = I2cInterface::new(i2c, 0x3C);
18//! let mut screen = Sh1106::new(i2c_interface);
19//!
20//! screen.init().unwrap();
21//!
22//! let canvas = screen.get_mut_canvas();
23//! canvas.set_pixel(10, 10, true);
24//! screen.flush().unwrap();
25//! ```
26
27pub mod canvas;
28pub mod properties;
29pub mod sh1106;
30
31macro_rules! fast_mul {
32    ($value:expr, $right:expr) => {{
33        let value_u32 = ($value) as u32;
34        if $right > 0 && ($right & ($right - 1)) == 0 {
35            value_u32 << $right.trailing_zeros()
36        } else {
37            value_u32 * $right
38        }
39    }};
40}
41
42pub(crate) use fast_mul;