Skip to content

Commit 9e5b9f1

Browse files
overlay: hide ram_temp when no RAM temperature sensor is present
ram_temp is read from an spd5118 hwmon sensor. With no such sensor, like on handhelds, mem_temp stays 0 and the "full" layout shows a bogus "0 C". Track whether a sensor was found and only draw ram_temp when one is, so a real 0 C reading still shows.
1 parent b2d8569 commit 9e5b9f1

3 files changed

Lines changed: 5 additions & 1 deletion

File tree

src/hud_elements.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,7 +778,8 @@ void HudElements::ram(){
778778
ImGui::PopFont();
779779
}
780780

781-
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram_temp]) {
781+
// only when an spd5118 RAM temp sensor exists, else mem_temp is a bogus 0
782+
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_ram_temp] && mem_temp_available) {
782783
ImguiNextColumnOrNewRow();
783784
if (HUDElements.params->enabled[OVERLAY_PARAM_ENABLED_temp_fahrenheit])
784785
right_aligned_text(HUDElements.colors.text, HUDElements.ralign_width, "%i", HUDElements.convert_to_fahrenheit(mem_temp));

src/memory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
float memused, memmax, swapused;
1414
int mem_temp;
15+
bool mem_temp_available = false;
1516
uint64_t proc_mem_resident, proc_mem_shared, proc_mem_virt;
1617

1718
void update_meminfo() {
@@ -46,6 +47,7 @@ void update_mem_temp() {
4647
if (read_line(path + dir + "/name") == "spd5118")
4748
mem_temp_files.emplace_back(path + dir + "/temp1_input");
4849
}
50+
mem_temp_available = !mem_temp_files.empty();
4951
if (mem_temp_files.empty())
5052
SPDLOG_ERROR("failed to find known ram temp sensors");
5153
}

src/memory.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
extern float memused, memmax, swapused;
88
extern int mem_temp;
9+
extern bool mem_temp_available;
910
extern uint64_t proc_mem_resident, proc_mem_shared, proc_mem_virt;
1011

1112
void update_meminfo();

0 commit comments

Comments
 (0)