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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
//! # Clockless LED Driver Abstractions
//!
//! This module provides abstractions for driving "clockless" LED protocols, such as
//! WS2812 (NeoPixel), SK6812, and similar. These protocols use a single data line
//! with precise timing to encode bits.
//!
//! ## Clockless Protocols
//!
//! Clockless protocols encode data bits using precise pulse timings on a single data line:
//!
//! - Each bit is represented by a high pulse followed by a low pulse
//! - The duration of the high and low pulses determines whether it's a '0' or '1' bit
//! - After all bits are sent, a longer reset period is required
//!
//! ## Traits
//!
//! - [`ClocklessLed`]: Trait defining the timing parameters for a clockless LED chipset
//!
//! ## Drivers
//!
//! - [`ClocklessDelayDriver`]: Driver using GPIO bit-banging with a delay timer
//!
//! ## Example
//!
//! ```rust
//! use blinksy::{
//! color::{LedChannels, RgbChannels},
//! driver::ClocklessLed,
//! time::Nanoseconds,
//! };
//!
//! // Define a new LED chipset with specific timing requirements
//! struct MyLed;
//!
//! impl ClocklessLed for MyLed {
//! // High pulse duration for '0' bit
//! const T_0H: Nanoseconds = Nanoseconds::nanos(350);
//! // Low pulse duration for '0' bit
//! const T_0L: Nanoseconds = Nanoseconds::nanos(800);
//! // High pulse duration for '1' bit
//! const T_1H: Nanoseconds = Nanoseconds::nanos(700);
//! // Low pulse duration for '1' bit
//! const T_1L: Nanoseconds = Nanoseconds::nanos(600);
//! // Reset period
//! const T_RESET: Nanoseconds = Nanoseconds::micros(50);
//! // Color channel ordering
//! const LED_CHANNELS: LedChannels = LedChannels::Rgb(RgbChannels::RGB);
//! }
//! ```
use crateLedChannels;
use crateNanoseconds;
pub use *;
/// Trait that defines the timing parameters and protocol specifics for a clockless LED chipset.
///
/// Implementors of this trait specify the exact timing requirements for a specific
/// LED chipset that uses a clockless protocol.
///
/// # Example
///
/// ```rust
/// use fugit::NanosDurationU32 as Nanoseconds;
/// use blinksy::{color::{LedChannels, RgbChannels}, driver::ClocklessLed};
///
/// struct WS2811Led;
///
/// impl ClocklessLed for WS2811Led {
/// const T_0H: Nanoseconds = Nanoseconds::nanos(250);
/// const T_0L: Nanoseconds = Nanoseconds::nanos(1000);
/// const T_1H: Nanoseconds = Nanoseconds::nanos(600);
/// const T_1L: Nanoseconds = Nanoseconds::nanos(650);
/// const T_RESET: Nanoseconds = Nanoseconds::micros(50);
/// const LED_CHANNELS: LedChannels = LedChannels::Rgb(RgbChannels::RGB);
/// }
/// ```