Skip to content

Commit

Permalink
Update NvAPIWrapper library
Browse files Browse the repository at this point in the history
  • Loading branch information
lich426 committed Nov 12, 2021
1 parent 3693e10 commit 9ad23e3
Show file tree
Hide file tree
Showing 15 changed files with 5,454 additions and 31 deletions.
67 changes: 67 additions & 0 deletions DonateForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions DonateForm.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FanCtrl
{
public partial class DonateForm : Form
{
public DonateForm()
{
InitializeComponent();
this.localizeComponent();
}

private void localizeComponent()
{
this.Text = StringLib.Donate;
}
}
}
5,233 changes: 5,233 additions & 0 deletions DonateForm.resx

Large diffs are not rendered by default.

14 changes: 12 additions & 2 deletions FanCtrl.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<PublisherName>Lich</PublisherName>
<SuiteName>FanCtrl</SuiteName>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.4.4.0</ApplicationVersion>
<ApplicationVersion>1.4.5.0</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<CreateDesktopShortcut>true</CreateDesktopShortcut>
<PublishWizardCompleted>true</PublishWizardCompleted>
Expand Down Expand Up @@ -131,7 +131,8 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="NvAPIWrapper">
<Reference Include="NvAPIWrapper, Version=0.8.1.100, Culture=neutral, PublicKeyToken=310fd07b25df79b3, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>dll\NvAPIWrapper.dll</HintPath>
</Reference>
<Reference Include="OpenHardwareMonitorLib, Version=0.9.2.3, Culture=neutral, processorArchitecture=MSIL">
Expand Down Expand Up @@ -164,6 +165,12 @@
<Compile Include="ControlForm.Designer.cs">
<DependentUpon>ControlForm.cs</DependentUpon>
</Compile>
<Compile Include="DonateForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="DonateForm.Designer.cs">
<DependentUpon>DonateForm.cs</DependentUpon>
</Compile>
<Compile Include="FanCtrl\Controller\HidUSBController.cs" />
<Compile Include="FanCtrl\Controller\Kernel\AdvApi32.cs" />
<Compile Include="FanCtrl\Controller\Kernel\Kernel32.cs" />
Expand Down Expand Up @@ -289,6 +296,9 @@
<EmbeddedResource Include="ControlForm.resx">
<DependentUpon>ControlForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="DonateForm.resx">
<DependentUpon>DonateForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="HotkeyForm.resx">
<DependentUpon>HotkeyForm.cs</DependentUpon>
</EmbeddedResource>
Expand Down
6 changes: 3 additions & 3 deletions FanCtrl/Hardware/Control/NvAPIFanControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public NvAPIFanControl(string id, string name, int index, int coolerID, int valu
LastValue = value;
mMinSpeed = minSpeed;
mMaxSpeed = maxSpeed;
IsSetSpeed = true;
IsSetSpeed = false;
mDefaultCoolerPolicy = defaultCoolerPolicy;
Console.WriteLine("NvAPIFanControl.NvAPIFanControl() : defaultCoolerPolicy({0})", (int)defaultCoolerPolicy);
}
Expand Down Expand Up @@ -110,8 +110,8 @@ public override void setAuto()
var gpuArray = PhysicalGPU.GetPhysicalGPUs();
var info = gpuArray[mIndex].CoolerInformation;

//info.RestoreCoolerSettingsToDefault(mCoolerID);
info.SetCoolerSettings(mCoolerID, mDefaultCoolerPolicy);
info.RestoreCoolerSettingsToDefault(mCoolerID);
//info.SetCoolerSettings(mCoolerID, mDefaultCoolerPolicy);
//info.SetCoolerSettings(mCoolerID, NvAPIWrapper.Native.GPU.CoolerPolicy.None);
IsSetSpeed = false;
Console.WriteLine("NvAPIFanControl.setAuto() : {0}", mCoolerID);
Expand Down
25 changes: 24 additions & 1 deletion FanCtrl/Hardware/HardwareManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,36 @@ public void start()
// temperature
var id = string.Format("NvAPIWrapper/{0}/{1}/Temp", hardwareName, gpu.GPUId);
var name = "GPU Core";
var temp = new NvAPITemp(id, name, i);
var temp = new NvAPITemp(id, name, i, NvAPITemp.TEMPERATURE_TYPE.CORE);
temp.LockBus += lockBus;
temp.UnlockBus += unlockBus;

