Added more examples.
This commit is contained in:
parent
636a1722f8
commit
4c93786f1c
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "luxafor"
|
||||
description = "Library, and CLI, for Luxafor lights via webhooks."
|
||||
description = "Library, and CLI, for Luxafor lights via either USB or webhooks."
|
||||
version = "0.2.0"
|
||||
authors = ["Simon Johnston <johnstonskj@gmail.com>"]
|
||||
repository = "https://github.com/johnstonskj/rust-luxafor"
|
||||
|
36
README.md
36
README.md
@ -1,6 +1,6 @@
|
||||
# Crate luxafor
|
||||
|
||||
Library, and CLI, for [Luxafor](https://luxafor.com/products/) lights via webhooks or USB.
|
||||
Library, and CLI, for [Luxafor](https://luxafor.com/products/) lights via either USB or webhooks.
|
||||
|
||||

|
||||

|
||||
@ -12,7 +12,39 @@ Library, and CLI, for [Luxafor](https://luxafor.com/products/) lights via webhoo
|
||||
This has been tested with the USB connected [flag](https://luxafor.com/flag-usb-busylight-availability-indicator/)
|
||||
as well as the [Bluetooth](https://luxafor.com/bluetooth-busy-light-availability-indicator/) lights.
|
||||
|
||||
## Examples
|
||||
## API Examples
|
||||
|
||||
The following example shows a function that sets the light to a solid red color. It demonstrates
|
||||
the use of a USB connected device.
|
||||
|
||||
```rust
|
||||
use luxafor::usb_hid::USBDeviceDiscovery;
|
||||
use luxafor::{Device, SolidColor};
|
||||
use luxafor::error::Result;
|
||||
|
||||
fn set_do_not_disturb() -> Result<()> {
|
||||
let discovery = USBDeviceDiscovery::new()?;
|
||||
let device = discovery.device()?;
|
||||
println!("USB device: '{}'", device.id());
|
||||
device.set_solid_color(SolidColor::Red, false)
|
||||
}
|
||||
```
|
||||
|
||||
The following shows the same function but using the webhook connection.
|
||||
|
||||
```rust
|
||||
use luxafor::webhook::new_device_for;
|
||||
use luxafor::{Device, SolidColor};
|
||||
use luxafor::error::Result;
|
||||
|
||||
fn set_do_not_disturb(device_id: &str) -> Result<()> {
|
||||
let device = new_device_for(device_id)?;
|
||||
println!("Webhook device: '{}'", device.id());
|
||||
device.set_solid_color(SolidColor::Red, false)
|
||||
}
|
||||
```
|
||||
|
||||
## CLI Examples
|
||||
|
||||
The following shows the command line tool setting the color to red.
|
||||
|
||||
|
37
src/lib.rs
37
src/lib.rs
@ -1,11 +1,44 @@
|
||||
/*!
|
||||
Library, and CLI, for [Luxafor](https://luxafor.com/products/) lights via webhooks or USB.
|
||||
Library, and CLI, for [Luxafor](https://luxafor.com/products/) lights via either USB or webhooks.
|
||||
|
||||
This has been
|
||||
tested with the USB connected [flag](https://luxafor.com/flag-usb-busylight-availability-indicator/)
|
||||
as well as the [Bluetooth](https://luxafor.com/bluetooth-busy-light-availability-indicator/) lights.
|
||||
|
||||
# Examples
|
||||
|
||||
# API Examples
|
||||
|
||||
The following example shows a function that sets the light to a solid red color. It demonstrates
|
||||
the use of a USB connected device.
|
||||
|
||||
```rust,norun
|
||||
use luxafor::usb_hid::USBDeviceDiscovery;
|
||||
use luxafor::{Device, SolidColor};
|
||||
use luxafor::error::Result;
|
||||
|
||||
fn set_do_not_disturb() -> Result<()> {
|
||||
let discovery = USBDeviceDiscovery::new()?;
|
||||
let device = discovery.device()?;
|
||||
println!("USB device: '{}'", device.id());
|
||||
device.set_solid_color(SolidColor::Red, false)
|
||||
}
|
||||
```
|
||||
|
||||
The following shows the same function but using the webhook connection.
|
||||
|
||||
```rust,norun
|
||||
use luxafor::webhook::new_device_for;
|
||||
use luxafor::{Device, SolidColor};
|
||||
use luxafor::error::Result;
|
||||
|
||||
fn set_do_not_disturb(device_id: &str) -> Result<()> {
|
||||
let device = new_device_for(device_id)?;
|
||||
println!("Webhook device: '{}'", device.id());
|
||||
device.set_solid_color(SolidColor::Red, false)
|
||||
}
|
||||
```
|
||||
|
||||
# CLI Examples
|
||||
|
||||
The following shows the command line tool setting the color to red.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user