#led-driver #rgb-led #led #sdk #linux #driver #eruption

eruption-sdk

为Linux提供Eruption实时RGB LED驱动程序的接口

2个版本

0.0.4 2022年10月8日
0.0.3 2022年10月8日

#1273 in 硬件支持

LGPL-3.0

29KB
430 代码行

eruption-sdk

Stars Stars Stars Stars

此crate为Linux的Eruption实时RGB LED驱动程序提供接口

目录

许可

Eruption SDK遵循GNU LGPL-3.0许可证

用法

请将其添加到您的 Cargo.toml

[dependencies]
eruption-sdk = "0.0.4"

MSRV

最低支持的Rust版本: Rust 1.64

示例代码

use eruption_sdk::canvas::Canvas;
use eruption_sdk::color::Color;
use eruption_sdk::connection::{Connection, ConnectionType};
use std::thread;
use std::time::Duration;

const EXAMPLE_NAME: &str = "Simple Rust Example #1";

fn main() -> Result<(), eyre::Error> {
    println!(
        "Welcome to the Eruption SDK!\nYou are running the \"{}\" \
        from the Eruption SDK version {}\n",
        EXAMPLE_NAME,
        eruption_sdk::SDK_VERSION
    );

    println!("Connecting to the Eruption daemon...");
    let connection = Connection::new(ConnectionType::Local)?;

    connection.connect()?;
    println!("Successfully connected to the Eruption daemon");

    let status = connection.get_server_status()?;
    println!("{:?}", status);

    // create a new canvas
    let mut canvas = Canvas::new();

    let red = Color::new(255, 0, 0, 128);
    let green = Color::new(0, 255, 0, 128);
    let blue = Color::new(0, 0, 255, 128);
    let final_val = Color::new(0, 0, 0, 0);

    canvas.fill(red);
    println!("Submitting canvas...");
    connection.submit_canvas(&canvas)?;

    thread::sleep(Duration::from_millis(1000));

    canvas.fill(green);
    println!("Submitting canvas...");
    connection.submit_canvas(&canvas)?;

    thread::sleep(Duration::from_millis(1000));

    canvas.fill(blue);
    println!("Submitting canvas...");
    connection.submit_canvas(&canvas)?;

    thread::sleep(Duration::from_millis(1000));

    canvas.fill(final_val);
    println!("Submitting canvas...");
    connection.submit_canvas(&canvas)?;

    println!("Exiting now");

    Ok(())
}

支持

Eruption SDK的支持可在 GitHub 上找到

依赖项

~11–19MB
~259K SLoC