mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
Update readme, slash configs
This commit is contained in:
@@ -19,7 +19,7 @@ pub enum LedBrightness {
|
||||
Low = 1,
|
||||
#[default]
|
||||
Med = 2,
|
||||
High = 3,
|
||||
High = 3
|
||||
}
|
||||
|
||||
impl LedBrightness {
|
||||
@@ -28,7 +28,7 @@ impl LedBrightness {
|
||||
Self::Off => Self::Low,
|
||||
Self::Low => Self::Med,
|
||||
Self::Med => Self::High,
|
||||
Self::High => Self::Off,
|
||||
Self::High => Self::Off
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ impl LedBrightness {
|
||||
Self::Off => Self::High,
|
||||
Self::Low => Self::Off,
|
||||
Self::Med => Self::Low,
|
||||
Self::High => Self::Med,
|
||||
Self::High => Self::Med
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ impl From<u8> for LedBrightness {
|
||||
0 => LedBrightness::Off,
|
||||
1 => LedBrightness::Low,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med,
|
||||
_ => LedBrightness::Med
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,7 @@ impl From<i32> for LedBrightness {
|
||||
1 => LedBrightness::Low,
|
||||
2 => LedBrightness::Med,
|
||||
3 => LedBrightness::High,
|
||||
_ => LedBrightness::Med,
|
||||
_ => LedBrightness::Med
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,7 +82,7 @@ impl From<i32> for LedBrightness {
|
||||
pub struct Colour {
|
||||
pub r: u8,
|
||||
pub g: u8,
|
||||
pub b: u8,
|
||||
pub b: u8
|
||||
}
|
||||
|
||||
impl Default for Colour {
|
||||
@@ -110,14 +110,18 @@ impl From<&[f32; 3]> for Colour {
|
||||
Self {
|
||||
r: (255.0 * c[0]) as u8,
|
||||
g: (255.0 * c[1]) as u8,
|
||||
b: (255.0 * c[2]) as u8,
|
||||
b: (255.0 * c[2]) as u8
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Colour> for [f32; 3] {
|
||||
fn from(c: Colour) -> Self {
|
||||
[c.r as f32 / 255.0, c.g as f32 / 255.0, c.b as f32 / 255.0]
|
||||
[
|
||||
c.r as f32 / 255.0,
|
||||
c.g as f32 / 255.0,
|
||||
c.b as f32 / 255.0
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,14 +130,16 @@ impl From<&[u8; 3]> for Colour {
|
||||
Self {
|
||||
r: c[0],
|
||||
g: c[1],
|
||||
b: c[2],
|
||||
b: c[2]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Colour> for [u8; 3] {
|
||||
fn from(c: Colour) -> Self {
|
||||
[c.r, c.g, c.b]
|
||||
[
|
||||
c.r, c.g, c.b
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,7 +153,7 @@ pub enum Speed {
|
||||
Low = 0xe1,
|
||||
#[default]
|
||||
Med = 0xeb,
|
||||
High = 0xf5,
|
||||
High = 0xf5
|
||||
}
|
||||
|
||||
impl FromStr for Speed {
|
||||
@@ -159,7 +165,7 @@ impl FromStr for Speed {
|
||||
"low" => Ok(Speed::Low),
|
||||
"med" => Ok(Speed::Med),
|
||||
"high" => Ok(Speed::High),
|
||||
_ => Err(Error::ParseSpeed),
|
||||
_ => Err(Error::ParseSpeed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -169,7 +175,7 @@ impl From<i32> for Speed {
|
||||
match value {
|
||||
0 => Self::Low,
|
||||
2 => Self::High,
|
||||
_ => Self::Med,
|
||||
_ => Self::Med
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -179,7 +185,7 @@ impl From<Speed> for i32 {
|
||||
match value {
|
||||
Speed::Low => 0,
|
||||
Speed::Med => 1,
|
||||
Speed::High => 2,
|
||||
Speed::High => 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +195,7 @@ impl From<Speed> for u8 {
|
||||
match s {
|
||||
Speed::Low => 0,
|
||||
Speed::Med => 1,
|
||||
Speed::High => 2,
|
||||
Speed::High => 2
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,7 +213,7 @@ pub enum Direction {
|
||||
Right = 0,
|
||||
Left = 1,
|
||||
Up = 2,
|
||||
Down = 3,
|
||||
Down = 3
|
||||
}
|
||||
|
||||
impl FromStr for Direction {
|
||||
@@ -220,7 +226,7 @@ impl FromStr for Direction {
|
||||
"up" => Ok(Direction::Up),
|
||||
"down" => Ok(Direction::Down),
|
||||
"left" => Ok(Direction::Left),
|
||||
_ => Err(Error::ParseDirection),
|
||||
_ => Err(Error::ParseDirection)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -231,7 +237,7 @@ impl From<i32> for Direction {
|
||||
1 => Self::Left,
|
||||
2 => Self::Up,
|
||||
3 => Self::Down,
|
||||
_ => Self::Right,
|
||||
_ => Self::Right
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -264,7 +270,7 @@ pub enum AuraModeNum {
|
||||
Ripple = 8,
|
||||
Pulse = 10,
|
||||
Comet = 11,
|
||||
Flash = 12,
|
||||
Flash = 12
|
||||
}
|
||||
|
||||
impl Display for AuraModeNum {
|
||||
@@ -293,7 +299,7 @@ impl From<&AuraModeNum> for &str {
|
||||
AuraModeNum::Ripple => "Ripple",
|
||||
AuraModeNum::Pulse => "Pulse",
|
||||
AuraModeNum::Comet => "Comet",
|
||||
AuraModeNum::Flash => "Flash",
|
||||
AuraModeNum::Flash => "Flash"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -311,7 +317,7 @@ impl From<&str> for AuraModeNum {
|
||||
"Pulse" => AuraModeNum::Pulse,
|
||||
"Comet" => AuraModeNum::Comet,
|
||||
"Flash" => AuraModeNum::Flash,
|
||||
_ => AuraModeNum::Static,
|
||||
_ => AuraModeNum::Static
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,7 +336,7 @@ impl From<u8> for AuraModeNum {
|
||||
10 => AuraModeNum::Pulse,
|
||||
11 => AuraModeNum::Comet,
|
||||
12 => AuraModeNum::Flash,
|
||||
_ => AuraModeNum::Static,
|
||||
_ => AuraModeNum::Static
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -377,7 +383,7 @@ pub enum AuraZone {
|
||||
/// The left part of a lightbar (typically on the front of laptop)
|
||||
BarLeft = 6,
|
||||
/// The right part of a lightbar
|
||||
BarRight = 7,
|
||||
BarRight = 7
|
||||
}
|
||||
|
||||
impl FromStr for AuraZone {
|
||||
@@ -394,7 +400,7 @@ impl FromStr for AuraZone {
|
||||
"5" | "logo" => Ok(AuraZone::Logo),
|
||||
"6" | "lightbar-left" => Ok(AuraZone::BarLeft),
|
||||
"7" | "lightbar-right" => Ok(AuraZone::BarRight),
|
||||
_ => Err(Error::ParseSpeed),
|
||||
_ => Err(Error::ParseSpeed)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -409,7 +415,7 @@ impl From<i32> for AuraZone {
|
||||
5 => Self::Logo,
|
||||
6 => Self::BarLeft,
|
||||
7 => Self::BarRight,
|
||||
_ => Self::default(),
|
||||
_ => Self::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -439,7 +445,7 @@ pub struct AuraEffect {
|
||||
/// One of three speeds for modes that support speed (most that animate)
|
||||
pub speed: Speed,
|
||||
/// Up, down, left, right. Only Rainbow mode seems to use this
|
||||
pub direction: Direction,
|
||||
pub direction: Direction
|
||||
}
|
||||
|
||||
impl AuraEffect {
|
||||
@@ -475,7 +481,7 @@ impl Default for AuraEffect {
|
||||
colour1: Colour { r: 166, g: 0, b: 0 },
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right,
|
||||
direction: Direction::Right
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -535,7 +541,7 @@ impl From<&AuraEffect> for Vec<u8> {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN,
|
||||
AuraEffect, AuraModeNum, AuraZone, Colour, Direction, Speed, AURA_LAPTOP_LED_MSG_LEN
|
||||
};
|
||||
|
||||
#[test]
|
||||
@@ -546,18 +552,18 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0x11,
|
||||
b: 0xdd,
|
||||
b: 0xdd
|
||||
},
|
||||
colour2: Colour::default(),
|
||||
speed: Speed::Med,
|
||||
direction: Direction::Right,
|
||||
direction: Direction::Right
|
||||
};
|
||||
let ar = <[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st);
|
||||
|
||||
println!("{:02x?}", ar);
|
||||
let check = [
|
||||
0x5d, 0xb3, 0x0, 0x0, 0xff, 0x11, 0xdd, 0xeb, 0x0, 0x0, 0xa6, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0,
|
||||
0x0
|
||||
];
|
||||
assert_eq!(ar, check);
|
||||
}
|
||||
@@ -570,15 +576,15 @@ mod tests {
|
||||
colour1: Colour {
|
||||
r: 0xff,
|
||||
g: 0,
|
||||
b: 0,
|
||||
b: 0
|
||||
},
|
||||
colour2: Colour { r: 0, g: 0, b: 0 },
|
||||
speed: Speed::Low,
|
||||
direction: Direction::Left,
|
||||
direction: Direction::Left
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x01, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -589,11 +595,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0xff,
|
||||
b: 0,
|
||||
b: 0
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x02, 0x00, 0xff, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -604,11 +610,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0,
|
||||
g: 0xff,
|
||||
b: 0xff,
|
||||
b: 0xff
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x03, 0x00, 0x00, 0xff, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -619,11 +625,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xff,
|
||||
b: 0xff
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x04, 0x00, 0xff, 0x00, 0xff, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -634,11 +640,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0x2c,
|
||||
g: 0xff,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x05, 0x00, 0x2c, 0xff, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -649,11 +655,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x06, 0x00, 0xff, 0x00, 0x00, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -664,11 +670,11 @@ mod tests {
|
||||
st.colour1 = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0xcd,
|
||||
b: 0xcd
|
||||
};
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x07, 0x00, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
@@ -678,7 +684,7 @@ mod tests {
|
||||
st.mode = AuraModeNum::RainbowWave;
|
||||
let capture = [
|
||||
0x5d, 0xb3, 0x07, 0x03, 0xff, 0x00, 0xcd, 0xe1, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
|
||||
0x0, 0x0,
|
||||
0x0, 0x0
|
||||
];
|
||||
assert_eq!(
|
||||
<[u8; AURA_LAPTOP_LED_MSG_LEN]>::from(&st)[..9],
|
||||
|
||||
Reference in New Issue
Block a user