Crates.io | ruxafor |
lib.rs | ruxafor |
version | 1.0.0 |
source | src |
created_at | 2022-09-12 13:02:26.16873 |
updated_at | 2022-10-05 09:03:23.724336 |
description | Control luxafor light with rust |
homepage | https://www.roclub.com/ |
repository | https://github.com/roclub/ruxafor |
max_upload_size | |
id | 663735 |
size | 13,274 |
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.
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(())
}
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(())
}