-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
solve ratio problem #12
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,9 @@ pub fn run( | |
selected_gpu = usize::from(n - 1) | ||
} | ||
KeyCode::Char('p') => { | ||
// re-scan pci tree to let driver discover new devices (only works as sudo) | ||
//commented out because discover_gpus not implemented | ||
|
||
/* // re-scan pci tree to let driver discover new devices (only works as sudo) | ||
match nvml.discover_gpus(PciInfo { | ||
bus: 0, | ||
bus_id: "".into(), | ||
|
@@ -174,7 +176,7 @@ pub fn run( | |
gpu_list = crate::gpu::try_init_gpus(&nvml, lh)?; | ||
if selected_gpu >= gpu_list.len() { | ||
selected_gpu = 0; | ||
} | ||
} */ | ||
} | ||
_ => {} | ||
} | ||
|
@@ -198,9 +200,14 @@ fn draw_fan_speed<'d>(gpu: &GpuInfo<'d>) -> Gauge<'d> { | |
.map(|u| u as f64) | ||
.sum::<f64>() | ||
/ temps as f64; | ||
|
||
let percentage = (avg / 100.).clamp(0., 1.0); | ||
let label = format!("{:.1}%", avg); | ||
let percentage = match avg.is_nan() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is defnitely no issue with the code -- I'm thinking that maybe we should just not run the call to Wanna hoist something out side the loop to where we can check if we get values then just never run this code if we don't have to? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i will convert it to something like Result<Gauge, Error>, if error is no fans, it will get there is no fans. and, you can implement other errors in future. |
||
true => 0.0, | ||
false => avg | ||
}; | ||
let label = match avg.is_nan() { | ||
true => "No fans".to_string(), | ||
false => format!("{:.1}%", avg) | ||
}; | ||
let spanned_label = Span::styled(label, Style::new().white().bold().bg(Color::Black)); | ||
|
||
Gauge::default() | ||
alphastrata marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is implemented https://docs.rs/nvml-wrapper/latest/nvml_wrapper/struct.Nvml.html#method.discover_gpus, it's probably not available on the platform (laptop gpus).
We need a better way to conditionally show/not-show this for sure.
You can actually see it working on a multi-gpu system here #6 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i was not able to compile, i will look again
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as it writes, this function is only for linux, im testing it on windows. so i will try to not show "p to rescan" on windows
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I too should've gone deeper in the docs before snarking, soz.