var tempDevice = new HardwareDevice(hardwareName);
tempDevice.addDevice(temp);

if (gpu.ThermalInformation.HasAnyThermalSensor == true)
{
if (gpu.ThermalInformation.HotSpotTemperature != 0)
{
id = string.Format("NvAPIWrapper/{0}/{1}/HotSpotTemp", hardwareName, gpu.GPUId);
name = "GPU Hot Spot";
temp = new NvAPITemp(id, name, i, NvAPITemp.TEMPERATURE_TYPE.HOTSPOT);
temp.LockBus += lockBus;
temp.UnlockBus += unlockBus;
tempDevice.addDevice(temp);
}

if (gpu.ThermalInformation.MemoryJunctionTemperature != 0)
{
id = string.Format("NvAPIWrapper/{0}/{1}/MemoryJunctionTemp", hardwareName, gpu.GPUId);
name = "GPU Memory Junction";
temp = new NvAPITemp(id, name, i, NvAPITemp.TEMPERATURE_TYPE.MEMORY);
temp.LockBus += lockBus;
temp.UnlockBus += unlockBus;
tempDevice.addDevice(temp);
}
}

var tempList = TempList[(int)LIBRARY_TYPE.NvAPIWrapper];
tempList.Add(tempDevice);

Expand Down
36 changes: 30 additions & 6 deletions FanCtrl/Hardware/Sensor/NvAPITemp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@ namespace FanCtrl
{
public class NvAPITemp : BaseSensor
{
public enum TEMPERATURE_TYPE
{
CORE = 0,
HOTSPOT = 1,
MEMORY = 2,
};


public delegate void LockBusHandler();
public event LockBusHandler LockBus;
public event LockBusHandler UnlockBus;

private int mIndex = -1;
private TEMPERATURE_TYPE mType = TEMPERATURE_TYPE.CORE;

public NvAPITemp(string id, string name, int index) : base(LIBRARY_TYPE.NvAPIWrapper)
public NvAPITemp(string id, string name, int index, TEMPERATURE_TYPE type) : base(LIBRARY_TYPE.NvAPIWrapper)
{
ID = id;
Name = name;
mIndex = index;
mType = type;
}

public override string getString()
Expand All @@ -35,12 +45,26 @@ public override void update()
try
{
var gpuArray = PhysicalGPU.GetPhysicalGPUs();
var e = gpuArray[mIndex].ThermalInformation.ThermalSensors.GetEnumerator();
while (e.MoveNext())

if (mType == TEMPERATURE_TYPE.CORE)
{
var e = gpuArray[mIndex].ThermalInformation.ThermalSensors.GetEnumerator();
while (e.MoveNext())
{
var value = e.Current;
Value = value.CurrentTemperature;
break;
}
}
else if (mType == TEMPERATURE_TYPE.HOTSPOT)
{
float value = gpuArray[mIndex].ThermalInformation.HotSpotTemperature;
Value = (int)Math.Round((double)value);
}
else if (mType == TEMPERATURE_TYPE.MEMORY)
{
var value = e.Current;
Value = value.CurrentTemperature;
break;
float value = gpuArray[mIndex].ThermalInformation.MemoryJunctionTemperature;
Value = (int)Math.Round((double)value);
}
}
catch { }
Expand Down
30 changes: 15 additions & 15 deletions MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,17 @@ private void onFanControlButtonClick(object sender, EventArgs e)
private void onDonatePictureBoxClick(object sender, MouseEventArgs e)
{
Console.WriteLine("MainForm.onDonatePictureBoxClick()");
System.Diagnostics.Process.Start("https://www.buymeacoffee.com/lich");

string localString = StringLib.Localize;
if (localString.CompareTo("ko") == 0)
{
var form = new DonateForm();
form.ShowDialog();
}
else
{
System.Diagnostics.Process.Start("https://www.buymeacoffee.com/lich");
}
}

private void onOSDButtonClick(object sender, EventArgs e)
Expand Down
6 changes: 3 additions & 3 deletions Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
//
// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를
// 기본값으로 할 수 있습니다.
[assembly: AssemblyVersion("1.4.4")]
[assembly: AssemblyFileVersion("1.4.4")]
[assembly: AssemblyInformationalVersion("1.4.4")]
[assembly: AssemblyVersion("1.4.5")]
[assembly: AssemblyFileVersion("1.4.5")]
[assembly: AssemblyInformationalVersion("1.4.5")]
Binary file modified Resources/donate2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 9ad23e3

Please sign in to comment.