mirror of
https://github.com/ilya-zlobintsev/LACT.git
synced 2025-02-25 18:55:26 -06:00
feat: handle scenarios when only the fan PWM is present, without speed readings
This commit is contained in:
parent
487b35ec18
commit
1e7d0873ff
@ -264,6 +264,7 @@ impl GpuController {
|
||||
speed_current: self.hw_mon_and_then(HwMon::get_fan_current),
|
||||
speed_max: self.hw_mon_and_then(HwMon::get_fan_max),
|
||||
speed_min: self.hw_mon_and_then(HwMon::get_fan_min),
|
||||
pwm_current: self.hw_mon_and_then(HwMon::get_fan_pwm),
|
||||
pmfw_info: PmfwInfo {
|
||||
acoustic_limit: self.handle.get_fan_acoustic_limit().ok(),
|
||||
acoustic_target: self.handle.get_fan_acoustic_target().ok(),
|
||||
|
@ -147,22 +147,33 @@ impl ThermalsPage {
|
||||
self.temperatures_label
|
||||
.set_markup(&format!("<b>{temperatures_text}</b>",));
|
||||
|
||||
match stats.fan.speed_current {
|
||||
Some(fan_speed_current) => self.fan_speed_label.set_markup(&format!(
|
||||
"<b>{} RPM ({}%)</b>",
|
||||
fan_speed_current,
|
||||
(fan_speed_current as f64
|
||||
/ stats.fan.speed_max.unwrap_or(fan_speed_current) as f64
|
||||
* 100.0)
|
||||
.round()
|
||||
)),
|
||||
let fan_label = if let Some(current_rpm) = stats.fan.speed_current {
|
||||
let text = match stats.fan.speed_max {
|
||||
Some(max_rpm) => format!(
|
||||
"<b>{current_rpm} RPM ({}%)</b>",
|
||||
((current_rpm as f64 / max_rpm as f64) * 100.0).round(),
|
||||
),
|
||||
None => format!("<b>{current_rpm} RPM</b>"),
|
||||
};
|
||||
Some(text)
|
||||
} else {
|
||||
stats.fan.pwm_current.map(|current_pwm| {
|
||||
format!(
|
||||
"<b>{}%</b>",
|
||||
((current_pwm as f64 / u8::MAX as f64) * 100.0).round()
|
||||
)
|
||||
})
|
||||
};
|
||||
|
||||
match &fan_label {
|
||||
Some(label) => self.fan_speed_label.set_markup(label),
|
||||
None => self.fan_speed_label.set_text("No fan detected"),
|
||||
}
|
||||
|
||||
if initial {
|
||||
self.fan_control_mode_stack_switcher.set_visible(true);
|
||||
self.fan_control_mode_stack_switcher
|
||||
.set_sensitive(stats.fan.speed_current.is_some());
|
||||
.set_sensitive(fan_label.is_some());
|
||||
|
||||
let child_name = match stats.fan.control_mode {
|
||||
Some(mode) if stats.fan.control_enabled => match mode {
|
||||
|
@ -188,6 +188,7 @@ pub struct FanStats {
|
||||
pub control_mode: Option<FanControlMode>,
|
||||
pub static_speed: Option<f64>,
|
||||
pub curve: Option<FanCurveMap>,
|
||||
pub pwm_current: Option<u8>,
|
||||
pub speed_current: Option<u32>,
|
||||
pub speed_max: Option<u32>,
|
||||
pub speed_min: Option<u32>,
|
||||
|
Loading…
Reference in New Issue
Block a user