Struct BleLedDevice

Source
pub struct BleLedDevice {
    pub is_on: bool,
    pub rgb_color: (u8, u8, u8),
    pub brightness: u8,
    pub effect: Option<u8>,
    pub effect_speed: Option<u8>,
    pub color_temp_kelvin: Option<u32>,
    /* private fields */
}
Expand description

Main struct for controlling an LED strip via Bluetooth LE

Fields§

§is_on: bool

Current power state

§rgb_color: (u8, u8, u8)

Current RGB color (red, green, blue)

§brightness: u8

Current brightness (0-100)

§effect: Option<u8>

Current effect mode if active

§effect_speed: Option<u8>

Current effect speed if an effect is active

§color_temp_kelvin: Option<u32>

Current color temperature in Kelvin if using white mode

Implementations§

Source§

impl BleLedDevice

Source

pub async fn new() -> Result<BleLedDevice>

Creates a new instance by scanning for and connecting to a compatible LED strip and automatically powers it on

Source

pub async fn new_without_power() -> Result<BleLedDevice>

Creates a new instance by scanning for and connecting to a compatible LED strip without automatically powering it on

Source

pub fn get_device_type_name(&self) -> &'static str

Get the device type name as string

Source

pub async fn set_custom_time( &self, hour: u8, minute: u8, second: u8, day_of_week: u8, ) -> Result<()>

Sets a custom time on the device

§Arguments
  • hour - Hour (0-23)
  • minute - Minute (0-59)
  • second - Second (0-59)
  • day_of_week - Day of week (1-7, where 1 is Monday)
Source

pub async fn power_on(&mut self) -> Result<()>

Turns the LED strip on

Source

pub async fn power_off(&mut self) -> Result<()>

Turns the LED strip off

Source

pub async fn set_color( &mut self, red_value: u8, green_value: u8, blue_value: u8, ) -> Result<()>

Sets the RGB color of the LED strip

§Arguments
  • red_value - Red component (0-255)
  • green_value - Green component (0-255)
  • blue_value - Blue component (0-255)
Source

pub async fn set_brightness(&mut self, value: u8) -> Result<()>

Sets the brightness level

§Arguments
  • value - Brightness level (0-100)
Source

pub async fn set_effect(&mut self, value: u8) -> Result<()>

Sets a light effect mode

§Arguments
  • value - Effect code (use the EFFECTS constant)
Source

pub async fn set_effect_speed(&mut self, value: u8) -> Result<()>

Sets the speed of the current effect

§Arguments
  • value - Effect speed (0-100)
Source

pub async fn set_color_temp_kelvin(&mut self, value: u32) -> Result<()>

Sets the color temperature in Kelvin for white light

§Arguments
  • value - Color temperature in Kelvin (typically 2700-6500)
Source

pub async fn set_schedule_on( &self, days: u8, hours: u8, minutes: u8, enabled: bool, ) -> Result<()>

Sets a schedule to turn on the device

§Arguments
  • days - Bitmask of days (use the WEEK_DAYS constants)
  • hours - Hour to turn on (0-23)
  • minutes - Minute to turn on (0-59)
  • enabled - Whether to enable or disable this schedule
Source

pub async fn set_schedule_off( &self, days: u8, hours: u8, minutes: u8, enabled: bool, ) -> Result<()>

Sets a schedule to turn off the device

§Arguments
  • days - Bitmask of days (use the WEEK_DAYS constants)
  • hours - Hour to turn off (0-23)
  • minutes - Minute to turn off (0-59)
  • enabled - Whether to enable or disable this schedule
Source

pub async fn generic_command( &self, id: u8, sub_id: u8, arg1: u8, arg2: u8, arg3: u8, ) -> Result<()>

Sends a generic command to the device with retries

§Arguments
  • id - Command ID
  • sub_id - Sub command ID
  • arg1 - First argument
  • arg2 - Second argument
  • arg3 - Third argument

Auto Trait Implementations§

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<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,