#rgb-led #group #pattern #intended #sequence #timer #action

无需 std choreographer

一种用于 RGB LED 群组的颜色图案序列器

4 个版本

0.0.4 2021 年 6 月 27 日
0.0.3 2021 年 6 月 21 日
0.0.2 2021 年 6 月 20 日
0.0.1 2021 年 6 月 20 日

嵌入式开发 中排名 1899

MPL-2.0 许可证

36KB
666

Choreographer

一种用于 RGB LED 群组的颜色图案序列器

示例

查看这条推文中的视频 [链接]

use choreographer::{
    engine::{Behavior, Sequence},
    script,
};
use groundhog::std_timer::Timer;
use std::thread::sleep;
use std::time::Duration;

// Timer with 1us ticks
type MicroTimer = Timer<1_000_000>;

// Create a script for a single LED with up to
// eight different steps in the sequence
let mut script: Sequence<MicroTimer, 8> = Sequence::empty();

// This script will:
// * Keep the LED black for 1s
// * Fade from black to white and back in a sine pattern over 2.5s
// * Remain at black for 1s
// * End the sequence
script.set(&script! {
    | action |  color | duration_ms | period_ms_f | phase_offset_ms | repeat |
    |  solid |  BLACK |        1000 |         0.0 |               0 |   once |
    |    sin |  WHITE |        2500 |      2500.0 |               0 |   once |
    |  solid |  BLACK |        1000 |         0.0 |               0 |   once |
}, Behavior::OneShot);

// Poll the script and update the LED until the
// script has completed (4.5s or so)
while let Some(color) = script.poll() {
    println!("Color: {:?}", color);
    set_led(color);
    sleep(Duration::from_millis(10));
}

// Now we could leave the LED off, or set a
// new sequence on some event!

许可证

此项目采用 Mozilla 公共许可证 v2.0 许可。

依赖项

~1MB
~22K SLoC