From d1bdf4dc7eae165670ecab81abf0587a0e0793fc Mon Sep 17 00:00:00 2001 From: "Luke D. Jones" Date: Mon, 29 Aug 2022 17:09:26 +1200 Subject: [PATCH] rog-aura: Add lid zone --- asusctl/src/main.rs | 4 +- daemon/src/ctrl_aura/config.rs | 2 +- rog-aura/src/usb.rs | 80 ++++++++++++++++---- rog-control-center/src/widgets/aura_power.rs | 8 +- 4 files changed, 74 insertions(+), 20 deletions(-) diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 9e3f13d3..368e51b5 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -604,7 +604,7 @@ fn handle_led_power2( aura_cli::SetAuraEnabled::Boot(arg) => { check(arg.keyboard, AuraDev19b6::BootKeyb); check(arg.logo, AuraDev19b6::BootLogo); - check(arg.lightbar, AuraDev19b6::BootBar); + check(arg.lightbar, AuraDev19b6::AwakeBar); } aura_cli::SetAuraEnabled::Sleep(arg) => { check(arg.keyboard, AuraDev19b6::SleepKeyb); @@ -614,7 +614,7 @@ fn handle_led_power2( aura_cli::SetAuraEnabled::Awake(arg) => { check(arg.keyboard, AuraDev19b6::AwakeKeyb); check(arg.logo, AuraDev19b6::AwakeLogo); - check(arg.lightbar, AuraDev19b6::AwakeBar); + check(arg.lightbar, AuraDev19b6::BootBar); } aura_cli::SetAuraEnabled::Shutdown(arg) => { check(arg.keyboard, AuraDev19b6::ShutdownKeyb); diff --git a/daemon/src/ctrl_aura/config.rs b/daemon/src/ctrl_aura/config.rs index 40b23e34..714c64e6 100644 --- a/daemon/src/ctrl_aura/config.rs +++ b/daemon/src/ctrl_aura/config.rs @@ -150,8 +150,8 @@ impl Default for AuraConfig { AuraDev19b6::AwakeKeyb, AuraDev19b6::ShutdownLogo, AuraDev19b6::ShutdownKeyb, - AuraDev19b6::AwakeBar, AuraDev19b6::BootBar, + AuraDev19b6::AwakeBar, AuraDev19b6::SleepBar, AuraDev19b6::ShutdownBar, ])) diff --git a/rog-aura/src/usb.rs b/rog-aura/src/usb.rs index 9c0389f3..6c4828f7 100644 --- a/rog-aura/src/usb.rs +++ b/rog-aura/src/usb.rs @@ -168,7 +168,7 @@ impl BitAnd for AuraDev1866 { /// #[cfg_attr(feature = "dbus", derive(Type))] #[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)] -#[repr(u16)] +#[repr(u32)] pub enum AuraDev19b6 { BootLogo = 1, BootKeyb = 1 << 1, @@ -178,25 +178,29 @@ pub enum AuraDev19b6 { SleepKeyb = 1 << 5, ShutdownLogo = 1 << 6, ShutdownKeyb = 1 << 7, - AwakeBar = 1 << 7 + 2, - BootBar = 1 << 7 + 3, + BootBar = 1 << 7 + 2, + AwakeBar = 1 << 7 + 3, SleepBar = 1 << 7 + 4, ShutdownBar = 1 << 7 + 5, + BootLid = 1 << 15 + 1, + AwakeLid = 1 << 15 + 2, + SleepLid = 1 << 15 + 3, + ShutdownLid = 1 << 15 + 4, } -impl From for u16 { +impl From for u32 { fn from(a: AuraDev19b6) -> Self { - a as u16 + a as u32 } } impl AuraDev19b6 { pub fn to_bytes(control: &[Self]) -> [u8; 3] { - let mut a: u16 = 0; + let mut a: u32 = 0; control.iter().for_each(|n| { - a |= *n as u16; + a |= *n as u32; }); - [(a & 0xff) as u8, ((a & 0xff00) >> 8) as u8, 0x00] + [(a & 0xff) as u8, ((a & 0xff00) >> 8) as u8, ((a & 0xff0000) >> 16) as u8] } pub const fn dev_id() -> &'static str { @@ -275,7 +279,7 @@ mod tests { AuraDev19b6::ShutdownKeyb, ]; let bytes = AuraDev19b6::to_bytes(&byte1); - println!("{:08b}", bytes[0]); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes[0], 0xff); // @@ -336,23 +340,73 @@ mod tests { assert_eq!(bytes[0], 0xdf); let byte2 = [ - AuraDev19b6::AwakeBar, AuraDev19b6::BootBar, + AuraDev19b6::AwakeBar, AuraDev19b6::SleepBar, AuraDev19b6::ShutdownBar, ]; let bytes = AuraDev19b6::to_bytes(&byte2); - println!("{:08b}", bytes[1]); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes[1], 0x1e); let byte2 = [ - AuraDev19b6::AwakeBar, AuraDev19b6::BootBar, + AuraDev19b6::AwakeBar, // AuraControl::SleepBar, AuraDev19b6::ShutdownBar, ]; let bytes = AuraDev19b6::to_bytes(&byte2); - println!("{:08b}", bytes[1]); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); assert_eq!(bytes[1], 0x16); + + let byte3 = [ + AuraDev19b6::AwakeLid, + AuraDev19b6::BootLid, + AuraDev19b6::SleepLid, + AuraDev19b6::ShutdownLid, + ]; + let bytes = AuraDev19b6::to_bytes(&byte3); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes[2], 0x0f); + + let byte3 = [ + //AuraDev19b6::AwakeLid, + AuraDev19b6::BootLid, + AuraDev19b6::SleepLid, + AuraDev19b6::ShutdownLid, + ]; + let bytes = AuraDev19b6::to_bytes(&byte3); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes[2], 0x0d); + + let byte3 = [ + AuraDev19b6::AwakeLid, + AuraDev19b6::BootLid, + // AuraControl::SleepLid, + AuraDev19b6::ShutdownLid, + ]; + let bytes = AuraDev19b6::to_bytes(&byte3); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes[2], 0x0b); + + let byte3 = [ + AuraDev19b6::AwakeLid, + AuraDev19b6::BootLid, + AuraDev19b6::SleepLid, + //AuraDev19b6::ShutdownLid, + ]; + let bytes = AuraDev19b6::to_bytes(&byte3); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes[2], 0x07); + + let byte3 = [ + AuraDev19b6::AwakeLid, + //AuraDev19b6::BootLid, + AuraDev19b6::SleepLid, + //AuraDev19b6::ShutdownLid, + ]; + let bytes = AuraDev19b6::to_bytes(&byte3); + println!("{:08b}, {:08b}, {:08b}", bytes[0], bytes[1], bytes[2]); + assert_eq!(bytes[2], 0x06); } } diff --git a/rog-control-center/src/widgets/aura_power.rs b/rog-control-center/src/widgets/aura_power.rs index b830f6c2..5fc42d54 100644 --- a/rog-control-center/src/widgets/aura_power.rs +++ b/rog-control-center/src/widgets/aura_power.rs @@ -227,11 +227,11 @@ fn aura_power2( .multizone_led_mode .contains(&AuraZone::BarRight); - let boot_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootBar); + let boot_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeBar); let boot_logo = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootLogo); let boot_keyb = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootKeyb); - let awake_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeBar); + let awake_bar = &mut enabled_states.x19b6.contains(&AuraDev19b6::BootBar); let awake_logo = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeLogo); let awake_keyb = &mut enabled_states.x19b6.contains(&AuraDev19b6::AwakeKeyb); @@ -319,9 +319,9 @@ fn aura_power2( .multizone_led_mode .contains(&AuraZone::BarLeft) { - modify(*boot_bar, AuraDev19b6::BootBar); + modify(*boot_bar, AuraDev19b6::AwakeBar); modify(*sleep_bar, AuraDev19b6::SleepBar); - modify(*awake_bar, AuraDev19b6::AwakeBar); + modify(*awake_bar, AuraDev19b6::BootBar); } let mut send = |enable: bool, data: Vec| {