#blink #led #light #api #usb #usb-device #blink-1

bin+lib blinkrs

A small api for interacting with blink(1) LED lights

8 releases (5 stable)

2.0.1 Feb 12, 2022
2.0.0 Jan 20, 2022
1.0.2 Jul 15, 2021
1.0.1 Nov 30, 2020
0.1.0 Sep 27, 2019

#1604 in Hardware support


Used in 2 crates (via transition)

MIT license

15KB
312 lines

blink(rs)

ci.img docs.img

A rust cli tool for controlling the blink(1) USB LED light.

Example

use std::boxed::Box;
use std::error::Error;

use blinkrs::{Blinkers, Message};

fn main() -> Result<(), Box<dyn Error>> {
    let blinkers: Blinkers = match Blinkers::new() {
        Ok(b) => b,
        Err(_e) => {
            println!("unable to find device");
            return Ok(())
        },
    };
    blinkers.send(Message::from("red"))?;
    blinkers.send(Message::from("off"))?;
    Ok(())
}

Contributing

See CONTRIBUTING.


lib.rs:

This crate provides a lightweight wrapper around the rusb crate specifically targeting the API of a blink(1) usb device.

Example

use std::boxed::Box;
use std::error::Error;

use blinkrs::{Blinkers, Message};

fn main() -> Result<(), Box<dyn Error>> {
    let blinkers: Blinkers = match Blinkers::new() {
        Ok(b) => b,
        Err(_e) => {
            println!("unable to find device");
            return Ok(())
        },
    };
    blinkers.send(Message::from("red"))?;
    blinkers.send(Message::from("off"))?;
    Ok(())
}

Extending The blink(1) Device

The blink(1) device supports the control of additional lights by using three connections (ground, power, and data) exposed under the "diffuser" cap of the enclosure. A tutorial for adding a Neopixel strip can be found in this blog post.

To accomodate these setups, the Message kind carries an optional "index" -

use blinkrs::{Message,Color};
Message::Immediate(Color::from("red"), Some(10));

Dependencies

~1.5MB
~33K SLoC