Add Ally 1 and X as "old" style devices for power

These have a slightly different power settings data which needs to be verified.
We can use the old style for now.

Closes #542
This commit is contained in:
Luke D. Jones
2024-08-27 11:46:09 +12:00
parent c3880d055d
commit 8f35220c5f
16 changed files with 1006 additions and 785 deletions

View File

@@ -15,6 +15,8 @@ use crate::error::RogError;
// #[serde(default)]
pub struct AuraConfig {
pub config_name: String,
#[serde(skip_serializing_if = "Option::is_none", default)]
pub ally_fix: Option<bool>,
pub brightness: LedBrightness,
pub current_mode: AuraModeNum,
pub builtins: BTreeMap<AuraModeNum, AuraEffect>,
@@ -57,6 +59,7 @@ impl AuraConfig {
let enabled = LaptopAuraPower::new(device_type, &support_data);
let mut config = AuraConfig {
config_name: format!("aura_{prod_id}.ron"),
ally_fix: None,
brightness: LedBrightness::Med,
current_mode: AuraModeNum::Static,
builtins: BTreeMap::new(),

View File

@@ -7,7 +7,7 @@ use log::{debug, info, warn};
use rog_aura::aura_detection::LedSupportData;
use rog_aura::keyboard::{LedUsbPackets, UsbPackets};
use rog_aura::usb::{LED_APPLY, LED_SET};
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, LED_MSG_LEN};
use rog_aura::{AuraDeviceType, AuraEffect, LedBrightness, PowerZones, LED_MSG_LEN};
use rog_platform::hid_raw::HidRaw;
use rog_platform::keyboard_led::KeyboardBacklight;
use udev::Device;
@@ -317,6 +317,23 @@ impl CtrlKbdLed {
config_loaded
}
pub(super) fn fix_ally_power(&mut self) -> Result<(), RogError> {
if self.led_type == AuraDeviceType::Ally {
if let LEDNode::Rog(_, hid_raw) = &self.led_node {
if let Some(fix) = self.config.ally_fix.as_mut() {
if !*fix {
let msg = [0x5d, 0xbd, 0x01, 0xff, 0xff, 0xff, 0xff];
hid_raw.write_bytes(&msg)?;
info!("Reset Ally power settings to base");
}
*fix = true;
}
self.config.write();
}
}
Ok(())
}
/// Set combination state for boot animation/sleep animation/all leds/keys
/// leds/side leds LED active
pub(super) fn set_power_states(&mut self) -> Result<(), RogError> {
@@ -325,13 +342,17 @@ impl CtrlKbdLed {
let buf = self.config.enabled.to_bytes(self.led_type);
platform.set_kbd_rgb_state(&buf)?;
} else if let LEDNode::Rog(_, hid_raw) = &self.led_node {
let bytes = self.config.enabled.to_bytes(self.led_type);
let message = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
if let Some(p) = self.config.enabled.states.first() {
if p.zone == PowerZones::Ally {
let msg = [0x5d, 0xd1, 0x09, 0x01, p.new_to_byte() as u8, 0x0, 0x0];
hid_raw.write_bytes(&msg)?;
return Ok(());
}
}
hid_raw.write_bytes(&message)?;
hid_raw.write_bytes(&LED_SET)?;
// Changes won't persist unless apply is set
hid_raw.write_bytes(&LED_APPLY)?;
let bytes = self.config.enabled.to_bytes(self.led_type);
let msg = [0x5d, 0xbd, 0x01, bytes[0], bytes[1], bytes[2], bytes[3]];
hid_raw.write_bytes(&msg)?;
}
Ok(())
}

View File

@@ -296,6 +296,7 @@ impl CtrlTask for CtrlAuraZbus {
impl crate::Reloadable for CtrlAuraZbus {
async fn reload(&mut self) -> Result<(), RogError> {
let mut ctrl = self.0.lock().await;
ctrl.fix_ally_power()?;
debug!("reloading keyboard mode");
ctrl.write_current_config_mode()?;
debug!("reloading power states");