mirror of
https://gitlab.com/asus-linux/asusctl.git
synced 2026-01-22 17:33:19 +01:00
Populate fan curve data
This commit is contained in:
@@ -5,15 +5,16 @@ use rog_anime::Animations;
|
||||
use rog_aura::usb::AuraPowerDev;
|
||||
use rog_dbus::zbus_anime::AnimeProxy;
|
||||
use rog_dbus::zbus_aura::AuraProxy;
|
||||
use rog_dbus::zbus_fan_curves::FanCurvesProxy;
|
||||
use rog_dbus::zbus_platform::{PlatformProxy, PlatformProxyBlocking};
|
||||
use rog_platform::platform::Properties;
|
||||
use rog_platform::platform::{Properties, ThrottlePolicy};
|
||||
use slint::{ComponentHandle, Model, PhysicalSize, RgbaColor, SharedString, Weak};
|
||||
use zbus::proxy::CacheProperties;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::{
|
||||
AnimePageData, AppSettingsPageData, AuraPageData, AvailableSystemProperties, MainWindow,
|
||||
PowerZones as SlintPowerZones, SystemPageData,
|
||||
AnimePageData, AppSettingsPageData, AuraPageData, AvailableSystemProperties, FanPageData,
|
||||
MainWindow, Node, PowerZones as SlintPowerZones, SystemPageData,
|
||||
};
|
||||
|
||||
// This macro expects are consistent naming between proxy calls and slint
|
||||
@@ -115,11 +116,96 @@ pub fn setup_window(config: Arc<Mutex<Config>>) -> MainWindow {
|
||||
setup_system_page(&ui, config.clone());
|
||||
setup_system_page_callbacks(&ui, config.clone());
|
||||
setup_aura_page(&ui, config.clone());
|
||||
setup_anime_page(&ui, config);
|
||||
setup_anime_page(&ui, config.clone());
|
||||
setup_fan_curve_page(&ui, config);
|
||||
|
||||
ui
|
||||
}
|
||||
|
||||
pub fn setup_fan_curve_page(ui: &MainWindow, _config: Arc<Mutex<Config>>) {
|
||||
let handle = ui.as_weak();
|
||||
|
||||
tokio::spawn(async move {
|
||||
// Create the connections/proxies here to prevent future delays in process
|
||||
let conn = zbus::Connection::system().await.unwrap();
|
||||
let fans = FanCurvesProxy::new(&conn).await.unwrap();
|
||||
|
||||
// Do initial setup
|
||||
let balanced = fans.fan_curve_data(ThrottlePolicy::Balanced).await.unwrap();
|
||||
let perf = fans
|
||||
.fan_curve_data(ThrottlePolicy::Performance)
|
||||
.await
|
||||
.unwrap();
|
||||
let quiet = fans.fan_curve_data(ThrottlePolicy::Quiet).await.unwrap();
|
||||
|
||||
handle
|
||||
.upgrade_in_event_loop(move |handle| {
|
||||
let global = handle.global::<FanPageData>();
|
||||
let collect = |temp: &[u8], pwm: &[u8]| -> slint::ModelRc<Node> {
|
||||
let tmp: Vec<Node> = temp
|
||||
.iter()
|
||||
.zip(pwm.iter())
|
||||
.map(|(x, y)| Node {
|
||||
x: *x as f32,
|
||||
y: *y as f32,
|
||||
})
|
||||
.collect();
|
||||
tmp.as_slice().into()
|
||||
};
|
||||
|
||||
for fan in balanced {
|
||||
match fan.fan {
|
||||
rog_profiles::FanCurvePU::CPU => {
|
||||
global.set_balanced_cpu_available(true);
|
||||
global.set_balanced_cpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::GPU => {
|
||||
global.set_balanced_gpu_available(true);
|
||||
global.set_balanced_gpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::MID => {
|
||||
global.set_balanced_mid_available(true);
|
||||
global.set_balanced_mid(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
}
|
||||
}
|
||||
for fan in perf {
|
||||
match fan.fan {
|
||||
rog_profiles::FanCurvePU::CPU => {
|
||||
global.set_performance_cpu_available(true);
|
||||
global.set_performance_cpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::GPU => {
|
||||
global.set_performance_gpu_available(true);
|
||||
global.set_performance_gpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::MID => {
|
||||
global.set_performance_mid_available(true);
|
||||
global.set_performance_mid(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
}
|
||||
}
|
||||
for fan in quiet {
|
||||
match fan.fan {
|
||||
rog_profiles::FanCurvePU::CPU => {
|
||||
global.set_quiet_cpu_available(true);
|
||||
global.set_quiet_cpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::GPU => {
|
||||
global.set_quiet_gpu_available(true);
|
||||
global.set_quiet_gpu(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
rog_profiles::FanCurvePU::MID => {
|
||||
global.set_quiet_mid_available(true);
|
||||
global.set_quiet_mid(collect(&fan.temp, &fan.pwm))
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.unwrap();
|
||||
});
|
||||
}
|
||||
|
||||
pub fn setup_app_settings_page(ui: &MainWindow, config: Arc<Mutex<Config>>) {
|
||||
let config_copy = config.clone();
|
||||
let global = ui.global::<AppSettingsPageData>();
|
||||
|
||||
@@ -6,6 +6,10 @@ import { PageAbout } from "pages/about.slint";
|
||||
import { PageFans } from "pages/fans.slint";
|
||||
import { PageAnime, AnimePageData } from "pages/anime.slint";
|
||||
import { PageAura } from "pages/aura.slint";
|
||||
import { Node } from "widgets/graph.slint";
|
||||
export { Node }
|
||||
import { FanPageData, FanType, Profile } from "types/fan_types.slint";
|
||||
export { FanPageData, FanType, Profile }
|
||||
import { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect } from "types/aura_types.slint";
|
||||
export { AuraPageData, AuraDevType, AuraDevTuf, AuraDevRog1, PowerZones, KbAuraPowerState, AuraPowerDev, AuraEffect }
|
||||
import { PageAppSettings, AppSettingsPageData } from "pages/app_settings.slint";
|
||||
|
||||
@@ -13,12 +13,18 @@ export enum FanType {
|
||||
}
|
||||
|
||||
export global FanPageData {
|
||||
in-out property <[Profile]> avilable_profiles: [Profile.Balanced, Profile.Performance, Profile.Quiet];
|
||||
in-out property <[FanType]> avilable_fans: [FanType.CPU, FanType.Middle, FanType.GPU];
|
||||
in-out property <[Profile]> available_profiles: [Profile.Balanced, Profile.Performance, Profile.Quiet];
|
||||
in-out property <[FanType]> available_fans: [FanType.CPU, FanType.Middle, FanType.GPU];
|
||||
|
||||
in-out property <bool> balanced_cpu_available: true;
|
||||
in-out property <bool> balanced_gpu_available: false;
|
||||
in-out property <bool> balanced_mid_available: true;
|
||||
in-out property <bool> balanced_gpu_available: true;
|
||||
in-out property <bool> balanced_mid_available: false;
|
||||
in-out property <bool> performance_cpu_available: true;
|
||||
in-out property <bool> performance_gpu_available: true;
|
||||
in-out property <bool> performance_mid_available: false;
|
||||
in-out property <bool> quiet_cpu_available: true;
|
||||
in-out property <bool> quiet_gpu_available: true;
|
||||
in-out property <bool> quiet_mid_available: false;
|
||||
|
||||
in-out property <[Node]> balanced_cpu: [
|
||||
{
|
||||
|
||||
@@ -5,7 +5,7 @@ export struct Node { x: length, y: length}
|
||||
export component Graph inherits Rectangle {
|
||||
in-out property <[Node]> nodes;
|
||||
in property <Node> node_min: { x: 0px, y: 0px };
|
||||
in property <Node> node_max: { x: 100px, y: 100px };
|
||||
in property <Node> node_max: { x: 100px, y: 255px };
|
||||
property <length> graph_padding: 20px;
|
||||
graph := Rectangle {
|
||||
width: root.width - root.graph_padding * 2;
|
||||
|
||||
Reference in New Issue
Block a user