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
//! [](https://crates.io/crates/open_dmx) [](https://docs.rs/open_dmx) []()
//!
//! A wrapper around the [**serial**] library to send **DMX data** over a [SerialPort].
//!
//! <br>
//!
//! ## Usage
//!
//! ```rust
//! use open_dmx::DMXSerial;
//!
//! fn main() {
//! let mut dmx = DMXSerial::open("COM3").unwrap();
//! dmx.set_channels([255; 512]);
//! dmx.set_channel(1, 0).unwrap();
//! }
//! ```
//!
//! <br>
//!
//! ## Feature flags
//!
//! - `thread_priority` *(enabled by default)*- Tries to set the [thread] priority of the [SerialPort] to *`MAX`*
//!
//! [**serial**]: https://dcuddeback.github.io/serial-rs/serial/
//! [SerialPort]: https://dcuddeback.github.io/serial-rs/serial_core/trait.SerialPort
//! [thread]: std::thread
//!
pub use *;
/// The fixed amount **DMX channels** for a singe [Interface]
///
/// [Interface]: DMXSerial
///
pub const DMX_CHANNELS: usize = 512;
/// Checks if a given [usize] is a valid **DMX channel**.
///
/// The size of a **DMX universe** is `512` channels. *(1-512)* Everything else will be considerd invalid.
///
/// # Example
///
/// ```
/// use open_dmx::check_valid_channel;
///
/// // Valid channels
/// assert!(check_valid_channel(1).is_ok());
/// assert!(check_valid_channel(512).is_ok());
///
/// // Invalid channels
/// assert!(check_valid_channel(0).is_err());
/// assert!(check_valid_channel(513).is_err());
///
/// ```
///
/// # Errors
///
/// Returns an [`DMXChannelValidityError`] if the channel is not valid.
///
/// - [`DMXChannelValidityError::TooLow`] if the channel is lower than `1`.
///
/// - [`DMXChannelValidityError::TooHigh`] if the channel is higher than `512`.
///
/// [DMXChannelValidityError]: error::DMXChannelValidityError
/// [`DMXChannelValidityError`]: error::DMXChannelValidityError
/// [`DMXChannelValidityError::TooLow`]: error::DMXChannelValidityError::TooLow
/// [`DMXChannelValidityError::TooHigh`]: error::DMXChannelValidityError::TooHigh