mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-02-06 00:15:04 +01:00
profiles: add mid fan curve support
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
use egui::Ui;
|
||||
use egui::{RichText, Ui};
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_profiles::Profile;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
|
||||
use crate::system_state::{FanCurvesState, ProfilesState, SystemState};
|
||||
use crate::widgets::fan_graphs;
|
||||
@@ -12,10 +12,6 @@ impl RogApp {
|
||||
|
||||
egui::CentralPanel::default().show(ctx, |ui| {
|
||||
ui.heading("Custom fan curves");
|
||||
ui.label(
|
||||
"A fan curve is only active when the related profile is active and the curve is \
|
||||
enabled",
|
||||
);
|
||||
Self::fan_curve(
|
||||
supported,
|
||||
&mut states.profiles,
|
||||
@@ -44,35 +40,35 @@ impl RogApp {
|
||||
ui: &mut Ui,
|
||||
) {
|
||||
ui.separator();
|
||||
ui.label("Enabled fan-curves");
|
||||
|
||||
let mut changed = false;
|
||||
ui.horizontal(|ui| {
|
||||
let mut item = |p: Profile, curves: &mut FanCurvesState, mut checked: bool| {
|
||||
ui.label("Current profile: ");
|
||||
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!("{:?}", p)))
|
||||
.add(egui::Checkbox::new(&mut checked, format!("{:?}", fan)))
|
||||
.changed()
|
||||
{
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.set_fan_curve_enabled(p, checked)
|
||||
.set_fan_curve_enabled(profile, checked)
|
||||
.map_err(|err| {
|
||||
*do_error = Some(err.to_string());
|
||||
})
|
||||
.ok();
|
||||
|
||||
if !checked {
|
||||
curves.enabled.remove(&p);
|
||||
} else {
|
||||
curves.enabled.insert(p);
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
};
|
||||
|
||||
profiles.list.sort();
|
||||
for f in &profiles.list {
|
||||
item(*f, curves, curves.enabled.contains(f));
|
||||
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);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ use rog_aura::usb::AuraPowerDev;
|
||||
use rog_aura::{AuraEffect, AuraModeNum};
|
||||
use rog_platform::platform::GpuMode;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_profiles::fan_curve_set::FanCurveSet;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
use supergfxctl::pci_device::{GfxMode, GfxPower};
|
||||
#[cfg(not(feature = "mocking"))]
|
||||
@@ -96,8 +96,8 @@ impl ProfilesState {
|
||||
pub struct FanCurvesState {
|
||||
pub show_curve: Profile,
|
||||
pub show_graph: FanCurvePU,
|
||||
pub enabled: HashSet<Profile>,
|
||||
pub curves: BTreeMap<Profile, FanCurveSet>,
|
||||
pub curves: BTreeMap<Profile, Vec<CurveData>>,
|
||||
pub available_fans: HashSet<FanCurvePU>,
|
||||
pub drag_delta: Vec2,
|
||||
}
|
||||
|
||||
@@ -108,34 +108,24 @@ impl FanCurvesState {
|
||||
} else {
|
||||
vec![Profile::Balanced, Profile::Quiet, Profile::Performance]
|
||||
};
|
||||
let enabled = if supported.platform_profile.fan_curves {
|
||||
dbus.proxies()
|
||||
.profile()
|
||||
.enabled_fan_profiles()?
|
||||
.iter()
|
||||
.cloned()
|
||||
.collect::<HashSet<_>>()
|
||||
} else {
|
||||
HashSet::from([Profile::Balanced, Profile::Quiet, Profile::Performance])
|
||||
};
|
||||
|
||||
let mut curves: BTreeMap<Profile, FanCurveSet> = BTreeMap::new();
|
||||
let mut curves: BTreeMap<Profile, Vec<CurveData>> = BTreeMap::new();
|
||||
for p in &profiles {
|
||||
if supported.platform_profile.fan_curves {
|
||||
if !supported.platform_profile.fans.is_empty() {
|
||||
if let Ok(curve) = dbus.proxies().profile().fan_curve_data(*p) {
|
||||
curves.insert(*p, curve);
|
||||
}
|
||||
} else {
|
||||
let mut curve = FanCurveSet::default();
|
||||
curve.cpu.pwm = [30, 40, 60, 100, 140, 180, 200, 250];
|
||||
curve.cpu.temp = [20, 30, 40, 50, 70, 80, 90, 100];
|
||||
curve.gpu.pwm = [40, 80, 100, 140, 170, 200, 230, 250];
|
||||
curve.gpu.temp = [20, 30, 40, 50, 70, 80, 90, 100];
|
||||
curves.insert(*p, curve);
|
||||
curves.insert(*p, Vec::default());
|
||||
}
|
||||
}
|
||||
|
||||
let show_curve = if supported.platform_profile.fan_curves {
|
||||
let mut available_fans = HashSet::new();
|
||||
for fan in supported.platform_profile.fans.iter() {
|
||||
available_fans.insert(*fan);
|
||||
}
|
||||
|
||||
let show_curve = if !supported.platform_profile.fans.is_empty() {
|
||||
dbus.proxies().profile().active_profile()?
|
||||
} else {
|
||||
Profile::Balanced
|
||||
@@ -144,8 +134,8 @@ impl FanCurvesState {
|
||||
Ok(Self {
|
||||
show_curve,
|
||||
show_graph: FanCurvePU::CPU,
|
||||
enabled,
|
||||
curves,
|
||||
available_fans,
|
||||
drag_delta: Vec2::default(),
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
use egui::plot::Points;
|
||||
use egui::Ui;
|
||||
use rog_platform::supported::SupportedFunctions;
|
||||
use rog_profiles::fan_curve_set::CurveData;
|
||||
use rog_profiles::{FanCurvePU, Profile};
|
||||
|
||||
use crate::system_state::FanCurvesState;
|
||||
@@ -15,20 +16,36 @@ pub fn fan_graphs(
|
||||
) {
|
||||
ui.separator();
|
||||
|
||||
let mut item = |p: Profile, ui: &mut Ui| {
|
||||
let mut item = |profile: Profile, ui: &mut Ui| {
|
||||
ui.group(|ui| {
|
||||
ui.selectable_value(&mut curves.show_curve, p, format!("{p:?}"));
|
||||
ui.add_enabled_ui(curves.show_curve == p, |ui| {
|
||||
ui.selectable_value(
|
||||
&mut curves.show_graph,
|
||||
FanCurvePU::CPU,
|
||||
format!("{:?}", FanCurvePU::CPU),
|
||||
);
|
||||
ui.selectable_value(
|
||||
&mut curves.show_graph,
|
||||
FanCurvePU::GPU,
|
||||
format!("{:?}", FanCurvePU::GPU),
|
||||
);
|
||||
if ui
|
||||
.selectable_value(&mut curves.show_curve, profile, format!("{profile:?}"))
|
||||
.clicked()
|
||||
{
|
||||
dbus.proxies().profile().set_active_profile(profile).ok();
|
||||
}
|
||||
ui.add_enabled_ui(curves.show_curve == profile, |ui| {
|
||||
if curves.available_fans.contains(&FanCurvePU::CPU) {
|
||||
ui.selectable_value(
|
||||
&mut curves.show_graph,
|
||||
FanCurvePU::CPU,
|
||||
format!("{:?}", FanCurvePU::CPU),
|
||||
);
|
||||
}
|
||||
if curves.available_fans.contains(&FanCurvePU::GPU) {
|
||||
ui.selectable_value(
|
||||
&mut curves.show_graph,
|
||||
FanCurvePU::GPU,
|
||||
format!("{:?}", FanCurvePU::GPU),
|
||||
);
|
||||
}
|
||||
if curves.available_fans.contains(&FanCurvePU::MID) {
|
||||
ui.selectable_value(
|
||||
&mut curves.show_graph,
|
||||
FanCurvePU::MID,
|
||||
format!("{:?}", FanCurvePU::MID),
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
@@ -43,11 +60,13 @@ pub fn fan_graphs(
|
||||
|
||||
use egui::plot::{Line, Plot};
|
||||
|
||||
let data = if curves.show_graph == FanCurvePU::CPU {
|
||||
&mut curve.cpu
|
||||
} else {
|
||||
&mut curve.gpu
|
||||
};
|
||||
let mut data = &mut CurveData::default();
|
||||
for c in curve {
|
||||
if c.fan == curves.show_graph {
|
||||
data = c;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let mut points: Vec<[f64; 2]> = data
|
||||
.temp
|
||||
|
||||
@@ -18,7 +18,7 @@ impl RogApp {
|
||||
*page = Page::System;
|
||||
}
|
||||
|
||||
if self.supported.platform_profile.fan_curves {
|
||||
if !self.supported.platform_profile.fans.is_empty() {
|
||||
ui.separator();
|
||||
if ui
|
||||
.selectable_value(page, Page::FanCurves, "Fan Curves")
|
||||
|
||||
Reference in New Issue
Block a user