Skip to content

Commit 51488d3

Browse files
authored
Merge pull request #479 from mathoudebine/fix/476-the-parametersload-temp-memory-of-the-intel-uhd-770-gpu-are-not-displayed
2 parents b2e97af + 63deacd commit 51488d3

File tree

2 files changed

+25
-17
lines changed

2 files changed

+25
-17
lines changed

library/lcd/lcd_comm_rev_c.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,8 @@ def __init__(self, command):
119119

120120

121121
class SubRevision(Enum):
122-
UNKNOWN = bytearray((0x00,))
123-
FIVEINCH = bytearray(
124-
(0x63, 0x68, 0x73, 0x5f, 0x35, 0x69, 0x6e, 0x63, 0x68, 0x2e, 0x64, 0x65, 0x76, 0x31, 0x5f, 0x72, 0x6f, 0x6d,
125-
0x31, 0x2e, 0x38, 0x37, 0x00)
126-
)
122+
UNKNOWN = ""
123+
FIVEINCH = "chs_5inch"
127124

128125
def __init__(self, command):
129126
self.command = command
@@ -199,9 +196,9 @@ def _hello(self):
199196
# This command reads LCD answer on serial link, so it bypasses the queue
200197
self.sub_revision = SubRevision.UNKNOWN
201198
self._send_command(Command.HELLO, bypass_queue=True)
202-
response = self.lcd_serial.read(23)
199+
response = str(self.lcd_serial.read(22).decode())
203200
self.lcd_serial.flushInput()
204-
if response == SubRevision.FIVEINCH.value:
201+
if response.startswith(SubRevision.FIVEINCH.value):
205202
self.sub_revision = SubRevision.FIVEINCH
206203
else:
207204
logger.warning("Display returned unknown sub-revision on Hello answer (%s)" % str(response))

library/sensors/sensors_librehardwaremonitor.py

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -230,12 +230,15 @@ def temperature() -> float:
230230
@staticmethod
231231
def fan_percent() -> float:
232232
mb = get_hw_and_update(Hardware.HardwareType.Motherboard)
233-
for sh in mb.SubHardware:
234-
sh.Update()
235-
for sensor in sh.Sensors:
236-
if sensor.SensorType == Hardware.SensorType.Control and "#2" in str(
237-
sensor.Name): # Is Motherboard #2 Fan always the CPU Fan ?
238-
return float(sensor.Value)
233+
try:
234+
for sh in mb.SubHardware:
235+
sh.Update()
236+
for sensor in sh.Sensors:
237+
if sensor.SensorType == Hardware.SensorType.Control and "#2" in str(
238+
sensor.Name): # Is Motherboard #2 Fan always the CPU Fan ?
239+
return float(sensor.Value)
240+
except:
241+
pass
239242

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

315-
for sensor in gpu_to_use.Sensors:
316-
if sensor.SensorType == Hardware.SensorType.Control:
317-
return float(sensor.Value)
323+
try:
324+
for sensor in gpu_to_use.Sensors:
325+
if sensor.SensorType == Hardware.SensorType.Control:
326+
return float(sensor.Value)
327+
except:
328+
pass
318329

319330
# No Fan Speed sensor for this GPU model
320331
return math.nan

0 commit comments

Comments
 (0)