1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
// SPDX-FileCopyrightText: 2026 Tod Kurt
// SPDX-License-Identifier: MIT
//! Control the [blink(1)](https://blink1.thingm.com/) USB RGB LED.
//!
//! A small synchronous API over `hidapi`, aimed at wiring a blink(1) into
//! alerting: red when the build breaks, green when it passes, dark when the
//! thing that was watching stops running.
//!
//! # Light it up
//!
//! ```no_run
//! use blink1rs::{Blink1, Color};
//! use std::time::Duration;
//!
//! let mut b = Blink1::open()?;
//! b.fade(Color::RED, Duration::from_millis(500))?;
//! std::thread::sleep(Duration::from_secs(1));
//! b.off()?;
//! # Ok::<(), blink1rs::Error>(())
//! ```
//!
//! # Watchdog
//!
//! The device can change its own colour when you stop talking to it, which
//! is the part a desktop notification cannot do. Arm it, then tickle it from
//! your health-check loop; if the loop dies, the light goes red on its own.
//!
//! ```no_run
//! use blink1rs::{Blink1, Color, OnTimeout};
//! use std::time::Duration;
//!
//! let mut b = Blink1::open()?;
//! b.set(Color::GREEN)?;
//! b.write_pattern_line(0, Color::RED, Duration::from_millis(200), blink1rs::Led::All)?;
//! b.watchdog_enable(Duration::from_secs(30), OnTimeout::PlayPattern { start: 0, end: 0 })?;
//!
//! loop {
//! // ... check whatever you are watching ...
//! b.watchdog_tickle()?;
//! std::thread::sleep(Duration::from_secs(10));
//! }
//! # Ok::<(), blink1rs::Error>(())
//! ```
//!
//! # Several devices
//!
//! [`Blink1::list`] sorts by serial number, the same order `blink1-tool -d N`
//! uses, so indices agree between the two.
//!
//! ```no_run
//! use blink1rs::Blink1;
//!
//! for info in Blink1::list()? {
//! println!("{} ({})", info.serial, info.kind);
//! }
//! # Ok::<(), blink1rs::Error>(())
//! ```
//!
//! # Colours are sent as given
//!
//! Unlike `blink1-tool`, gamma correction is off by default, so `#ff8000` is
//! the byte triple the device receives and
//! [`read_rgb`](Blink1::read_rgb) gives it straight back. Turn it on with
//! [`set_gamma`](Blink1::set_gamma) to match `blink1-tool`'s appearance.
//!
//! # Threads
//!
//! [`Blink1`] is `Send` but not `Sync`: move it into a thread, or share one
//! behind a `Mutex`.
pub use Color;
pub use ;
pub use ;
pub use ;