Skip to content

Commit

Permalink
Merge pull request #479 from mathoudebine/fix/476-the-parametersload-…
Browse files Browse the repository at this point in the history
…temp-memory-of-the-intel-uhd-770-gpu-are-not-displayed
  • Loading branch information
mathoudebine authored Feb 25, 2024
2 parents b2e97af + 63deacd commit 51488d3
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
11 changes: 4 additions & 7 deletions library/lcd/lcd_comm_rev_c.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,8 @@ def __init__(self, command):


class SubRevision(Enum):
UNKNOWN = bytearray((0x00,))
FIVEINCH = bytearray(
(0x63, 0x68, 0x73, 0x5f, 0x35, 0x69, 0x6e, 0x63, 0x68, 0x2e, 0x64, 0x65, 0x76, 0x31, 0x5f, 0x72, 0x6f, 0x6d,
0x31, 0x2e, 0x38, 0x37, 0x00)
)
UNKNOWN = ""
FIVEINCH = "chs_5inch"

def __init__(self, command):
self.command = command
Expand Down Expand Up @@ -199,9 +196,9 @@ def _hello(self):
# This command reads LCD answer on serial link, so it bypasses the queue
self.sub_revision = SubRevision.UNKNOWN
self._send_command(Command.HELLO, bypass_queue=True)
response = self.lcd_serial.read(23)
response = str(self.lcd_serial.read(22).decode())
self.lcd_serial.flushInput()
if response == SubRevision.FIVEINCH.value:
if response.startswith(SubRevision.FIVEINCH.value):
self.sub_revision = SubRevision.FIVEINCH
else:
logger.warning("Display returned unknown sub-revision on Hello answer (%s)" % str(response))
Expand Down
31 changes: 21 additions & 10 deletions library/sensors/sensors_librehardwaremonitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,15 @@ def temperature() -> float:
@staticmethod
def fan_percent() -> float:
mb = get_hw_and_update(Hardware.HardwareType.Motherboard)
for sh in mb.SubHardware:
sh.Update()
for sensor in sh.Sensors:
if sensor.SensorType == Hardware.SensorType.Control and "#2" in str(
sensor.Name): # Is Motherboard #2 Fan always the CPU Fan ?
return float(sensor.Value)
try:
for sh in mb.SubHardware:
sh.Update()
for sensor in sh.Sensors:
if sensor.SensorType == Hardware.SensorType.Control and "#2" in str(
sensor.Name): # Is Motherboard #2 Fan always the CPU Fan ?
return float(sensor.Value)
except:
pass

# No Fan Speed sensor for this CPU model
return math.nan
Expand Down Expand Up @@ -274,10 +277,15 @@ def stats(cls) -> Tuple[float, float, float, float]: # load (%) / used mem (%)
for sensor in gpu_to_use.Sensors:
if sensor.SensorType == Hardware.SensorType.Load and str(sensor.Name).startswith("GPU Core"):
load = float(sensor.Value)
elif sensor.SensorType == Hardware.SensorType.Load and str(sensor.Name).startswith("D3D 3D") and math.isnan(
load):
# Only use D3D usage if global "GPU Core" sensor is not available, because it is less
# precise and does not cover the entire GPU: https://www.hwinfo.com/forum/threads/what-is-d3d-usage.759/
load = float(sensor.Value)
elif sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith("GPU Memory Used"):
used_mem = float(sensor.Value)
elif sensor.SensorType == Hardware.SensorType.SmallData and str(sensor.Name).startswith(
"D3D Dedicated Memory Used") and math.isnan(used_mem):
"D3D") and str(sensor.Name).endswith("Memory Used") and math.isnan(used_mem):
# Only use D3D memory usage if global "GPU Memory Used" sensor is not available, because it is less
# precise and does not cover the entire GPU: https://www.hwinfo.com/forum/threads/what-is-d3d-usage.759/
used_mem = float(sensor.Value)
Expand Down Expand Up @@ -312,9 +320,12 @@ def fan_percent(cls) -> float:
# GPU not supported
return math.nan

for sensor in gpu_to_use.Sensors:
if sensor.SensorType == Hardware.SensorType.Control:
return float(sensor.Value)
try:
for sensor in gpu_to_use.Sensors:
if sensor.SensorType == Hardware.SensorType.Control:
return float(sensor.Value)
except:
pass

# No Fan Speed sensor for this GPU model
return math.nan
Expand Down

0 comments on commit 51488d3

Please sign in to comment.