feat: use new power1_input interface instead of average when it is available

This commit is contained in:
Ilya Zlobintsev
2023-11-15 21:58:21 +02:00
parent ca3292fd5b
commit 51e187ef2a
5 changed files with 11 additions and 4 deletions

4
Cargo.lock generated
View File

@@ -40,9 +40,9 @@ dependencies = [
[[package]]
name = "amdgpu-sysfs"
version = "0.12.2"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a20a5d3ccaa6f829840888988fd74dbc5166340d0c7ffd24d2c4d715a4d90bc9"
checksum = "b2563dbe2f3443f41116df5a23ae6b977f80feb7e5ca2fe6a4f3eb27042ecb08"
dependencies = [
"enum_dispatch",
"serde",

View File

@@ -267,6 +267,7 @@ impl GpuController {
},
power: PowerStats {
average: self.hw_mon_and_then(HwMon::get_power_average),
current: self.hw_mon_and_then(HwMon::get_power_input),
cap_current: self.hw_mon_and_then(HwMon::get_power_cap),
cap_max: self.hw_mon_and_then(HwMon::get_power_cap_max),
cap_min: self.hw_mon_and_then(HwMon::get_power_cap_min),

View File

@@ -108,13 +108,18 @@ impl StatsFrame {
let PowerStats {
average: power_average,
current: power_current,
cap_current: power_cap_current,
..
} = stats.power;
let power_current = power_current
.filter(|value| *value != 0.0)
.or(power_average);
self.power_usage_label.set_markup(&format!(
"<b>{}/{}W</b>",
power_average.unwrap_or(0.0),
power_current.unwrap_or(0.0),
power_cap_current.unwrap_or(0.0)
));

View File

@@ -7,7 +7,7 @@ edition = "2021"
args = ["clap"]
[dependencies]
amdgpu-sysfs = { version = "0.12.2", features = ["serde"] }
amdgpu-sysfs = { version = "0.12.3", features = ["serde"] }
serde = { version = "1.0", features = ["derive"] }
indexmap = { version = "*", features = ["serde"] }
clap = { version = "4.4.6", features = ["derive"], optional = true }

View File

@@ -218,6 +218,7 @@ pub struct VramStats {
#[derive(Serialize, Deserialize, Debug, Clone, Copy)]
pub struct PowerStats {
pub average: Option<f64>,
pub current: Option<f64>,
pub cap_current: Option<f64>,
pub cap_max: Option<f64>,
pub cap_min: Option<f64>,