Reformat with trailing comma

This commit is contained in:
Luke Jones
2025-02-14 16:06:20 +13:00
parent 0bdf0474c9
commit 2c006699f2
113 changed files with 791 additions and 792 deletions

View File

@@ -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],
}
}
@@ -200,7 +200,7 @@ mod tests {
power_zones: vec![
PowerZones::Keyboard,
PowerZones::RearGlow,
]
],
};
assert!(ron::to_string(&led).is_ok());

View File

@@ -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,7 +110,7 @@ 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,
}
}
}
@@ -120,7 +120,7 @@ impl From<Colour> for [f32; 3] {
[
c.r as f32 / 255.0,
c.g as f32 / 255.0,
c.b as f32 / 255.0
c.b as f32 / 255.0,
]
}
}
@@ -130,7 +130,7 @@ impl From<&[u8; 3]> for Colour {
Self {
r: c[0],
g: c[1],
b: c[2]
b: c[2],
}
}
}
@@ -138,7 +138,7 @@ impl From<&[u8; 3]> for Colour {
impl From<Colour> for [u8; 3] {
fn from(c: Colour) -> Self {
[
c.r, c.g, c.b
c.r, c.g, c.b,
]
}
}
@@ -153,7 +153,7 @@ pub enum Speed {
Low = 0xe1,
#[default]
Med = 0xeb,
High = 0xf5
High = 0xf5,
}
impl FromStr for Speed {
@@ -165,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),
}
}
}
@@ -175,7 +175,7 @@ impl From<i32> for Speed {
match value {
0 => Self::Low,
2 => Self::High,
_ => Self::Med
_ => Self::Med,
}
}
}
@@ -185,7 +185,7 @@ impl From<Speed> for i32 {
match value {
Speed::Low => 0,
Speed::Med => 1,
Speed::High => 2
Speed::High => 2,
}
}
}
@@ -195,7 +195,7 @@ impl From<Speed> for u8 {
match s {
Speed::Low => 0,
Speed::Med => 1,
Speed::High => 2
Speed::High => 2,
}
}
}
@@ -213,7 +213,7 @@ pub enum Direction {
Right = 0,
Left = 1,
Up = 2,
Down = 3
Down = 3,
}
impl FromStr for Direction {
@@ -226,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),
}
}
}
@@ -237,7 +237,7 @@ impl From<i32> for Direction {
1 => Self::Left,
2 => Self::Up,
3 => Self::Down,
_ => Self::Right
_ => Self::Right,
}
}
}
@@ -270,7 +270,7 @@ pub enum AuraModeNum {
Ripple = 8,
Pulse = 10,
Comet = 11,
Flash = 12
Flash = 12,
}
impl Display for AuraModeNum {
@@ -299,7 +299,7 @@ impl From<&AuraModeNum> for &str {
AuraModeNum::Ripple => "Ripple",
AuraModeNum::Pulse => "Pulse",
AuraModeNum::Comet => "Comet",
AuraModeNum::Flash => "Flash"
AuraModeNum::Flash => "Flash",
}
}
}
@@ -317,7 +317,7 @@ impl From<&str> for AuraModeNum {
"Pulse" => AuraModeNum::Pulse,
"Comet" => AuraModeNum::Comet,
"Flash" => AuraModeNum::Flash,
_ => AuraModeNum::Static
_ => AuraModeNum::Static,
}
}
}
@@ -336,7 +336,7 @@ impl From<u8> for AuraModeNum {
10 => AuraModeNum::Pulse,
11 => AuraModeNum::Comet,
12 => AuraModeNum::Flash,
_ => AuraModeNum::Static
_ => AuraModeNum::Static,
}
}
}
@@ -383,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 {
@@ -400,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),
}
}
}
@@ -415,7 +415,7 @@ impl From<i32> for AuraZone {
5 => Self::Logo,
6 => Self::BarLeft,
7 => Self::BarRight,
_ => Self::default()
_ => Self::default(),
}
}
}
@@ -445,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 {
@@ -481,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,
}
}
}
@@ -541,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]
@@ -552,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);
}
@@ -576,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],
@@ -595,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],
@@ -610,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],
@@ -625,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],
@@ -640,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],
@@ -655,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],
@@ -670,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],
@@ -684,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],

View File

@@ -11,7 +11,7 @@ pub struct InputBased {
/// - temperature
/// - fan speed
/// - time
input: Box<dyn InputForEffect>
input: Box<dyn InputForEffect>,
}
impl EffectState for InputBased {

View File

@@ -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,
}
}
}

View File

@@ -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 {

View File

@@ -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 {
@@ -211,7 +211,7 @@ mod tests {
.push(Effect::Static(Static::new(LedCode::F, Colour {
r: 255,
g: 127,
b: 0
b: 0,
})));
seq.next_state(&layout);
@@ -232,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 =
@@ -274,10 +274,10 @@ mod tests {
Colour {
r: 255,
g: 127,
b: 80
b: 80,
},
100,
10
10,
)));
seq.next_state(&layout);

View File

@@ -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,
}
}
}

View File

@@ -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}"),
}
}
}

View File

@@ -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)",
}
}
}

View File

@@ -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,7 +332,7 @@ 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![
@@ -422,7 +422,7 @@ impl KeyLayout {
(LedCode::PrtSc, "regular".to_owned()),
(LedCode::RCtrl, "regular".to_owned()),
]),
]
],
}
}
}

