From d6b4e7c25afdb145d9e47b4b4c1b52dc0c9b6aad Mon Sep 17 00:00:00 2001 From: Ilya Zlobintsev Date: Wed, 21 Oct 2020 11:12:27 +0300 Subject: [PATCH] Added temp display --- daemon/src/gpu_controller.rs | 3 ++ daemon/src/hw_mon.rs | 6 +++ daemon/src/lib.rs | 2 +- gui/src/main.rs | 6 +++ gui/src/main_window.glade | 79 ++++++++++++++++++++++++++++++++++-- 5 files changed, 91 insertions(+), 5 deletions(-) diff --git a/daemon/src/gpu_controller.rs b/daemon/src/gpu_controller.rs index b7c737c..35b6f9b 100644 --- a/daemon/src/gpu_controller.rs +++ b/daemon/src/gpu_controller.rs @@ -10,6 +10,7 @@ pub struct GpuStats { pub mem_total: u64, pub mem_freq: i32, pub gpu_freq: i32, + pub gpu_temp: i32, } #[derive(Clone)] @@ -173,6 +174,7 @@ impl GpuController { / 1024; let (mem_freq, gpu_freq) = (self.hw_mon.get_mem_freq(), self.hw_mon.get_gpu_freq()); + let gpu_temp = self.hw_mon.get_gpu_temp(); GpuStats { @@ -180,6 +182,7 @@ impl GpuController { mem_used, mem_freq, gpu_freq, + gpu_temp, } } diff --git a/daemon/src/hw_mon.rs b/daemon/src/hw_mon.rs index b73aced..63b8f82 100644 --- a/daemon/src/hw_mon.rs +++ b/daemon/src/hw_mon.rs @@ -49,4 +49,10 @@ impl HWMon { fs::read_to_string(filename).unwrap().trim().parse::().unwrap() / 1000 / 1000 } + + pub fn get_gpu_temp(&self) -> i32 { + let filename = self.hwmon_path.join("temp1_input"); + + fs::read_to_string(filename).unwrap().trim().parse::().unwrap() / 1000 + } } diff --git a/daemon/src/lib.rs b/daemon/src/lib.rs index 9f58665..629db07 100644 --- a/daemon/src/lib.rs +++ b/daemon/src/lib.rs @@ -68,7 +68,7 @@ impl Daemon { Action::GetInfo => bincode::serialize(&gpu_controller.gpu_info).unwrap(), Action::CheckAlive => vec![1], }; - println!("responding with {:?}", response); + println!("responding with {} bytes", response.len()); stream .write_all(&response) diff --git a/gui/src/main.rs b/gui/src/main.rs index f06c62e..dbe90c3 100644 --- a/gui/src/main.rs +++ b/gui/src/main.rs @@ -69,6 +69,9 @@ fn build_ui(application: >k::Application) { let vram_clock_text_buffer: TextBuffer = builder .get_object("vram_clock_text_buffer").unwrap(); + let gpu_temp_text_buffer: TextBuffer = builder + .get_object("gpu_temp_text_buffer").unwrap(); + let d = match DaemonConnection::new() { Ok(a) => a, Err(_) => { @@ -125,9 +128,12 @@ fn build_ui(application: >k::Application) { let text = format!("{}/{} MiB", gpu_stats.mem_used, gpu_stats.mem_total); vram_usage_label.set_text(&text); + gpu_clock_text_buffer.set_text(&format!("{}MHz", gpu_stats.gpu_freq)); vram_clock_text_buffer.set_text(&format!("{}MHz", gpu_stats.mem_freq)); + gpu_temp_text_buffer.set_text(&format!("{}°C", gpu_stats.gpu_temp)); + glib::Continue(true) }); diff --git a/gui/src/main_window.glade b/gui/src/main_window.glade index 178f6ef..c68bb12 100644 --- a/gui/src/main_window.glade +++ b/gui/src/main_window.glade @@ -11,6 +11,9 @@ gpu_model + + 100°C + 1.0 GT/s PCIe x1 @@ -317,9 +320,10 @@ True True - 5 + 6 5 vulkan_device_name_text_buffer + True 1 @@ -330,9 +334,10 @@ True True - 5 + 6 5 vulkan_version_text_buffer + True 1 @@ -585,10 +590,76 @@ - + + True + False + vertical + + + True + False + center + + + True + False + 5 + 5 + 5 + 5 + Temperature + + + False + True + 0 + + + + + True + True + 5 + 5 + 6 + 5 + False + False + gpu_temp_text_buffer + False + True + + + False + True + 1 + + + + + False + True + 0 + + + + + + + + 2 + - + + True + False + Ventilation + + + 2 + False +