From 6800ae38dd7a4d520aefd99b009a10ca83d91a79 Mon Sep 17 00:00:00 2001 From: seerge Date: Sun, 19 Mar 2023 17:39:30 +0100 Subject: [PATCH] Custom fan-axis for 401 model --- app/AppConfig.cs | 26 +++++++++++++++++++++++++- app/Fans.cs | 14 +++++++------- app/GHelper.csproj | 2 +- 3 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/AppConfig.cs b/app/AppConfig.cs index b629dec9..2ff13450 100644 --- a/app/AppConfig.cs +++ b/app/AppConfig.cs @@ -1,4 +1,6 @@ -using System.Text.Json; +using System.Diagnostics; +using System.Management; +using System.Text.Json; public class AppConfig { @@ -6,6 +8,8 @@ public class AppConfig public string appPath; string configFile; + string _model; + public Dictionary config = new Dictionary(); public AppConfig() @@ -36,6 +40,26 @@ public class AppConfig } + + + public bool ContainsModel(string contains) + { + if (_model is null) + { + _model = ""; + using (var searcher = new ManagementObjectSearcher(@"Select * from Win32_ComputerSystem")) + { + foreach (var process in searcher.Get()) + { + _model = process["Model"].ToString(); + break; + } + } + } + + return (_model is not null && _model.Contains(contains)); + + } private void initConfig() { config = new Dictionary(); diff --git a/app/Fans.cs b/app/Fans.cs index bf53c1ee..21232c3b 100644 --- a/app/Fans.cs +++ b/app/Fans.cs @@ -1,9 +1,4 @@ -using System; -using System.Diagnostics; -using System.Diagnostics.Metrics; -using System.Drawing.Imaging; -using System.Drawing.Text; -using System.IO; +using System.Diagnostics; using System.Windows.Forms.DataVisualization.Charting; namespace GHelper @@ -17,8 +12,13 @@ namespace GHelper static string ChartPercToRPM(int percentage, string unit = "") { + int MinRPM, MaxRPM; + MinRPM = 1800; + MaxRPM = Program.config.ContainsModel("401") ? 7200 : 5800; + if (percentage == 0) return "OFF"; - return (1800 + 200 * Math.Floor(percentage * 0.2)).ToString() + unit; + + return (200*Math.Round((float)(MinRPM + (MaxRPM-MinRPM)*percentage*0.01)/200)).ToString() + unit; } void SetChart(Chart chart, int device) diff --git a/app/GHelper.csproj b/app/GHelper.csproj index a03a05ae..2bcf0ea4 100644 --- a/app/GHelper.csproj +++ b/app/GHelper.csproj @@ -16,7 +16,7 @@ x64 False True - 0.31 + 0.33