| Crates.io | myrtio-light-composer |
| lib.rs | myrtio-light-composer |
| version | 0.6.7 |
| created_at | 2025-12-20 14:56:21.727381+00 |
| updated_at | 2026-01-04 21:48:14.965289+00 |
| description | 1D LED rendering library |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1996612 |
| size | 99,972 |
1D LED rendering library for Rust, designed for embedded systems (no_std friendly).
no_std. Uses embassy-time for time primitives.critical-section.Instant::now() — callers provide the current time, enabling use across different runtimes.IntentChannel) to control the renderer from any context.use myrtio_light_composer::{
Duration, EffectId, FilterProcessorConfig, Instant, IntentChannel,
LightChangeIntent, LightEngineConfig, LightStateIntent, Renderer, Rgb,
TransitionTimings, bounds::RenderingBounds, filter::BrightnessFilterConfig,
};
// 1. Create communication channel (static for 'static lifetime)
static INTENTS: IntentChannel<16> = IntentChannel::new();
// 2. Configure the engine
let config = LightEngineConfig {
effect: EffectId::Rainbow,
bounds: RenderingBounds { start: 0, end: 60 },
timings: TransitionTimings {
fade_out: Duration::from_millis(200),
fade_in: Duration::from_millis(150),
color_change: Duration::from_millis(100),
brightness: Duration::from_millis(100),
},
filters: FilterProcessorConfig {
brightness: BrightnessFilterConfig {
min_brightness: 0,
scale: 255,
adjust: None,
},
color_correction: Rgb::new(255, 255, 255),
},
brightness: 255,
color: Rgb::new(255, 180, 100),
};
// 3. Initialize renderer
let receiver = INTENTS.receiver();
let mut renderer = Renderer::<60, 16>::new(receiver, &config);
// 4. Send commands (from anywhere - thread/interrupt safe)
let sender = INTENTS.sender();
let _ = sender.try_send(LightChangeIntent::State(LightStateIntent {
brightness: Some(255),
color: Some(Rgb::new(255, 0, 0)),
..Default::default()
}));
// 5. Render loop (caller provides timing)
let mut time_ms: u64 = 0;
loop {
let now = Instant::from_millis(time_ms);
let frame = renderer.render(now);
ws2812.write(frame);
// Platform-specific delay (e.g., embassy Timer, std::thread::sleep, busy-wait)
delay_ms(16);
time_ms += 16;
}
To run the interactive desktop preview:
cargo run --manifest-path preview/Cargo.toml