View File

@@ -16,5 +16,5 @@ pub enum AdvancedAuraType {
#[default]
None,
Zoned(Vec<LedCode>),
PerKey
PerKey,
}

View File

@@ -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,7 +46,7 @@ impl AuraPowerState {
boot: true,
awake: true,
sleep: true,
shutdown: true
shutdown: true,
}
}
@@ -140,7 +140,7 @@ impl AuraPowerState {
| ((self.sleep as u32) << (23 + 3))
| ((self.shutdown as u32) << (23 + 4))
}
PowerZones::None | PowerZones::KeyboardAndLightbar => 0
PowerZones::None | PowerZones::KeyboardAndLightbar => 0,
}
}
}
@@ -148,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 {
@@ -206,19 +206,19 @@ 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!(),
}
}
@@ -266,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"),
}
}
}
@@ -285,7 +285,7 @@ enum OldAuraPower {
Boot = 0xc31209,
Sleep = 0x300804,
Keyboard = 0x080000,
Lightbar = 0x040500
Lightbar = 0x040500,
}
impl BitOr<OldAuraPower> for OldAuraPower {
@@ -332,9 +332,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
};
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -347,9 +347,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
};
let bytes = power.to_bytes(AuraDeviceType::LaptopKeyboardPre2021);
println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]);
@@ -369,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]);
@@ -394,9 +394,9 @@ mod test {
boot: true,
awake: false,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let boot_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -405,9 +405,9 @@ mod test {
boot: true,
awake: false,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let sleep_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -416,9 +416,9 @@ mod test {
boot: false,
awake: false,
sleep: true,
shutdown: false
shutdown: false,
},
]
],
});
let sleep_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -427,9 +427,9 @@ mod test {
boot: false,
awake: false,
sleep: true,
shutdown: false
shutdown: false,
},
]
],
});
let awake_logo = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -438,9 +438,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let awake_keyb = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -449,9 +449,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let shut_logo_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -460,9 +460,9 @@ mod test {
boot: false,
awake: false,
sleep: false,
shutdown: true
shutdown: true,
},
]
],
});
let shut_keyb_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -471,9 +471,9 @@ mod test {
boot: false,
awake: false,
sleep: false,
shutdown: true
shutdown: true,
},
]
],
});
let boot_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -482,9 +482,9 @@ mod test {
boot: true,
awake: false,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let awake_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -493,9 +493,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let sleep_bar_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -504,9 +504,9 @@ mod test {
boot: false,
awake: false,
sleep: true,
shutdown: false
shutdown: false,
},
]
],
});
let shut_bar__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -515,9 +515,9 @@ mod test {
boot: false,
awake: false,
sleep: false,
shutdown: true
shutdown: true,
},
]
],
});
let boot_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -526,9 +526,9 @@ mod test {
boot: true,
awake: false,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let awake_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -537,9 +537,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let sleep_lid_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -548,9 +548,9 @@ mod test {
boot: false,
awake: false,
sleep: true,
shutdown: false
shutdown: false,
},
]
],
});
let shut_lid__ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -559,9 +559,9 @@ mod test {
boot: false,
awake: false,
sleep: false,
shutdown: true
shutdown: true,
},
]
],
});
let boot_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -570,9 +570,9 @@ mod test {
boot: true,
awake: false,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let awake_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -581,9 +581,9 @@ mod test {
boot: false,
awake: true,
sleep: false,
shutdown: false
shutdown: false,
},
]
],
});
let sleep_rear = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -592,9 +592,9 @@ mod test {
boot: false,
awake: false,
sleep: true,
shutdown: false
shutdown: false,
},
]
],
});
let shut_rear_ = to_binary_string_post2021(&LaptopAuraPower {
states: vec![
@@ -603,9 +603,9 @@ mod test {
boot: false,
awake: false,
sleep: false,
shutdown: true
shutdown: true,
},
]
],
});
assert_eq!(boot_logo_, "00000001, 00000000, 00000000, 00000000");
@@ -655,7 +655,7 @@ mod test {
zone: PowerZones::RearGlow,
..Default::default()
},
]
],
});
assert_eq!(byte1, "11111111, 00011110, 00001111, 00001111");
}

View File

@@ -29,40 +29,40 @@ 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
RED, VIOLET, BLUE, TEAL, GREEN, YELLOW, ORANGE,
];
#[cfg_attr(feature = "dbus", derive(Type, Value, OwnedValue))]
@@ -76,7 +76,7 @@ pub enum AuraDeviceType {
ScsiExtDisk = 3,
Ally = 4,
AnimeOrSlash = 5,
Unknown = 255
Unknown = 255,
}
impl AuraDeviceType {
@@ -110,7 +110,7 @@ impl From<&str> for AuraDeviceType {
"1abe" | "1b4c" => Self::Ally,
"19b3" | "193b" => Self::AnimeOrSlash,
"19b6" => Self::LaptopKeyboard2021,
_ => Self::Unknown
_ => Self::Unknown,
}
}
}
@@ -138,5 +138,5 @@ pub enum PowerZones {
KeyboardAndLightbar = 5,
/// Ally specific for creating correct packet
Ally = 6,
None = 255
None = 255,
}

View File

@@ -1,7 +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
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
0x5d, 0xb5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
];