Added temp display

This commit is contained in:
Ilya Zlobintsev 2020-10-21 11:12:27 +03:00
parent 3463b0f3b5
commit d6b4e7c25a
5 changed files with 91 additions and 5 deletions

View File

@ -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,
}
}

View File

@ -49,4 +49,10 @@ impl HWMon {
fs::read_to_string(filename).unwrap().trim().parse::<i32>().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::<i32>().unwrap() / 1000
}
}

View File

@ -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)

View File

@ -69,6 +69,9 @@ fn build_ui(application: &gtk::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: &gtk::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)
});

View File

@ -11,6 +11,9 @@
<object class="GtkTextBuffer" id="gpu_model_text_buffer">
<property name="text">gpu_model</property>
</object>
<object class="GtkTextBuffer" id="gpu_temp_text_buffer">
<property name="text" translatable="yes">100°C</property>
</object>
<object class="GtkTextBuffer" id="link_speed_text_buffer">
<property name="text" translatable="yes">1.0 GT/s PCIe x1</property>
</object>
@ -317,9 +320,10 @@
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-top">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">5</property>
<property name="buffer">vulkan_device_name_text_buffer</property>
<property name="monospace">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@ -330,9 +334,10 @@
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-top">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">5</property>
<property name="buffer">vulkan_version_text_buffer</property>
<property name="monospace">True</property>
</object>
<packing>
<property name="left-attach">1</property>
@ -585,10 +590,76 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">5</property>
<property name="margin-bottom">5</property>
<property name="label" translatable="yes">Temperature</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkTextView">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="margin-start">5</property>
<property name="margin-end">5</property>
<property name="margin-top">6</property>
<property name="margin-bottom">5</property>
<property name="editable">False</property>
<property name="cursor-visible">False</property>
<property name="buffer">gpu_temp_text_buffer</property>
<property name="accepts-tab">False</property>
<property name="monospace">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<placeholder/>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Ventilation</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
</child>