pub struct Pixels<I2C> { /* private fields */ }Expand description
Driver for the Modulino Pixels module.
§Example
ⓘ
use modulino::{Pixels, Color};
let mut pixels = Pixels::new(i2c)?;
// Set individual LED
pixels.set_color(0, Color::RED, 50)?;
// Set all LEDs to the same color
pixels.set_all_color(Color::BLUE, 25)?;
// Apply changes
pixels.show()?;
// Clear all LEDs
pixels.clear_all()?;
pixels.show()?;Implementations§
Source§impl<I2C, E> Pixels<I2C>where
I2C: I2c<Error = E>,
impl<I2C, E> Pixels<I2C>where
I2C: I2c<Error = E>,
Sourcepub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
pub fn new_with_address(i2c: I2C, address: u8) -> Result<Self, E>
Create a new Pixels instance with a custom address.
Sourcepub fn set_color(
&mut self,
index: usize,
color: Color,
brightness: u8,
) -> Result<&mut Self, E>
pub fn set_color( &mut self, index: usize, color: Color, brightness: u8, ) -> Result<&mut Self, E>
Set the color of a specific LED.
§Arguments
index- LED index (0-7)color- The color to setbrightness- Brightness level (0-100)
Sourcepub fn set_rgb(
&mut self,
index: usize,
r: u8,
g: u8,
b: u8,
brightness: u8,
) -> Result<&mut Self, E>
pub fn set_rgb( &mut self, index: usize, r: u8, g: u8, b: u8, brightness: u8, ) -> Result<&mut Self, E>
Set the color of a specific LED using RGB values.
§Arguments
index- LED index (0-7)r- Red component (0-255)g- Green component (0-255)b- Blue component (0-255)brightness- Brightness level (0-100)
Sourcepub fn set_brightness(
&mut self,
index: usize,
brightness: u8,
) -> Result<&mut Self, E>
pub fn set_brightness( &mut self, index: usize, brightness: u8, ) -> Result<&mut Self, E>
Set the brightness of a specific LED without changing its color.
§Arguments
index- LED index (0-7)brightness- Brightness level (0-100)
Sourcepub fn set_all_color(&mut self, color: Color, brightness: u8) -> &mut Self
pub fn set_all_color(&mut self, color: Color, brightness: u8) -> &mut Self
Set the color of all LEDs.
Sourcepub fn set_all_rgb(&mut self, r: u8, g: u8, b: u8, brightness: u8) -> &mut Self
pub fn set_all_rgb(&mut self, r: u8, g: u8, b: u8, brightness: u8) -> &mut Self
Set all LEDs to the same RGB color.
Sourcepub fn set_range_color(
&mut self,
from: usize,
to: usize,
color: Color,
brightness: u8,
) -> &mut Self
pub fn set_range_color( &mut self, from: usize, to: usize, color: Color, brightness: u8, ) -> &mut Self
Set the color of a range of LEDs.
§Arguments
from- Starting index (inclusive)to- Ending index (inclusive)color- The color to setbrightness- Brightness level (0-100)
Sourcepub fn set_all_brightness(&mut self, brightness: u8) -> &mut Self
pub fn set_all_brightness(&mut self, brightness: u8) -> &mut Self
Set the brightness of all LEDs without changing their colors.
Sourcepub fn clear_range(&mut self, from: usize, to: usize) -> &mut Self
pub fn clear_range(&mut self, from: usize, to: usize) -> &mut Self
Clear a range of LEDs.
Sourcepub fn show(&mut self) -> Result<(), E>
pub fn show(&mut self) -> Result<(), E>
Apply the current LED states to the hardware.
This must be called after setting colors for changes to take effect.
Auto Trait Implementations§
impl<I2C> Freeze for Pixels<I2C>where
I2C: Freeze,
impl<I2C> RefUnwindSafe for Pixels<I2C>where
I2C: RefUnwindSafe,
impl<I2C> Send for Pixels<I2C>where
I2C: Send,
impl<I2C> Sync for Pixels<I2C>where
I2C: Sync,
impl<I2C> Unpin for Pixels<I2C>where
I2C: Unpin,
impl<I2C> UnwindSafe for Pixels<I2C>where
I2C: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more