Struct esp32_simple::light::Led

source ·
pub struct Led<'a> { /* private fields */ }
Expand description

Represents an LED with color and state control.

§Type Parameters

  • 'a - Lifetime of the LED.

Implementations§

source§

impl<'a> Led<'a>

source

pub fn new(tx_rmt: TxRmtDriver<'a>) -> Result<Self>

Creates a new Led instance.

§Arguments
  • tx_rmt - A TxRmtDriver for controlling the LED.
§Returns

A new Led initialized to off with black color.

§Errors

Returns an error if the LED cannot be initialized.

source

pub fn set_color(&mut self, color: Rgb) -> Result<()>

Sets the color of the LED.

§Arguments
  • color - The new color for the LED.
§Returns

Ok(()) on success.

§Errors

Returns an error if the color cannot be applied.

source

pub fn on(&mut self) -> Result<()>

Turns on the LED.

§Returns

Ok(()) on success.

§Errors

Returns an error if the LED cannot be turned on.

source

pub fn off(&mut self) -> Result<()>

Turns off the LED.

§Returns

Ok(()) on success.

§Errors

Returns an error if the LED cannot be turned off.

Trait Implementations§

source§

impl Switch for Led<'_>

source§

fn toggle(&mut self) -> Result<()>

Toggles the state of the LED.

§Returns

Ok(()) on success.

§Errors

Returns an error if the LED state cannot be toggled.

Auto Trait Implementations§

§

impl<'a> Freeze for Led<'a>

§

impl<'a> RefUnwindSafe for Led<'a>

§

impl<'a> Send for Led<'a>

§

impl<'a> Sync for Led<'a>

§

impl<'a> Unpin for Led<'a>

§

impl<'a> !UnwindSafe for Led<'a>

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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

§

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

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

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

Performs the conversion.