mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 09:23:19 +01:00
Update readme, slash configs
This commit is contained in:
@@ -54,7 +54,7 @@ pub struct LedSupportData {
|
||||
#[serde(default)]
|
||||
pub advanced_type: AdvancedAuraType,
|
||||
/// If empty will default to `Keyboard` power zone
|
||||
pub power_zones: Vec<PowerZones>,
|
||||
pub power_zones: Vec<PowerZones>
|
||||
}
|
||||
|
||||
impl LedSupportData {
|
||||
@@ -116,7 +116,7 @@ impl LedSupportFile {
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![],
|
||||
advanced_type: AdvancedAuraType::None,
|
||||
power_zones: vec![PowerZones::Keyboard],
|
||||
power_zones: vec![PowerZones::Keyboard]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +191,16 @@ mod tests {
|
||||
product_id: String::new(),
|
||||
layout_name: "ga401".to_owned(),
|
||||
basic_modes: vec![AuraModeNum::Static],
|
||||
basic_zones: vec![AuraZone::Key1, AuraZone::Logo, AuraZone::BarLeft],
|
||||
basic_zones: vec![
|
||||
AuraZone::Key1,
|
||||
AuraZone::Logo,
|
||||
AuraZone::BarLeft,
|
||||
],
|
||||
advanced_type: AdvancedAuraType::Zoned(vec![LedCode::LightbarRight]),
|
||||
power_zones: vec![PowerZones::Keyboard, PowerZones::RearGlow],
|
||||
power_zones: vec![
|
||||
PowerZones::Keyboard,
|
||||
PowerZones::RearGlow,
|
||||
]
|
||||
};
|
||||
|
||||
assert!(ron::to_string(&led).is_ok());
|
||||
|
||||
@@ -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],
|
||||
|
||||
@@ -11,7 +11,7 @@ pub struct InputBased {
|
||||
/// - temperature
|
||||
/// - fan speed
|
||||
/// - time
|
||||
input: Box<dyn InputForEffect>,
|
||||
input: Box<dyn InputForEffect>
|
||||
}
|
||||
|
||||
impl EffectState for InputBased {
|
||||
|
||||
@@ -19,7 +19,7 @@ pub struct Breathe {
|
||||
#[serde(skip)]
|
||||
count_flipped: bool,
|
||||
#[serde(skip)]
|
||||
use_colour1: bool,
|
||||
use_colour1: bool
|
||||
}
|
||||
|
||||
impl Breathe {
|
||||
@@ -31,7 +31,7 @@ impl Breathe {
|
||||
speed,
|
||||
colour: colour1,
|
||||
count_flipped: false,
|
||||
use_colour1: true,
|
||||
use_colour1: true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ pub struct DoomFlicker {
|
||||
#[serde(skip)]
|
||||
count: u8,
|
||||
#[serde(skip)]
|
||||
colour: Colour,
|
||||
colour: Colour
|
||||
}
|
||||
|
||||
impl DoomFlicker {
|
||||
@@ -24,7 +24,7 @@ impl DoomFlicker {
|
||||
count: 4,
|
||||
max_percentage,
|
||||
min_percentage,
|
||||
start_colour: colour,
|
||||
start_colour: colour
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -53,13 +53,13 @@ impl EffectState for DoomFlicker {
|
||||
let max_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
|
||||
};
|
||||
// min light is a percentage of the set colour
|
||||
let min_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
|
||||
};
|
||||
|
||||
// Convert the 255 to percentage
|
||||
@@ -96,7 +96,7 @@ pub struct DoomLightFlash {
|
||||
#[serde(skip)]
|
||||
count: u8,
|
||||
#[serde(skip)]
|
||||
colour: Colour,
|
||||
colour: Colour
|
||||
}
|
||||
|
||||
impl DoomLightFlash {
|
||||
@@ -109,7 +109,7 @@ impl DoomLightFlash {
|
||||
min_percentage,
|
||||
start_colour: colour,
|
||||
max_time: 32,
|
||||
min_time: 7,
|
||||
min_time: 7
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -135,13 +135,13 @@ impl EffectState for DoomLightFlash {
|
||||
let max_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *max_percentage as f32) as u8
|
||||
};
|
||||
// min light is a percentage of the set colour
|
||||
let min_light = Colour {
|
||||
r: (start_colour.r as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
g: (start_colour.g as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8,
|
||||
b: (start_colour.b as f32 / 100.0 * *min_percentage as f32) as u8
|
||||
};
|
||||
|
||||
if *colour == max_light {
|
||||
|
||||
@@ -32,7 +32,7 @@ pub const RNDTABLE: [i32; 256] = [
|
||||
206, 163, 45, 63, 90, 168, 114, 59, 33, 159, 95, 28, 139, 123, 98, 125, 196, 15, 70, 194, 253,
|
||||
54, 14, 109, 226, 71, 17, 161, 93, 186, 87, 244, 138, 20, 52, 123, 251, 26, 36, 17, 46, 52,
|
||||
231, 232, 76, 31, 221, 84, 37, 216, 165, 212, 106, 197, 242, 98, 43, 39, 175, 254, 145, 190,
|
||||
84, 118, 222, 187, 136, 120, 163, 236, 249,
|
||||
84, 118, 222, 187, 136, 120, 163, 236, 249
|
||||
];
|
||||
|
||||
pub fn p_random() -> i32 {
|
||||
@@ -67,7 +67,7 @@ pub(crate) trait EffectState {
|
||||
#[derive(Debug, Deserialize, Serialize, Default)]
|
||||
pub struct AdvancedEffects {
|
||||
effects: Vec<Effect>,
|
||||
zoned: bool,
|
||||
zoned: bool
|
||||
}
|
||||
|
||||
impl AdvancedEffects {
|
||||
@@ -75,7 +75,7 @@ impl AdvancedEffects {
|
||||
pub fn new(zoned: bool) -> Self {
|
||||
Self {
|
||||
effects: Default::default(),
|
||||
zoned,
|
||||
zoned
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ pub enum Effect {
|
||||
Static(Static),
|
||||
Breathe(Breathe),
|
||||
DoomFlicker(DoomFlicker),
|
||||
DoomLightFlash(DoomLightFlash),
|
||||
DoomLightFlash(DoomLightFlash)
|
||||
}
|
||||
|
||||
impl Default for Effect {
|
||||
@@ -207,14 +207,12 @@ mod tests {
|
||||
fn single_key_next_state_then_create() {
|
||||
let layout = KeyLayout::default_layout();
|
||||
let mut seq = AdvancedEffects::new(false);
|
||||
seq.effects.push(Effect::Static(Static::new(
|
||||
LedCode::F,
|
||||
Colour {
|
||||
seq.effects
|
||||
.push(Effect::Static(Static::new(LedCode::F, Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 0,
|
||||
},
|
||||
)));
|
||||
b: 0
|
||||
})));
|
||||
|
||||
seq.next_state(&layout);
|
||||
let packets = seq.create_packets();
|
||||
@@ -234,14 +232,14 @@ mod tests {
|
||||
Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 0,
|
||||
b: 0
|
||||
},
|
||||
Colour {
|
||||
r: 127,
|
||||
g: 0,
|
||||
b: 255,
|
||||
b: 255
|
||||
},
|
||||
Speed::Med,
|
||||
Speed::Med
|
||||
)));
|
||||
|
||||
let s =
|
||||
@@ -276,10 +274,10 @@ mod tests {
|
||||
Colour {
|
||||
r: 255,
|
||||
g: 127,
|
||||
b: 80,
|
||||
b: 80
|
||||
},
|
||||
100,
|
||||
10,
|
||||
10
|
||||
)));
|
||||
|
||||
seq.next_state(&layout);
|
||||
|
||||
@@ -8,14 +8,14 @@ use crate::{effect_state_impl, Colour};
|
||||
pub struct Static {
|
||||
led: LedCode,
|
||||
/// The starting colour
|
||||
colour: Colour,
|
||||
colour: Colour
|
||||
}
|
||||
|
||||
impl Static {
|
||||
pub fn new(address: LedCode, colour: Colour) -> Self {
|
||||
Self {
|
||||
led: address,
|
||||
colour,
|
||||
colour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ pub enum Error {
|
||||
ParseBrightness,
|
||||
IoPath(String, std::io::Error),
|
||||
Ron(ron::Error),
|
||||
RonParse(ron::error::SpannedError),
|
||||
RonParse(ron::error::SpannedError)
|
||||
}
|
||||
|
||||
impl fmt::Display for Error {
|
||||
@@ -21,7 +21,7 @@ impl fmt::Display for Error {
|
||||
Error::ParseBrightness => write!(f, "Could not parse brightness"),
|
||||
Error::IoPath(path, io) => write!(f, "IO Error: {path}, {io}"),
|
||||
Error::Ron(e) => write!(f, "RON Parse Error: {e}"),
|
||||
Error::RonParse(e) => write!(f, "RON Parse Error: {e}"),
|
||||
Error::RonParse(e) => write!(f, "RON Parse Error: {e}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ pub enum LedCode {
|
||||
/// To be ignored by effects
|
||||
Spacing,
|
||||
/// To be ignored by effects
|
||||
Blocking,
|
||||
Blocking
|
||||
}
|
||||
|
||||
impl LedCode {
|
||||
@@ -210,7 +210,7 @@ pub struct LedUsbPackets {
|
||||
/// Wether or not this packet collection is zoned. The determines which
|
||||
/// starting bytes are used and what the indexing is for lightbar RGB
|
||||
/// colours
|
||||
zoned: bool,
|
||||
zoned: bool
|
||||
}
|
||||
|
||||
impl Default for LedUsbPackets {
|
||||
@@ -244,7 +244,7 @@ impl LedUsbPackets {
|
||||
}
|
||||
Self {
|
||||
usb_packets: set,
|
||||
zoned: false,
|
||||
zoned: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ impl LedUsbPackets {
|
||||
}
|
||||
Self {
|
||||
usb_packets: vec![pkt],
|
||||
zoned: true,
|
||||
zoned: true
|
||||
}
|
||||
}
|
||||
|
||||
@@ -633,7 +633,7 @@ impl From<&LedCode> for &str {
|
||||
LedCode::ZonedKbLeft => "Left Zone (zone 1)",
|
||||
LedCode::ZonedKbLeftMid => "Center-left Zone (zone 2)",
|
||||
LedCode::ZonedKbRightMid => "Center-right Zone (zone 3)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)",
|
||||
LedCode::ZonedKbRight => "Right Zone (zone 4)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ pub enum KeyShape {
|
||||
pad_left: f32,
|
||||
pad_right: f32,
|
||||
pad_top: f32,
|
||||
pad_bottom: f32,
|
||||
pad_bottom: f32
|
||||
},
|
||||
Blank {
|
||||
width: f32,
|
||||
height: f32,
|
||||
},
|
||||
height: f32
|
||||
}
|
||||
}
|
||||
|
||||
impl KeyShape {
|
||||
@@ -41,7 +41,7 @@ impl KeyShape {
|
||||
pad_left: f32,
|
||||
pad_right: f32,
|
||||
pad_top: f32,
|
||||
pad_bottom: f32,
|
||||
pad_bottom: f32
|
||||
) -> Self {
|
||||
Self::Led {
|
||||
width,
|
||||
@@ -49,7 +49,7 @@ impl KeyShape {
|
||||
pad_left,
|
||||
pad_right,
|
||||
pad_top,
|
||||
pad_bottom,
|
||||
pad_bottom
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ impl KeyShape {
|
||||
pad_left,
|
||||
pad_right,
|
||||
pad_top,
|
||||
pad_bottom,
|
||||
pad_bottom
|
||||
} => {
|
||||
*width *= scale;
|
||||
*height *= scale;
|
||||
@@ -97,7 +97,7 @@ pub struct KeyRow {
|
||||
row: Vec<(LedCode, String)>,
|
||||
/// The final data structure merged key_shapes and rows
|
||||
#[serde(skip)]
|
||||
built_row: Vec<(LedCode, KeyShape)>,
|
||||
built_row: Vec<(LedCode, KeyShape)>
|
||||
}
|
||||
|
||||
impl KeyRow {
|
||||
@@ -106,7 +106,7 @@ impl KeyRow {
|
||||
pad_left,
|
||||
pad_top,
|
||||
row,
|
||||
built_row: Default::default(),
|
||||
built_row: Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ impl KeyRow {
|
||||
pad_bottom,
|
||||
..
|
||||
} => height + pad_top + pad_bottom,
|
||||
KeyShape::Blank { height, .. } => *height,
|
||||
KeyShape::Blank { height, .. } => *height
|
||||
};
|
||||
|
||||
if h < height {
|
||||
@@ -156,7 +156,7 @@ impl KeyRow {
|
||||
pad_right,
|
||||
..
|
||||
} => w += width + pad_left + pad_right,
|
||||
KeyShape::Blank { width, .. } => w += width,
|
||||
KeyShape::Blank { width, .. } => w += width
|
||||
}
|
||||
}
|
||||
w
|
||||
@@ -185,7 +185,7 @@ pub struct KeyLayout {
|
||||
/// Should be copied from the `LaptopLedData` as laptops may have the same
|
||||
/// layout, but different EC features.
|
||||
#[serde(skip)]
|
||||
advanced_type: AdvancedAuraType,
|
||||
advanced_type: AdvancedAuraType
|
||||
}
|
||||
|
||||
impl KeyLayout {
|
||||
@@ -195,7 +195,7 @@ impl KeyLayout {
|
||||
if buf.is_empty() {
|
||||
Err(Error::IoPath(
|
||||
path.to_string_lossy().to_string(),
|
||||
std::io::ErrorKind::InvalidData.into(),
|
||||
std::io::ErrorKind::InvalidData.into()
|
||||
))
|
||||
} else {
|
||||
let mut data = ron::from_str::<Self>(&buf)?;
|
||||
@@ -332,121 +332,97 @@ impl KeyLayout {
|
||||
advanced_type: AdvancedAuraType::None,
|
||||
key_shapes: HashMap::from([(
|
||||
"regular".to_owned(),
|
||||
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1),
|
||||
KeyShape::new_led(1.0, 1.0, 0.1, 0.1, 0.1, 0.1)
|
||||
)]),
|
||||
key_rows: vec![
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::Esc, "regular".to_owned()),
|
||||
(LedCode::F1, "regular".to_owned()),
|
||||
(LedCode::F2, "regular".to_owned()),
|
||||
(LedCode::F3, "regular".to_owned()),
|
||||
(LedCode::F4, "regular".to_owned()),
|
||||
// not sure which key to put here
|
||||
(LedCode::F5, "regular".to_owned()),
|
||||
(LedCode::F6, "regular".to_owned()),
|
||||
(LedCode::F7, "regular".to_owned()),
|
||||
(LedCode::F8, "regular".to_owned()),
|
||||
(LedCode::F9, "regular".to_owned()),
|
||||
(LedCode::F10, "regular".to_owned()),
|
||||
(LedCode::F11, "regular".to_owned()),
|
||||
(LedCode::F12, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::Tilde, "regular".to_owned()),
|
||||
(LedCode::N1, "regular".to_owned()),
|
||||
(LedCode::N2, "regular".to_owned()),
|
||||
(LedCode::N3, "regular".to_owned()),
|
||||
(LedCode::N4, "regular".to_owned()),
|
||||
(LedCode::N5, "regular".to_owned()),
|
||||
(LedCode::N6, "regular".to_owned()),
|
||||
(LedCode::N7, "regular".to_owned()),
|
||||
(LedCode::N8, "regular".to_owned()),
|
||||
(LedCode::N9, "regular".to_owned()),
|
||||
(LedCode::N0, "regular".to_owned()),
|
||||
(LedCode::Hyphen, "regular".to_owned()),
|
||||
(LedCode::Equals, "regular".to_owned()),
|
||||
(LedCode::Backspace, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::Tab, "regular".to_owned()),
|
||||
(LedCode::Q, "regular".to_owned()),
|
||||
(LedCode::W, "regular".to_owned()),
|
||||
(LedCode::E, "regular".to_owned()),
|
||||
(LedCode::R, "regular".to_owned()),
|
||||
(LedCode::T, "regular".to_owned()),
|
||||
(LedCode::Y, "regular".to_owned()),
|
||||
(LedCode::U, "regular".to_owned()),
|
||||
(LedCode::I, "regular".to_owned()),
|
||||
(LedCode::O, "regular".to_owned()),
|
||||
(LedCode::P, "regular".to_owned()),
|
||||
(LedCode::LBracket, "regular".to_owned()),
|
||||
(LedCode::RBracket, "regular".to_owned()),
|
||||
(LedCode::BackSlash, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::Caps, "regular".to_owned()),
|
||||
(LedCode::A, "regular".to_owned()),
|
||||
(LedCode::S, "regular".to_owned()),
|
||||
(LedCode::D, "regular".to_owned()),
|
||||
(LedCode::F, "regular".to_owned()),
|
||||
(LedCode::G, "regular".to_owned()),
|
||||
(LedCode::H, "regular".to_owned()),
|
||||
(LedCode::J, "regular".to_owned()),
|
||||
(LedCode::K, "regular".to_owned()),
|
||||
(LedCode::L, "regular".to_owned()),
|
||||
(LedCode::SemiColon, "regular".to_owned()),
|
||||
(LedCode::Quote, "regular".to_owned()),
|
||||
(LedCode::Return, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::LShift, "regular".to_owned()),
|
||||
(LedCode::Z, "regular".to_owned()),
|
||||
(LedCode::X, "regular".to_owned()),
|
||||
(LedCode::C, "regular".to_owned()),
|
||||
(LedCode::V, "regular".to_owned()),
|
||||
(LedCode::B, "regular".to_owned()),
|
||||
(LedCode::N, "regular".to_owned()),
|
||||
(LedCode::M, "regular".to_owned()),
|
||||
(LedCode::Comma, "regular".to_owned()),
|
||||
(LedCode::Period, "regular".to_owned()),
|
||||
(LedCode::FwdSlash, "regular".to_owned()),
|
||||
(LedCode::Rshift, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
KeyRow::new(
|
||||
0.1,
|
||||
0.1,
|
||||
vec![
|
||||
(LedCode::LCtrl, "regular".to_owned()),
|
||||
(LedCode::LFn, "regular".to_owned()),
|
||||
(LedCode::Meta, "regular".to_owned()),
|
||||
(LedCode::LAlt, "regular".to_owned()),
|
||||
(LedCode::Spacebar, "regular".to_owned()),
|
||||
(LedCode::RAlt, "regular".to_owned()),
|
||||
(LedCode::PrtSc, "regular".to_owned()),
|
||||
(LedCode::RCtrl, "regular".to_owned()),
|
||||
],
|
||||
),
|
||||
],
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::Esc, "regular".to_owned()),
|
||||
(LedCode::F1, "regular".to_owned()),
|
||||
(LedCode::F2, "regular".to_owned()),
|
||||
(LedCode::F3, "regular".to_owned()),
|
||||
(LedCode::F4, "regular".to_owned()),
|
||||
// not sure which key to put here
|
||||
(LedCode::F5, "regular".to_owned()),
|
||||
(LedCode::F6, "regular".to_owned()),
|
||||
(LedCode::F7, "regular".to_owned()),
|
||||
(LedCode::F8, "regular".to_owned()),
|
||||
(LedCode::F9, "regular".to_owned()),
|
||||
(LedCode::F10, "regular".to_owned()),
|
||||
(LedCode::F11, "regular".to_owned()),
|
||||
(LedCode::F12, "regular".to_owned()),
|
||||
]),
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::Tilde, "regular".to_owned()),
|
||||
(LedCode::N1, "regular".to_owned()),
|
||||
(LedCode::N2, "regular".to_owned()),
|
||||
(LedCode::N3, "regular".to_owned()),
|
||||
(LedCode::N4, "regular".to_owned()),
|
||||
(LedCode::N5, "regular".to_owned()),
|
||||
(LedCode::N6, "regular".to_owned()),
|
||||
(LedCode::N7, "regular".to_owned()),
|
||||
(LedCode::N8, "regular".to_owned()),
|
||||
(LedCode::N9, "regular".to_owned()),
|
||||
(LedCode::N0, "regular".to_owned()),
|
||||
(LedCode::Hyphen, "regular".to_owned()),
|
||||
(LedCode::Equals, "regular".to_owned()),
|
||||
(LedCode::Backspace, "regular".to_owned()),
|
||||
]),
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::Tab, "regular".to_owned()),
|
||||
(LedCode::Q, "regular".to_owned()),
|
||||
(LedCode::W, "regular".to_owned()),
|
||||
(LedCode::E, "regular".to_owned()),
|
||||
(LedCode::R, "regular".to_owned()),
|
||||
(LedCode::T, "regular".to_owned()),
|
||||
(LedCode::Y, "regular".to_owned()),
|
||||
(LedCode::U, "regular".to_owned()),
|
||||
(LedCode::I, "regular".to_owned()),
|
||||
(LedCode::O, "regular".to_owned()),
|
||||
(LedCode::P, "regular".to_owned()),
|
||||
(LedCode::LBracket, "regular".to_owned()),
|
||||
(LedCode::RBracket, "regular".to_owned()),
|
||||
(LedCode::BackSlash, "regular".to_owned()),
|
||||
]),
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::Caps, "regular".to_owned()),
|
||||
(LedCode::A, "regular".to_owned()),
|
||||
(LedCode::S, "regular".to_owned()),
|
||||
(LedCode::D, "regular".to_owned()),
|
||||
(LedCode::F, "regular".to_owned()),
|
||||
(LedCode::G, "regular".to_owned()),
|
||||
(LedCode::H, "regular".to_owned()),
|
||||
(LedCode::J, "regular".to_owned()),
|
||||
(LedCode::K, "regular".to_owned()),
|
||||
(LedCode::L, "regular".to_owned()),
|
||||
(LedCode::SemiColon, "regular".to_owned()),
|
||||
(LedCode::Quote, "regular".to_owned()),
|
||||
(LedCode::Return, "regular".to_owned()),
|
||||
]),
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::LShift, "regular".to_owned()),
|
||||
(LedCode::Z, "regular".to_owned()),
|
||||
(LedCode::X, "regular".to_owned()),
|
||||
(LedCode::C, "regular".to_owned()),
|
||||
(LedCode::V, "regular".to_owned()),
|
||||
(LedCode::B, "regular".to_owned()),
|
||||
(LedCode::N, "regular".to_owned()),
|
||||
(LedCode::M, "regular".to_owned()),
|
||||
(LedCode::Comma, "regular".to_owned()),
|
||||
(LedCode::Period, "regular".to_owned()),
|
||||
(LedCode::FwdSlash, "regular".to_owned()),
|
||||
(LedCode::Rshift, "regular".to_owned()),
|
||||
]),
|
||||
KeyRow::new(0.1, 0.1, vec![
|
||||
(LedCode::LCtrl, "regular".to_owned()),
|
||||
(LedCode::LFn, "regular".to_owned()),
|
||||
(LedCode::Meta, "regular".to_owned()),
|
||||
(LedCode::LAlt, "regular".to_owned()),
|
||||
(LedCode::Spacebar, "regular".to_owned()),
|
||||
(LedCode::RAlt, "regular".to_owned()),
|
||||
(LedCode::PrtSc, "regular".to_owned()),
|
||||
(LedCode::RCtrl, "regular".to_owned()),
|
||||
]),
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
|
||||
#[default]
|
||||
None,
|
||||
Zoned(Vec<LedCode>),
|
||||
PerKey,
|
||||
PerKey
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ pub struct AuraPowerState {
|
||||
pub awake: bool,
|
||||
pub sleep: bool,
|
||||
/// Ignored for pre-2021 and Tuf
|
||||
pub shutdown: bool,
|
||||
pub shutdown: bool
|
||||
}
|
||||
|
||||
impl Default for AuraPowerState {
|
||||
@@ -34,7 +34,7 @@ impl Default for AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
shutdown: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,13 +46,15 @@ impl AuraPowerState {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: true,
|
||||
shutdown: true
|
||||
}
|
||||
}
|
||||
|
||||
fn tuf_to_bytes(&self) -> Vec<u8> {
|
||||
// &cmd, &boot, &awake, &sleep, &keyboard
|
||||
vec![1, self.boot as u8, self.awake as u8, self.sleep as u8, 1]
|
||||
vec![
|
||||
1, self.boot as u8, self.awake as u8, self.sleep as u8, 1,
|
||||
]
|
||||
}
|
||||
|
||||
/// # Bits for older 0x1866 keyboard model
|
||||
@@ -104,41 +106,41 @@ impl AuraPowerState {
|
||||
match self.zone {
|
||||
PowerZones::Logo => {
|
||||
self.boot as u32
|
||||
| (self.awake as u32) << 2
|
||||
| (self.sleep as u32) << 4
|
||||
| (self.shutdown as u32) << 6
|
||||
| ((self.awake as u32) << 2)
|
||||
| ((self.sleep as u32) << 4)
|
||||
| ((self.shutdown as u32) << 6)
|
||||
}
|
||||
PowerZones::Ally => {
|
||||
(self.boot as u32)
|
||||
| (self.awake as u32) << 1
|
||||
| (self.sleep as u32) << 2
|
||||
| (self.shutdown as u32) << 3
|
||||
| ((self.awake as u32) << 1)
|
||||
| ((self.sleep as u32) << 2)
|
||||
| ((self.shutdown as u32) << 3)
|
||||
}
|
||||
PowerZones::Keyboard => {
|
||||
(self.boot as u32) << 1
|
||||
| (self.awake as u32) << 3
|
||||
| (self.sleep as u32) << 5
|
||||
| (self.shutdown as u32) << 7
|
||||
((self.boot as u32) << 1)
|
||||
| ((self.awake as u32) << 3)
|
||||
| ((self.sleep as u32) << 5)
|
||||
| ((self.shutdown as u32) << 7)
|
||||
}
|
||||
PowerZones::Lightbar => {
|
||||
(self.boot as u32) << (7 + 2)
|
||||
| (self.awake as u32) << (7 + 3)
|
||||
| (self.sleep as u32) << (7 + 4)
|
||||
| (self.shutdown as u32) << (7 + 5)
|
||||
((self.boot as u32) << (7 + 2))
|
||||
| ((self.awake as u32) << (7 + 3))
|
||||
| ((self.sleep as u32) << (7 + 4))
|
||||
| ((self.shutdown as u32) << (7 + 5))
|
||||
}
|
||||
PowerZones::Lid => {
|
||||
(self.boot as u32) << (15 + 1)
|
||||
| (self.awake as u32) << (15 + 2)
|
||||
| (self.sleep as u32) << (15 + 3)
|
||||
| (self.shutdown as u32) << (15 + 4)
|
||||
((self.boot as u32) << (15 + 1))
|
||||
| ((self.awake as u32) << (15 + 2))
|
||||
| ((self.sleep as u32) << (15 + 3))
|
||||
| ((self.shutdown as u32) << (15 + 4))
|
||||
}
|
||||
PowerZones::RearGlow => {
|
||||
(self.boot as u32) << (23 + 1)
|
||||
| (self.awake as u32) << (23 + 2)
|
||||
| (self.sleep as u32) << (23 + 3)
|
||||
| (self.shutdown as u32) << (23 + 4)
|
||||
((self.boot as u32) << (23 + 1))
|
||||
| ((self.awake as u32) << (23 + 2))
|
||||
| ((self.sleep as u32) << (23 + 3))
|
||||
| ((self.shutdown as u32) << (23 + 4))
|
||||
}
|
||||
PowerZones::None | PowerZones::KeyboardAndLightbar => 0,
|
||||
PowerZones::None | PowerZones::KeyboardAndLightbar => 0
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,7 +148,7 @@ impl AuraPowerState {
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct LaptopAuraPower {
|
||||
pub states: Vec<AuraPowerState>,
|
||||
pub states: Vec<AuraPowerState>
|
||||
}
|
||||
|
||||
impl LaptopAuraPower {
|
||||
@@ -204,26 +206,32 @@ impl LaptopAuraPower {
|
||||
// 3. KeyboardAndLightbar
|
||||
if support_data.power_zones.contains(&PowerZones::Lightbar) {
|
||||
Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)],
|
||||
states: vec![AuraPowerState::default_for(PowerZones::KeyboardAndLightbar)]
|
||||
}
|
||||
} else {
|
||||
Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
|
||||
}
|
||||
}
|
||||
}
|
||||
AuraDeviceType::LaptopKeyboardTuf => Self {
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)],
|
||||
states: vec![AuraPowerState::default_for(PowerZones::Keyboard)]
|
||||
},
|
||||
AuraDeviceType::ScsiExtDisk => todo!(),
|
||||
AuraDeviceType::AnimeOrSlash => todo!(),
|
||||
AuraDeviceType::AnimeOrSlash => todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_bytes(&self, aura_type: AuraDeviceType) -> Vec<u8> {
|
||||
if let Some(stuff) = self.states.first() {
|
||||
if stuff.zone == PowerZones::Ally {
|
||||
return vec![0x5d, 0xd1, 0x09, 0x01, stuff.new_to_byte() as u8];
|
||||
return vec![
|
||||
0x5d,
|
||||
0xd1,
|
||||
0x09,
|
||||
0x01,
|
||||
stuff.new_to_byte() as u8,
|
||||
];
|
||||
}
|
||||
}
|
||||
match aura_type {
|
||||
@@ -258,7 +266,7 @@ impl LaptopAuraPower {
|
||||
self.new_to_bytes()
|
||||
}
|
||||
AuraDeviceType::ScsiExtDisk => todo!("scsi disk not implemented yet"),
|
||||
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet"),
|
||||
AuraDeviceType::AnimeOrSlash => todo!("anime/slash not implemented yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -277,7 +285,7 @@ enum OldAuraPower {
|
||||
Boot = 0xc31209,
|
||||
Sleep = 0x300804,
|
||||
Keyboard = 0x080000,
|
||||
Lightbar = 0x040500,
|
||||
Lightbar = 0x040500
|
||||
}
|
||||
|
||||
impl BitOr<OldAuraPower> for OldAuraPower {
|
||||
@@ -318,26 +326,30 @@ mod test {
|
||||
#[test]
|
||||
fn check_0x1866_control_bytes() {
|
||||
let power = LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
assert_eq!(bytes, [0x08, 0x00, 0x02, 0x00]);
|
||||
|
||||
let power = LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
@@ -357,16 +369,16 @@ mod test {
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
shutdown: false
|
||||
},
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: true,
|
||||
awake: true,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
shutdown: false
|
||||
},
|
||||
],
|
||||
]
|
||||
};
|
||||
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
|
||||
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
|
||||
@@ -376,184 +388,224 @@ mod test {
|
||||
#[test]
|
||||
fn check_0x19b6_control_bytes_binary_rep() {
|
||||
let boot_logo_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Logo,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
},
|
||||
]
|
||||
});
|
||||
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Keyboard,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
},
|
||||
]
|
||||
});
|
||||
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lightbar,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
},
|
||||
]
|
||||
});
|
||||
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::Lid,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
},
|
||||
]
|
||||
});
|
||||
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: true,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: true,
|
||||
sleep: false,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: true,
|
||||
shutdown: false
|
||||
},
|
||||
]
|
||||
});
|
||||
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
|
||||
states: vec![AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true,
|
||||
}],
|
||||
states: vec![
|
||||
AuraPowerState {
|
||||
zone: PowerZones::RearGlow,
|
||||
boot: false,
|
||||
awake: false,
|
||||
sleep: false,
|
||||
shutdown: true
|
||||
},
|
||||
]
|
||||
});
|
||||
|
||||
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
|
||||
@@ -603,7 +655,7 @@ mod test {
|
||||
zone: PowerZones::RearGlow,
|
||||
..Default::default()
|
||||
},
|
||||
],
|
||||
]
|
||||
});
|
||||
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
|
||||
}
|
||||
|
||||
@@ -29,39 +29,41 @@ pub const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||
pub const RED: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0x00,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
pub const GREEN: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0xff,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
pub const BLUE: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0x00,
|
||||
b: 0xff,
|
||||
b: 0xff
|
||||
};
|
||||
pub const VIOLET: Colour = Colour {
|
||||
r: 0x9b,
|
||||
g: 0x26,
|
||||
b: 0xb6,
|
||||
b: 0xb6
|
||||
};
|
||||
pub const TEAL: Colour = Colour {
|
||||
r: 0x00,
|
||||
g: 0x7c,
|
||||
b: 0x80,
|
||||
b: 0x80
|
||||
};
|
||||
pub const YELLOW: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0xef,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
pub const ORANGE: Colour = Colour {
|
||||
r: 0xff,
|
||||
g: 0xa4,
|
||||
b: 0x00,
|
||||
b: 0x00
|
||||
};
|
||||
pub const GRADIENT: [Colour; 7] = [RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE];
|
||||
pub const GRADIENT: [Colour; 7] = [
|
||||
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE
|
||||
];
|
||||
|
||||
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)]
|
||||
@@ -74,7 +76,7 @@ pub enum AuraDeviceType {
|
||||
ScsiExtDisk = 3,
|
||||
Ally = 4,
|
||||
AnimeOrSlash = 5,
|
||||
Unknown = 255,
|
||||
Unknown = 255
|
||||
}
|
||||
|
||||
impl AuraDeviceType {
|
||||
@@ -108,7 +110,7 @@ impl From<&str> for AuraDeviceType {
|
||||
"1abe" | "1b4c" => Self::Ally,
|
||||
"19b3" | "193b" => Self::AnimeOrSlash,
|
||||
"19b6" => Self::LaptopKeyboard2021,
|
||||
_ => Self::Unknown,
|
||||
_ => Self::Unknown
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,5 +138,5 @@ pub enum PowerZones {
|
||||
KeyboardAndLightbar = 5,
|
||||
/// Ally specific for creating correct packet
|
||||
Ally = 6,
|
||||
None = 255,
|
||||
None = 255
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
// Only these two packets must be 17 bytes
|
||||
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] =
|
||||
[0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
|
||||
pub const AURA_LAPTOP_LED_APPLY: [u8; 17] = [
|
||||
0x5d, 0xb4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
];
|
||||
pub const AURA_LAPTOP_LED_SET: [u8; 17] = [
|
||||
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user