Control

Struct Control 

Source
pub struct Control<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver>
where Layout: LayoutForDim<Dim>, Pattern: PatternTrait<Dim, Layout>,
{ /* private fields */ }
Expand description

Central LED control system.

A Control is made up of:

You can use Control to

  • Set a global brightness
  • Set a global color correction.
  • Send a frame of colors from the pattern to the driver.

Tip: Use ControlBuilder to build your Control struct.

Implementations§

Source§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Layout: LayoutForDim<Dim>, Pattern: PatternTrait<Dim, Layout>,

Source

pub fn new(pattern: Pattern, driver: Driver) -> Self

Creates a new control system.

§Arguments
  • pattern - The pattern to use
  • driver - The LED driver to use
§Returns

A new Control instance with default brightness

Source

pub fn set_brightness(&mut self, brightness: f32)

Sets the overall brightness level.

§Arguments
  • brightness - Brightness level from 0.0 (off) to 1.0 (full)
Source

pub fn set_color_correction(&mut self, correction: ColorCorrection)

Sets a color correction.

§Arguments
  • correction - Color correction factors
Source§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Layout, Pattern, Driver> Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Blocking, Layout, Pattern, Driver>
where Layout: LayoutForDim<Dim>, Pattern: PatternTrait<Dim, Layout>, Driver: DriverTrait, Driver::Color: FromColor<Pattern::Color>,

Source

pub fn tick(&mut self, time_in_ms: u64) -> Result<(), Driver::Error>

Updates the LED state based on the current time.

This method:

  1. Calls the pattern to generate colors
  2. Passes the colors and brightness to the driver
§Arguments
  • time_in_ms - Current time in milliseconds
§Returns

Result indicating success or an error from the driver

Source§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Layout, Pattern, Driver> Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Async, Layout, Pattern, Driver>
where Layout: LayoutForDim<Dim>, Pattern: PatternTrait<Dim, Layout>, Driver: DriverAsyncTrait, Driver::Color: FromColor<Pattern::Color>,

Source

pub async fn tick(&mut self, time_in_ms: u64) -> Result<(), Driver::Error>

Updates the LED state based on the current time, asynchronously.

This method:

  1. Calls the pattern to generate colors
  2. Passes the colors and brightness to the driver
§Arguments
  • time_in_ms - Current time in milliseconds
§Returns

Result indicating success or an error from the driver

Auto Trait Implementations§

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> Freeze for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: Freeze, Driver: Freeze,

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> RefUnwindSafe for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: RefUnwindSafe, Driver: RefUnwindSafe, Dim: RefUnwindSafe, Exec: RefUnwindSafe, Layout: RefUnwindSafe,

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> Send for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: Send, Driver: Send, Dim: Send, Exec: Send, Layout: Send,

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> Sync for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: Sync, Driver: Sync, Dim: Sync, Exec: Sync, Layout: Sync,

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> Unpin for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: Unpin, Driver: Unpin, Dim: Unpin, Exec: Unpin, Layout: Unpin,

§

impl<const PIXEL_COUNT: usize, const FRAME_BUFFER_SIZE: usize, Dim, Exec, Layout, Pattern, Driver> UnwindSafe for Control<PIXEL_COUNT, FRAME_BUFFER_SIZE, Dim, Exec, Layout, Pattern, Driver>
where Pattern: UnwindSafe, Driver: UnwindSafe, Dim: UnwindSafe, Exec: UnwindSafe, Layout: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromColor<T> for T

Source§

fn from_color(color: T) -> T

Converts from the source color type
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Converts into the target color type
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.