ruxafor

Crates.ioruxafor
lib.rsruxafor
version1.0.0
sourcesrc
created_at2022-09-12 13:02:26.16873
updated_at2022-10-05 09:03:23.724336
descriptionControl luxafor light with rust
homepagehttps://www.roclub.com/
repositoryhttps://github.com/roclub/ruxafor
max_upload_size
id663735
size13,274
Framtale (framtale)

documentation

README

ruxafor

This crate provides an API for controlling the luxafor light. At the current development status, this API can only control USB-connected luxafor lights. Further development (such as controlling bluetooth connected devices) is in progress. Feel free to participate.

Usage

For basic usage (e.g. switching the color of your luxafor light to red) take a look at the follwoing code block.

use ruxafor::{USBDiscovery, Color};
use hidapi::HidError;

fn main() -> Result<(), HidError> {
    let usb_discovery = USBDiscovery::new()?;
    let usb_device = usb_discovery.device()?;
    usb_device.set_static_color(Color::Red)?;
    Ok(()) 
}

Control mute button

However, if you want to check whether the mute button of the luxafor light is pressed for a period of time, you can simply use the ìs_button_pressed(timeout) method as presented in the following code block. Note that the variable timeout is measured in milliseconds.

use ruxafor::{USBDiscovery, Color};
use hidapi::HidError;

fn main() -> Result<(), HidError> {
    let usb_discovery = USBDiscovery::new()?;
    let usb_device = usb_discovery.device()?;
    if usb_device.is_button_pressed(1000, 5000) {
        // do something
    }
    Ok(())
}
Commit count: 7

cargo fmt