Fixes saving the sensor values on program exit and the displayed fan control values for NVIDIA GPUs.. (#575)
* Fixes saving the sensor values on program exit. * Fixes the displayed fan control values for NVIDIA GPUs. * Update NvidiaGpu.cs Check cooler id. Co-authored-by: PhyxionNL <7643972+PhyxionNL@users.noreply.github.com>
This commit is contained in:
@@ -470,13 +470,15 @@ namespace LibreHardwareMonitor.Hardware.Gpu
|
||||
|
||||
if (_controls is { Length: > 0 })
|
||||
{
|
||||
NvApi.NvFanCoolerControl fanControllers = GetFanCoolersControllers(out status);
|
||||
if (status == NvApi.NvStatus.OK && fanControllers.Count > 0)
|
||||
NvApi.NvFanCoolersStatus fanCoolers = GetFanCoolersStatus(out status);
|
||||
if (status == NvApi.NvStatus.OK && fanCoolers.Count > 0 && fanCoolers.Count == _controls.Length)
|
||||
{
|
||||
for (int i = 0; i < fanControllers.Count; i++)
|
||||
for (int i = 0; i < fanCoolers.Count; i++)
|
||||
{
|
||||
NvApi.NvFanCoolerControlItem item = fanControllers.Items[i];
|
||||
_controls[i].Value = item.Level;
|
||||
NvApi.NvFanCoolersStatusItem item = fanCoolers.Items[i];
|
||||
|
||||
if (Array.Find(_controls, c => c.Index == item.CoolerId) is { } control)
|
||||
control.Value = item.CurrentLevel;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -189,19 +189,20 @@ namespace LibreHardwareMonitor.Hardware
|
||||
using MemoryStream memoryStream = new();
|
||||
using GZipStream gZipStream = new(memoryStream, CompressionMode.Compress);
|
||||
using BufferedStream outputStream = new(gZipStream, 65536);
|
||||
using BinaryWriter binaryWriter = new(outputStream);
|
||||
|
||||
long t = 0;
|
||||
|
||||
foreach (SensorValue sensorValue in _values)
|
||||
using (BinaryWriter binaryWriter = new(outputStream))
|
||||
{
|
||||
long v = sensorValue.Time.ToBinary();
|
||||
binaryWriter.Write(v - t);
|
||||
t = v;
|
||||
binaryWriter.Write(sensorValue.Value);
|
||||
}
|
||||
long t = 0;
|
||||
|
||||
binaryWriter.Flush();
|
||||
foreach (SensorValue sensorValue in _values)
|
||||
{
|
||||
long v = sensorValue.Time.ToBinary();
|
||||
binaryWriter.Write(v - t);
|
||||
t = v;
|
||||
binaryWriter.Write(sensorValue.Value);
|
||||
}
|
||||
|
||||
binaryWriter.Flush();
|
||||
}
|
||||
|
||||
_settings.SetValue(new Identifier(Identifier, "values").ToString(), Convert.ToBase64String(memoryStream.ToArray()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user