diff --git a/CHANGELOG.md b/CHANGELOG.md index f0c4f419..82112c34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Support for G733C LED modes - Support for GV601VI LED modes - Support for FX505G LED modes +- Support for GA402X LED modes - Support for G634J LED modes (layout is in progress) - Support the Rear Glow on some laptops - Added field to aura_support to determine which LED power zones are supported. This will need folks to contribute data. @@ -27,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add generation of typescript types from the rust types used via dbus using typeshare - Add generation of introspection XML from asusd dbus - Add a reworked gnome extension to the main repo under `desktop-extensions/gnome/`. This was done to better keep the extension in sync with work done on asusd, especially around breaking dbus +- Add support for the mid fan custom curves on some laptops ### Changed - Move FX506HC to FX506H in arua DB to catch full series of this range - Move FX506LH to FX506L in arua DB to catch full series of this range diff --git a/asusctl/src/main.rs b/asusctl/src/main.rs index 751e9eaf..4412e8a5 100644 --- a/asusctl/src/main.rs +++ b/asusctl/src/main.rs @@ -705,7 +705,7 @@ fn handle_fan_curve( if let Some(enabled) = cmd.enabled { dbus.proxies() .profile() - .set_fan_curve_enabled(profile, enabled)?; + .set_fan_curves_enabled(profile, enabled)?; } if let Some(mut curve) = cmd.data.clone() { diff --git a/asusd/src/ctrl_profiles/trait_impls.rs b/asusd/src/ctrl_profiles/trait_impls.rs index c9e95a1a..f1bb623f 100644 --- a/asusd/src/ctrl_profiles/trait_impls.rs +++ b/asusd/src/ctrl_profiles/trait_impls.rs @@ -5,7 +5,7 @@ use async_trait::async_trait; use config_traits::StdConfig; use log::{error, info, warn}; use rog_profiles::fan_curve_set::CurveData; -use rog_profiles::{FanCurveProfiles, Profile}; +use rog_profiles::{FanCurvePU, FanCurveProfiles, Profile}; use zbus::export::futures_util::lock::Mutex; use zbus::export::futures_util::StreamExt; use zbus::fdo::Error; @@ -83,9 +83,9 @@ impl ProfileZbus { .ok(); } - /// Set a profile fan curve enabled status. Will also activate a fan curve - /// if in the same profile mode - async fn set_fan_curve_enabled( + /// Set all fan curves for a profile to enabled status. Will also activate a + /// fan curve if in the same profile mode + async fn set_fan_curves_enabled( &mut self, profile: Profile, enabled: bool, @@ -95,7 +95,33 @@ impl ProfileZbus { if let Some(curves) = &mut ctrl.fan_curves { curves .profiles_mut() - .set_profile_curve_enabled(profile, enabled); + .set_profile_curves_enabled(profile, enabled); + + ctrl.write_profile_curve_to_platform() + .map_err(|e| warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e)) + .ok(); + + ctrl.save_config(); + Ok(()) + } else { + Err(Error::Failed(UNSUPPORTED_MSG.to_owned())) + } + } + + /// Set a single fan curve for a profile to enabled status. Will also + /// activate a fan curve if in the same profile mode + async fn set_profile_fan_curve_enabled( + &mut self, + profile: Profile, + fan: FanCurvePU, + enabled: bool, + ) -> zbus::fdo::Result<()> { + let mut ctrl = self.0.lock().await; + ctrl.profile_config.read(); + if let Some(curves) = &mut ctrl.fan_curves { + curves + .profiles_mut() + .set_profile_fan_curve_enabled(profile, fan, enabled); ctrl.write_profile_curve_to_platform() .map_err(|e| warn!("{MOD_NAME}: write_profile_curve_to_platform, {}", e)) diff --git a/rog-aura/data/aura_support.ron b/rog-aura/data/aura_support.ron index 340693ea..80704a8f 100644 --- a/rog-aura/data/aura_support.ron +++ b/rog-aura/data/aura_support.ron @@ -383,6 +383,14 @@ advanced_type: None, power_zones: [Keyboard], ), + ( + board_name: "GA402X", + layout_name: "ga401q", + basic_modes: [Static, Breathe, Pulse, Rainbow], + basic_zones: [], + advanced_type: None, + power_zones: [Keyboard], + ), ( board_name: "GA503Q", layout_name: "ga401q", diff --git a/rog-control-center/src/pages/fan_curve_page.rs b/rog-control-center/src/pages/fan_curve_page.rs index b56d839d..d20d2b0e 100644 --- a/rog-control-center/src/pages/fan_curve_page.rs +++ b/rog-control-center/src/pages/fan_curve_page.rs @@ -1,6 +1,5 @@ use egui::{RichText, Ui}; use rog_platform::supported::SupportedFunctions; -use rog_profiles::{FanCurvePU, Profile}; use crate::system_state::{FanCurvesState, ProfilesState, SystemState}; use crate::widgets::fan_graphs; @@ -47,29 +46,62 @@ impl RogApp { ui.label(RichText::new(format!("{}", profiles.current)).strong()); }); + // ui.horizontal(|ui| { + // ui.label("Enabled fan-curves: "); + // let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut + // checked: bool| { if ui + // .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan))) + // .changed() + // { + // dbus.proxies() + // .profile() + // .set_fan_curves_enabled(profile, checked) + // .map_err(|err| { + // *do_error = Some(err.to_string()); + // }) + // .ok(); + // changed = true; + // } + // }; + + // if let Some(curves) = curves.curves.get_mut(&profiles.current) { + // for curve in curves.iter_mut() { + // fan_curve_enable(profiles.current, curve.fan, curve.enabled); + // } + // } + // }); + ui.horizontal(|ui| { ui.label("Enabled fan-curves: "); - let mut fan_curve_enable = |profile: Profile, fan: FanCurvePU, mut checked: bool| { - if ui - .add(egui::Checkbox::new(&mut checked, format!("{:?}", fan))) - .changed() - { - dbus.proxies() - .profile() - .set_fan_curve_enabled(profile, checked) - .map_err(|err| { - *do_error = Some(err.to_string()); - }) - .ok(); - changed = true; - } - }; - + let mut checked = false; + let mut label = String::default(); if let Some(curves) = curves.curves.get_mut(&profiles.current) { - for curve in curves.iter_mut() { - fan_curve_enable(profiles.current, curve.fan, curve.enabled); + for curve in curves.iter() { + label.push_str(&<&str>::from(curve.fan).to_ascii_uppercase()); + label.push(' '); + if curve.enabled { + // TODO: it's possible to set just one fan to active + checked = true; + } } } + + if ui + .add(egui::Checkbox::new( + &mut checked, + RichText::new(label).strong(), + )) + .changed() + { + dbus.proxies() + .profile() + .set_fan_curves_enabled(profiles.current, checked) + .map_err(|err| { + *do_error = Some(err.to_string()); + }) + .ok(); + changed = true; + } }); if changed { diff --git a/rog-dbus/src/zbus_profile.rs b/rog-dbus/src/zbus_profile.rs index 7ffffdb7..e3969049 100644 --- a/rog-dbus/src/zbus_profile.rs +++ b/rog-dbus/src/zbus_profile.rs @@ -21,7 +21,7 @@ //! …consequently `zbus-xmlgen` did not generate code for the above interfaces. use rog_profiles::fan_curve_set::CurveData; -use rog_profiles::Profile; +use rog_profiles::{FanCurvePU, Profile}; use zbus::dbus_proxy; #[dbus_proxy( @@ -46,7 +46,16 @@ trait Profile { fn set_active_profile(&self, profile: Profile) -> zbus::Result<()>; /// Set a profile fan curve enabled status. Will also activate a fan curve. - fn set_fan_curve_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>; + fn set_fan_curves_enabled(&self, profile: Profile, enabled: bool) -> zbus::Result<()>; + + /// Set a single fan curve for a profile to enabled status. Will also + /// activate a fan curve. + async fn set_profile_fan_curve_enabled( + &mut self, + profile: Profile, + fan: FanCurvePU, + enabled: bool, + ) -> zbus::Result<()>; /// Set the fan curve for the specified profile, or the profile the user is /// currently in if profile == None. Will also activate the fan curve. diff --git a/rog-profiles/src/lib.rs b/rog-profiles/src/lib.rs index 2531a297..712adab1 100644 --- a/rog-profiles/src/lib.rs +++ b/rog-profiles/src/lib.rs @@ -300,7 +300,7 @@ impl FanCurveProfiles { Ok(()) } - pub fn set_profile_curve_enabled(&mut self, profile: Profile, enabled: bool) { + pub fn set_profile_curves_enabled(&mut self, profile: Profile, enabled: bool) { match profile { Profile::Balanced => { for curve in self.balanced.iter_mut() { @@ -320,6 +320,40 @@ impl FanCurveProfiles { } } + pub fn set_profile_fan_curve_enabled( + &mut self, + profile: Profile, + fan: FanCurvePU, + enabled: bool, + ) { + match profile { + Profile::Balanced => { + for curve in self.balanced.iter_mut() { + if curve.fan == fan { + curve.enabled = enabled; + break; + } + } + } + Profile::Performance => { + for curve in self.performance.iter_mut() { + if curve.fan == fan { + curve.enabled = enabled; + break; + } + } + } + Profile::Quiet => { + for curve in self.quiet.iter_mut() { + if curve.fan == fan { + curve.enabled = enabled; + break; + } + } + } + } + } + pub fn get_fan_curves_for(&self, name: Profile) -> &[CurveData] { match name { Profile::Balanced => &self.balanced,