use super::CapabilityBase;
use crate::{Color, Error};
use dbus_message_parser::Value;
#[derive(Debug, Clone)]
pub struct ReactiveEffect(pub(crate) CapabilityBase);
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
pub enum Speed {
Fast = 1,
Medium = 2,
Slow = 3,
VerySlow = 4,
}
impl ReactiveEffect {
pub(crate) const INTERFACE: &'static str = "razer.device.lighting.chroma";
pub(crate) const METHOD: &'static str = "setReactive";
pub async fn set(&self, (red, green, blue): Color, speed: Speed) -> Result<(), Error> {
self.0
.call_set_method(
Self::INTERFACE,
Self::METHOD,
vec![
Value::Byte(red),
Value::Byte(green),
Value::Byte(blue),
Value::Byte(speed as u8),
],
)
.await
}
pub async fn fast(&self, color: Color) -> Result<(), Error> {
self.set(color, Speed::Fast).await
}
pub async fn medium(&self, color: Color) -> Result<(), Error> {
self.set(color, Speed::Medium).await
}
pub async fn slow(&self, color: Color) -> Result<(), Error> {
self.set(color, Speed::Slow).await
}
pub async fn very_slow(&self, color: Color) -> Result<(), Error> {
self.set(color, Speed::VerySlow).await
}
}