first commit

This commit is contained in:
Karmel0x
2023-08-26 11:56:51 +02:00
commit 584bcadd2a
23 changed files with 1504 additions and 0 deletions

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -0,0 +1,71 @@
using AsusSystemAnalysis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsusFanControl
{
public class AsusControl
{
public AsusControl()
{
AsusWinIO64.InitializeWinIo();
}
~AsusControl()
{
AsusWinIO64.ShutdownWinIo();
}
public void SetFanSpeed(byte value, byte fanIndex = 0)
{
AsusWinIO64.HealthyTable_SetFanIndex(fanIndex);
AsusWinIO64.HealthyTable_SetFanPwmDuty(value);
AsusWinIO64.HealthyTable_SetFanTestMode((char)(value > 0 ? 0x01 : 0x00));
}
public void SetFanSpeed(int percent)
{
var value = (byte)(percent / 100.0f * 255);
SetFanSpeed(value);
}
public void SetFansSpeed(byte value)
{
var fanCount = AsusWinIO64.HealthyTable_FanCounts();
for(byte fanIndex = 0; fanIndex < fanCount; fanIndex++)
{
SetFanSpeed(value, fanIndex);
}
}
public void SetFansSpeed(int percent)
{
var value = (byte)(percent / 100.0f * 255);
SetFansSpeed(value);
}
public int GetFanSpeed(byte fanIndex = 0)
{
AsusWinIO64.HealthyTable_SetFanIndex(fanIndex);
var fanSpeed = AsusWinIO64.HealthyTable_FanRPM();
return fanSpeed;
}
public List<int> GetFanSpeeds()
{
var fanSpeeds = new List<int>();
var fanCount = AsusWinIO64.HealthyTable_FanCounts();
for (byte fanIndex = 0; fanIndex < fanCount; fanIndex++)
{
var fanSpeed = GetFanSpeed(fanIndex);
fanSpeeds.Add(fanSpeed);
}
return fanSpeeds;
}
}
}

View File

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DF94635E-4107-4EE9-8675-7137E750BC86}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>AsusFanControl</RootNamespace>
<AssemblyName>AsusFanControl</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>..\bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>..\bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<LangVersion>7.3</LangVersion>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AsusControl.cs" />
<Compile Include="AsusWinIO64.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<Content Include="AsusWinIO64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,22 @@
using System.Runtime.InteropServices;
namespace AsusSystemAnalysis
{
public class AsusWinIO64
{
[DllImport("AsusWinIO64.dll")]
public static extern void InitializeWinIo();
[DllImport("AsusWinIO64.dll")]
public static extern void ShutdownWinIo();
[DllImport("AsusWinIO64.dll")]
public static extern int HealthyTable_FanCounts();
[DllImport("AsusWinIO64.dll")]
public static extern void HealthyTable_SetFanIndex(byte index);
[DllImport("AsusWinIO64.dll")]
public static extern int HealthyTable_FanRPM();
[DllImport("AsusWinIO64.dll")]
public static extern void HealthyTable_SetFanTestMode(char mode);
[DllImport("AsusWinIO64.dll")]
public static extern void HealthyTable_SetFanPwmDuty(short duty);
}
}

Binary file not shown.

45
AsusFanControl/Program.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using AsusSystemAnalysis;
namespace AsusFanControl
{
internal static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static int Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("Usage: AsusFanControl <fanSpeedPercent>");
return 1;
}
bool tryParse = int.TryParse(args[0], out int num);
if (!tryParse)
{
Console.WriteLine("Please enter a numeric value for fan speed.");
return 1;
}
if ((num != 0 && num < 40) || num > 99)
{
Console.WriteLine("Please enter a value for fan speed between 40 and 99 or 0 for turning off test mode.");
Console.WriteLine("If you want to skip these limits you need to change it in source code.");
return 1;
}
var asusControl = new AsusControl();
var fanSpeeds = asusControl.GetFanSpeeds();
Console.WriteLine($"Current fan speeds: {string.Join(" ", fanSpeeds)}");
asusControl.SetFansSpeed(num);
return 0;
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("AsusFanControl")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AsusFanControl")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("df94635e-4107-4ee9-8675-7137e750bc86")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]