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
impl BleLedDevice
Sourcepub async fn new() -> Result<BleLedDevice>
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
Sourcepub async fn new_without_power() -> Result<BleLedDevice>
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
Sourcepub fn get_device_type_name(&self) -> &'static str
pub fn get_device_type_name(&self) -> &'static str
Get the device type name as string
Sourcepub async fn set_custom_time(
&self,
hour: u8,
minute: u8,
second: u8,
day_of_week: u8,
) -> Result<()>
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)
Sourcepub async fn set_color(
&mut self,
red_value: u8,
green_value: u8,
blue_value: u8,
) -> Result<()>
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)
Sourcepub async fn set_brightness(&mut self, value: u8) -> Result<()>
pub async fn set_brightness(&mut self, value: u8) -> Result<()>
Sourcepub async fn set_effect(&mut self, value: u8) -> Result<()>
pub async fn set_effect(&mut self, value: u8) -> Result<()>
Sourcepub async fn set_effect_speed(&mut self, value: u8) -> Result<()>
pub async fn set_effect_speed(&mut self, value: u8) -> Result<()>
Sourcepub async fn set_color_temp_kelvin(&mut self, value: u32) -> Result<()>
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)
Sourcepub async fn set_schedule_on(
&self,
days: u8,
hours: u8,
minutes: u8,
enabled: bool,
) -> Result<()>
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
Sourcepub async fn set_schedule_off(
&self,
days: u8,
hours: u8,
minutes: u8,
enabled: bool,
) -> Result<()>
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
Auto Trait Implementations§
impl Freeze for BleLedDevice
impl !RefUnwindSafe for BleLedDevice
impl Send for BleLedDevice
impl Sync for BleLedDevice
impl Unpin for BleLedDevice
impl !UnwindSafe for BleLedDevice
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