From f2a7fc1b60cfa51cd2525d7a50701e7ec4259174 Mon Sep 17 00:00:00 2001 From: aristocratos Date: Tue, 3 Nov 2020 17:18:53 +0100 Subject: [PATCH] Fixed: Cpu temp calculation from cores if missing and better multi cpu temp support --- bpytop.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bpytop.py b/bpytop.py index b290a0b..31b269c 100755 --- a/bpytop.py +++ b/bpytop.py @@ -2721,6 +2721,7 @@ class CpuCollector(Collector): core_dict: Dict[int, int] = {} entry_int: int = 0 cpu_type: str = "" + c_max: int = 0 s_name: str = "_-_" s_label: str = "_-_" if cls.sensor_method == "psutil": @@ -2753,7 +2754,13 @@ class CpuCollector(Collector): elif (entry.label.startswith(("Core", "Tccd", "CPU")) or (name.lower().startswith("cpu") and not entry.label)) and hasattr(entry, "current") and round(entry.current) > 0: if entry.label.startswith(("Core", "Tccd")): entry_int = int(entry.label.replace("Core", "").replace("Tccd", "")) - if entry_int in core_dict: + if entry_int in core_dict and cpu_type != "ryzen": + if c_max == 0: + c_max = max(core_dict) + 1 + if c_max < THREADS // 2 and (entry_int + c_max) not in core_dict: + core_dict[(entry_int + c_max)] = round(entry.current) + continue + elif entry_int in core_dict: continue core_dict[entry_int] = round(entry.current) continue @@ -2770,8 +2777,8 @@ class CpuCollector(Collector): temp = round(entry.current) cores.append(round(entry.current)) if core_dict: - if not temp: - temp = core_dict.get(0, 0) + if not temp or temp == 1000: + temp = sum(core_dict.values()) // len(core_dict) if not cls.cpu_temp_high or not cls.cpu_temp_crit: cls.cpu_temp_high, cls.cpu_temp_crit = 80, 95 cls.cpu_temp[0].append(temp)