2 releases (1 stable)
1.0.0 | Oct 5, 2022 |
---|---|
0.1.0 | Sep 12, 2022 |
#7 in #hidapi
12KB
216 lines
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(())
}
Dependencies
~3–8MB
~80K SLoC